forked from snyk-labs/nodejs-goof
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.spec.js
More file actions
58 lines (46 loc) · 1.4 KB
/
Copy pathtest.spec.js
File metadata and controls
58 lines (46 loc) · 1.4 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
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
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');
});
});
});