-
Notifications
You must be signed in to change notification settings - Fork 0
/
hasAccessToAll.js
50 lines (39 loc) · 1.35 KB
/
hasAccessToAll.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
// During the test the env variable is set to test
process.env.NODE_ENV = 'test';
// Require the dev-dependencies
const chai = require('chai');
const { Access } = require('../../../index');
const { assert } = chai;
// Our parent block
describe('MODELS: ACCESS hasAccessToAll', () => { // eslint-disable-line
it('user is undef', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll();
assert.isFalse(bool);
done();
});
it('user.access is undef', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll({});
assert.isFalse(bool);
done();
});
it('user is admin', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll({ is_admin: true });
assert.isTrue(bool);
done();
});
it('user has access to all', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll({ access: [{ role: 'placesAdmin' }] }, 'places');
assert.isTrue(bool);
done();
});
it('user does not have access to all', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll({ access: [{ role: 'other' }] }, 'places');
assert.isFalse(bool);
done();
});
it('to does not have UNRESTRICTED_ROLES', (done) => { // eslint-disable-line
const bool = Access.hasAccessToAll({ access: [{ role: 'other' }] }, 'other');
assert.isFalse(bool);
done();
});
});