password.service.spec.ts
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { PasswordService } from "./password.service";
describe("Services", () => {
describe("Password Service", () => {
let $httpBackend: ng.IHttpBackendService;
let passwordService: PasswordService;
let $rootScope: ng.IRootScopeService;
let data: any;
beforeEach(angular.mock.module("main", ($translateProvider: angular.translate.ITranslateProvider) => {
$translateProvider.translations('en', {});
}));
beforeEach(inject((_$httpBackend_: ng.IHttpBackendService,
_PasswordService_: PasswordService, _$rootScope_: ng.IRootScopeService) => {
$httpBackend = _$httpBackend_;
passwordService = _PasswordService_;
$rootScope = _$rootScope_;
}));
describe("Succesfull request", () => {
it("should change user password", (done) => {
data = {
code: '1234567890',
password: 'test',
password_confirmation: 'test'
};
$httpBackend.expectPATCH(`/api/v1/new_password?code=${data.code}&password=${data.password}&password_confirmation=${data.password_confirmation}`).respond(201, [{ login: "test" }]);
passwordService.new_password('1234567890', 'test', 'test').then((response: restangular.IResponse) => {
expect(response.data[0].login).toEqual("test");
done();
});
$httpBackend.flush();
});
});
});
});