mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
2f4f6db133
no issue - add ember-suave dependency - upgrade grunt-jscs dependency - add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc - separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc - standardize es6 usage across client
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import {
|
|
describeModule,
|
|
it
|
|
} from 'ember-mocha';
|
|
import { ghUserCanAdmin } from 'ghost/helpers/gh-user-can-admin';
|
|
|
|
describe('Unit: Helper: gh-user-can-admin', function () {
|
|
// Mock up roles and test for truthy
|
|
describe('Owner role', function () {
|
|
let user = {
|
|
get(role) {
|
|
if (role === 'isOwner') {
|
|
return true;
|
|
} else if (role === 'isAdmin') {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
it(' - can be Admin', function () {
|
|
let result = ghUserCanAdmin([user]);
|
|
expect(result).to.equal(true);
|
|
});
|
|
});
|
|
|
|
describe('Administrator role', function () {
|
|
let user = {
|
|
get(role) {
|
|
if (role === 'isOwner') {
|
|
return false;
|
|
} else if (role === 'isAdmin') {
|
|
return true;
|
|
}
|
|
}
|
|
};
|
|
|
|
it(' - can be Admin', function () {
|
|
let result = ghUserCanAdmin([user]);
|
|
expect(result).to.equal(true);
|
|
});
|
|
});
|
|
|
|
describe('Editor and Author roles', function () {
|
|
let user = {
|
|
get(role) {
|
|
if (role === 'isOwner') {
|
|
return false;
|
|
} else if (role === 'isAdmin') {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
it(' - cannot be Admin', function () {
|
|
let result = ghUserCanAdmin([user]);
|
|
expect(result).to.equal(false);
|
|
});
|
|
});
|
|
});
|