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
98 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"BASE_URL": "https://staging.player.me/api/v1", | ||
"NON_EXISTING_USERNAME": "<non-existing-username>", | ||
"USERNAME": "<username>", | ||
"PASSWORD": "<password>" | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
'use strict'; | ||
|
||
var _mocha = require('mocha'); | ||
|
||
var _chai = require('chai'); | ||
|
||
var _auth = require('../../dist/auth'); | ||
|
||
(0, _mocha.describe)('auth.prelogin', function () { | ||
var nonExistingUsername = process.env.NON_EXISTING_USERNAME; | ||
var username = process.env.USERNAME; | ||
|
||
(0, _mocha.it)('should be defined and return false if parameter is not valid', function () { | ||
_chai.assert.ok(_auth.prelogin); | ||
_chai.assert.ok(!(0, _auth.prelogin)()); | ||
}); | ||
|
||
(0, _mocha.it)('should return a Promise if login parameter is given', function () { | ||
_chai.assert.ok((0, _auth.prelogin)({ login: username }) instanceof Promise); | ||
}); | ||
|
||
(0, _mocha.it)('should resolve to an object if user exists', function (done) { | ||
(0, _auth.prelogin)({ login: username }).then(function (user) { | ||
_chai.assert.typeOf(user, 'object'); | ||
_chai.assert.ok(user.id); | ||
_chai.assert.equal(user.username, username); | ||
done(); | ||
}).catch(function () { | ||
done(new Error('env user does not exist')); | ||
}); | ||
}); | ||
|
||
(0, _mocha.it)('should reject with an error if user does not exist', function (done) { | ||
(0, _auth.prelogin)({ login: nonExistingUsername }).then(function () { | ||
done(new Error('env non-existing user exists')); | ||
}).catch(function (error) { | ||
_chai.assert.ok(error.message); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
import { describe, it } from 'mocha'; | ||
import { assert } from 'chai'; | ||
|
||
import { prelogin } from '../../dist/auth'; | ||
|
||
describe('auth.prelogin', () => { | ||
const nonExistingUsername = process.env.NON_EXISTING_USERNAME; | ||
const username = process.env.USERNAME; | ||
|
||
it('should be defined and return false if parameter is not valid', () => { | ||
assert.ok(prelogin); | ||
assert.ok(!prelogin()); | ||
}); | ||
|
||
it('should return a Promise if login parameter is given', () => { | ||
assert.ok(prelogin({ login: username }) instanceof Promise); | ||
}); | ||
|
||
it('should resolve to an object if user exists', (done) => { | ||
prelogin({ login: username }) | ||
.then((user) => { | ||
assert.typeOf(user, 'object'); | ||
assert.ok(user.id); | ||
assert.equal(user.username, username); | ||
done(); | ||
}) | ||
.catch(() => { | ||
done(new Error('env user does not exist')); | ||
}); | ||
}); | ||
|
||
it('should reject with an error if user does not exist', (done) => { | ||
prelogin({ login: nonExistingUsername }) | ||
.then(() => { | ||
done(new Error('env non-existing user exists')); | ||
}).catch((error) => { | ||
assert.ok(error.message); | ||
done(); | ||
}); | ||
}); | ||
}); |