Skip to content

Instantly share code, notes, and snippets.

@qetr1ck-op
Last active February 9, 2017 15:37
Show Gist options
  • Save qetr1ck-op/6fb5b4ce80d1743518ce980fa22aee74 to your computer and use it in GitHub Desktop.
Save qetr1ck-op/6fb5b4ce80d1743518ce980fa22aee74 to your computer and use it in GitHub Desktop.
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