forked from snyk-labs/nodejs-goof
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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'); | ||
}); | ||
}); | ||
}); |