Commit 022de891a5285f6b7d2e07347b09e7b07dbe1ca8

Authored by Victor Costa
1 parent ec5e37f2

Fix identation and replace apply by detectChanges

Showing 1 changed file with 16 additions and 16 deletions   Show diff stats
src/app/account/register.component.spec.ts
... ... @@ -50,29 +50,29 @@ describe("Register Component", () => {
50 50 expect(helper.debugElement.query('div.register-page').length).toEqual(1);
51 51 });
52 52  
53   - it("registers a new user", done => {
54   - user_data = { username: "username", password: "password", password_confirmation: "password", email: "user@company.com" };
55   - response = { };
  53 + it("registers a new user", done => {
  54 + user_data = { username: "username", password: "password", password_confirmation: "password", email: "user@company.com" };
  55 + response = {};
56 56  
57   - helper.component.account = user_data;
  57 + helper.component.account = user_data;
58 58  
59   - deferred = $q.defer();
60   - deferred.resolve({ data: response });
61   - registerService.createAccount = jasmine.createSpy("createAccount").and.returnValue(deferred.promise);
  59 + deferred = $q.defer();
  60 + deferred.resolve({ data: response });
  61 + registerService.createAccount = jasmine.createSpy("createAccount").and.returnValue(deferred.promise);
62 62  
63   - helper.component.signup();
64   - $rootScope.$apply();
  63 + helper.component.signup();
  64 + helper.detectChanges();
65 65  
66   - expect(registerService.createAccount).toHaveBeenCalledWith(user_data);
67   - expect(stateService.transitionTo).toHaveBeenCalledWith("main.environment");
68   - expect(notificationService.success).toHaveBeenCalled();
  66 + expect(registerService.createAccount).toHaveBeenCalledWith(user_data);
  67 + expect(stateService.transitionTo).toHaveBeenCalledWith("main.environment");
  68 + expect(notificationService.success).toHaveBeenCalled();
69 69  
70   - done();
71   - });
  70 + done();
  71 + });
72 72  
73 73 it("gives error when registration fails", done => {
74 74 user_data = { password: "pas" };
75   - response = { data: { message: '{ "password": ["is too short"] }'}};
  75 + response = { data: { message: '{ "password": ["is too short"] }' } };
76 76  
77 77 helper.component.account = user_data;
78 78  
... ... @@ -81,7 +81,7 @@ describe("Register Component", () => {
81 81 registerService.createAccount = jasmine.createSpy("createAccount").and.returnValue(deferred.promise);
82 82  
83 83 helper.component.signup();
84   - $rootScope.$apply();
  84 + helper.detectChanges();
85 85  
86 86 expect(registerService.createAccount).toHaveBeenCalledWith(user_data);
87 87  
... ...