forked from JoyChou93/java-sec-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.component.spec.js
More file actions
59 lines (47 loc) · 1.49 KB
/
Copy pathauthentication.component.spec.js
File metadata and controls
59 lines (47 loc) · 1.49 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const assert = require('assert)')
describe('Component Tests', () => {
describe('PasswordComponent', () => {
let comp
let service
test('should show error if passwords do not match', () => {
// GIVEN
comp.password = 'password1';
comp.confirmPassword = 'password2';
// WHEN
comp.changePassword();
// THEN
assert(comp.doNotMatch).toBe('ERROR');
assert(comp.error).toBeNull();
assert(comp.success).toBeNull();
});
test('should call Auth.changePassword when passwords match', () => {
// GIVEN
// deepcode ignore NoHardcodedPasswords/test: <please specify a reason of ignoring this>
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
assert(service.save).toHaveBeenCalledWith('myPassword');
});
test('should set success to OK upon success', function() {
// GIVEN
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
expect(comp.doNotMatch).toBeNull();
expect(comp.error).toBeNull();
expect(comp.success).toBe('OK');
});
test('should notify of error if change password fails', function() {
// GIVEN
comp.password = comp.confirmPassword = 'myPassword';
// WHEN
comp.changePassword();
// THEN
assert(comp.doNotMatch).toBeNull();
assert(comp.success).toBeNull();
assert(comp.error).toBe('ERROR');
});
});
});