2016-11-24 01:50:57 +03:00
|
|
|
import {it} from 'mocha';
|
2016-11-14 16:16:51 +03:00
|
|
|
import {ghUserCanAdmin} from 'ghost-admin/helpers/gh-user-can-admin';
|
2015-06-30 16:21:03 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
describe('Unit: Helper: gh-user-can-admin', function () {
|
2015-06-30 16:21:03 +03:00
|
|
|
// Mock up roles and test for truthy
|
2015-10-28 14:36:45 +03:00
|
|
|
describe('Owner role', function () {
|
|
|
|
let user = {
|
|
|
|
get(role) {
|
2015-06-30 16:21:03 +03:00
|
|
|
if (role === 'isOwner') {
|
|
|
|
return true;
|
|
|
|
} else if (role === 'isAdmin') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2015-06-30 16:21:03 +03:00
|
|
|
it(' - can be Admin', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let result = ghUserCanAdmin([user]);
|
2015-06-30 16:21:03 +03:00
|
|
|
expect(result).to.equal(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
describe('Administrator role', function () {
|
|
|
|
let user = {
|
|
|
|
get(role) {
|
2015-06-30 16:21:03 +03:00
|
|
|
if (role === 'isOwner') {
|
|
|
|
return false;
|
|
|
|
} else if (role === 'isAdmin') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2015-06-30 16:21:03 +03:00
|
|
|
it(' - can be Admin', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let result = ghUserCanAdmin([user]);
|
2015-06-30 16:21:03 +03:00
|
|
|
expect(result).to.equal(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
describe('Editor and Author roles', function () {
|
|
|
|
let user = {
|
|
|
|
get(role) {
|
2015-06-30 16:21:03 +03:00
|
|
|
if (role === 'isOwner') {
|
|
|
|
return false;
|
|
|
|
} else if (role === 'isAdmin') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2015-06-30 16:21:03 +03:00
|
|
|
it(' - cannot be Admin', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let result = ghUserCanAdmin([user]);
|
2015-06-30 16:21:03 +03:00
|
|
|
expect(result).to.equal(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|