-
Notifications
You must be signed in to change notification settings - Fork 303
/
authentication-client.tests.js
80 lines (64 loc) · 2.26 KB
/
authentication-client.tests.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var expect = require('chai').expect;
var ArgumentError = require('rest-facade').ArgumentError;
var AuthenticationClient = require('../../src/auth');
var OAuthAuthenticator = require('../../src/auth/OAuthAuthenticator');
var DatabaseAuthenticator = require('../../src/auth/DatabaseAuthenticator');
var PasswordlessAuthenticator = require('../../src/auth/PasswordlessAuthenticator');
var UsersManager = require('../../src/auth/UsersManager');
var TokensManager = require('../../src/auth/TokensManager');
var ensureProperty = require('../utils').ensureProperty;
describe('AuthenticationClient', function () {
describe('#constructor', function () {
it('should raise an error when no options object is provided', function () {
expect(AuthenticationClient)
.to.throw(ArgumentError, 'Authentication Client SDK options must be an object');
});
it('should raise an error when the domain is not valid', function () {
var client = AuthenticationClient.bind(null, { token: 'token', domain: '' });
expect(client)
.to.throw(ArgumentError, 'Must provide a domain');
});
});
describe('instance properties', function () {
var properties = {
'OAuthAuthenticator': {
name: 'oauth',
cls: OAuthAuthenticator
},
'DatabaseAuthenticator': {
name: 'database',
cls: DatabaseAuthenticator
},
'PasswordlessAuthenticator': {
name: 'passwordless',
cls: PasswordlessAuthenticator
},
'UsersManager': {
name: 'users',
cls: UsersManager
},
'TokensManager': {
name: 'tokens',
cls: TokensManager
}
};
var options = {
clientId: 'CLIENT_ID',
domain: 'tenant.auth0.com'
};
var client = new AuthenticationClient(options);
// Tests common to all properties.
for (var name in properties) {
var property = properties[name];
it('should expose an instance of ' + name, ensureProperty(client, property.name, property.cls));
}
});
describe('instance methods', function () {
var method;
var methods = [];
var client = new AuthenticationClient({ token: 'token', domain: 'auth0.com' });
methods.forEach(function (method) {
ensureMethod(client, method);
});
});
});