Last active
February 9, 2017 15:37
-
-
Save qetr1ck-op/6fb5b4ce80d1743518ce980fa22aee74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PasswordRecoveryService from './rest.service'; | |
describe('vv.account.password-recovery:restService', () => { | |
let sut, Resource; | |
beforeEach(() => { | |
Resource = { | |
passwordRecovery: jasmine.createSpy('passwordRecovery').and.callFake(() => Resource), | |
post: jasmine.createSpy('post'), | |
patch: jasmine.createSpy('patch'), | |
get: jasmine.createSpy('get') | |
}; | |
sut = new PasswordRecoveryService(Resource); | |
}); | |
describe('restoreByEmail()', () => { | |
it('should call restore by email as a param', () => { | |
let params = 'fakeParams'; | |
sut.restoreByEmail(params); | |
expect(sut._resource.passwordRecovery).toHaveBeenCalled(); | |
expect(sut._resource.post).toHaveBeenCalledWith(params); | |
}); | |
}); | |
describe('setNewPassword()', () => { | |
it('should call set new password with param', () => { | |
let token = '#!@3'; | |
let password = '123456'; | |
sut.setNewPassword({token, password}); | |
expect(sut._resource.passwordRecovery).toHaveBeenCalledWith(token); | |
expect(sut._resource.patch).toHaveBeenCalledWith({password}); | |
}); | |
}); | |
describe('validateToken()', () => { | |
it('should call validate token with param', () => { | |
let token = '#!@3'; | |
sut.validateToken(token); | |
expect(sut._resource.passwordRecovery).toHaveBeenCalledWith(token); | |
expect(sut._resource.get).toHaveBeenCalled(); | |
}); | |
}); | |
describe('$inject', () => { | |
let DI = ['Resource']; | |
it('should return correct array', () => { | |
expect(PasswordRecoveryService.$inject).toEqual(DI); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment