This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
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
9 changed files
with
163 additions
and
0 deletions.
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
'use strict'; | ||
|
||
require('./reset'); | ||
|
||
var _mocha = require('mocha'); | ||
|
||
var _chai = require('chai'); | ||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
'use strict'; | ||
|
||
require('./reset'); | ||
|
||
var _mocha = require('mocha'); | ||
|
||
var _chai = require('chai'); | ||
|
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,37 @@ | ||
'use strict'; | ||
|
||
var _mocha = require('mocha'); | ||
|
||
var _chai = require('chai'); | ||
|
||
var _utils = require('../lib/utils'); | ||
|
||
var _auth = require('../../dist/auth'); | ||
|
||
(0, _mocha.describe)('auth.reset', function () { | ||
var code = process.env.RESET_CODE; | ||
var password = process.env.PASSWORD; | ||
var confirm = password; | ||
|
||
(0, _mocha.it)('should be defined,\n returns a Promise,\n and reject if arguments are not valid', function (done) { | ||
_chai.assert.ok(_auth.reset); | ||
_chai.assert.typeOf((0, _auth.reset)(), 'Promise'); | ||
(0, _utils.shouldFail)((0, _auth.reset)(), done); | ||
}); | ||
|
||
(0, _mocha.it)('should fail if code is invalid', function (done) { | ||
return (0, _utils.shouldFail)((0, _auth.reset)({ code: 'invalidcode', password: password, confirm: confirm }), done); | ||
}); | ||
|
||
(0, _mocha.it)('should fail if password and confirm are not the same', function (done) { | ||
return (0, _utils.shouldFail)((0, _auth.reset)({ code: code, password: password, confirm: confirm + 1 }), done); | ||
}); | ||
|
||
if (!code) return; // skip the tests below if there is no valid code | ||
|
||
(0, _mocha.it)('should resolve with a success message if successful', function (done) { | ||
return (0, _utils.shouldSucceed)((0, _auth.reset)({ code: code, password: password, confirm: confirm }), function (success) { | ||
return _chai.assert.ok(success.message); | ||
}, done); | ||
}); | ||
}); |
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
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,49 @@ | ||
import { describe, it } from 'mocha'; | ||
import { assert } from 'chai'; | ||
import { shouldFail, shouldSucceed } from '../lib/utils'; | ||
|
||
import { reset } from '../../dist/auth'; | ||
|
||
describe('auth.reset', () => { | ||
const code = process.env.RESET_CODE; | ||
const password = process.env.PASSWORD; | ||
const confirm = password; | ||
|
||
it( | ||
`should be defined, | ||
returns a Promise, | ||
and reject if arguments are not valid`, | ||
done => { | ||
assert.ok(reset); | ||
assert.typeOf(reset(), 'Promise'); | ||
shouldFail(reset(), done); | ||
} | ||
); | ||
|
||
it( | ||
`should fail if code is invalid`, | ||
done => shouldFail( | ||
reset({ code: 'invalidcode', password, confirm }), | ||
done | ||
) | ||
); | ||
|
||
it( | ||
`should fail if password and confirm are not the same`, | ||
done => shouldFail( | ||
reset({ code, password, confirm: confirm + 1 }), | ||
done | ||
) | ||
); | ||
|
||
if (!code) return; // skip the tests below if there is no valid code | ||
|
||
it( | ||
`should resolve with a success message if successful`, | ||
done => shouldSucceed( | ||
reset({ code, password, confirm }), | ||
success => assert.ok(success.message), | ||
done | ||
) | ||
); | ||
}); |