I have the following setup (forgive me if you don't use CoffeeScript)
Authentication service
class Authentication
constructor: ($resource) ->
@$resource = $resource
authenticate: (user) ->
response = @$resource('/api/v1/login', { email: user.email, password: user.password }).save()
return response.$promise
Session controller (uses Authentication service)
class SessionController
constructor: (Authentication, $cookieStore, $location) ->
@Authentication = Authentication
@$cookieStore = $cookieStore
@$location = $location
login: ->
promise = @Authentication.authenticate(@user)
promise.then(
(response) =>
# How do I test to validate the following:
@a= true
(response) =>
# And how do I test to validated this:
@a = false
)
My question
What I can't figure out is how to test this? I would like the test to validate the value of @a
after calling @Authentication.authenticate(@user)
Thank you.
Aucun commentaire:
Enregistrer un commentaire