Ghost/ghost/members-api/test/unit/lib/repositories/member.test.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

const assert = require('assert');
const MemberRepository = require('../../../../lib/repositories/member');
describe('MemberRepository', function () {
describe('#isComplimentarySubscription', function () {
it('Does not error when subscription.plan is null', function () {
const repo = new MemberRepository({});
repo.isComplimentarySubscription({});
});
});
describe('#resolveContextSource', function (){
it('Maps context to source', function (){
const repo = new MemberRepository({});
let source = repo._resolveContextSource({
import: true
});
assert.equal(source, 'import');
source = repo._resolveContextSource({
importer: true
});
assert.equal(source, 'import');
source = repo._resolveContextSource({
user: true
});
assert.equal(source, 'admin');
source = repo._resolveContextSource({
user: true,
api_key: true
});
assert.equal(source, 'admin');
source = repo._resolveContextSource({
api_key: true
});
assert.equal(source, 'api');
source = repo._resolveContextSource({
});
assert.equal(source, 'member');
source = repo._resolveContextSource({
generic_context: true
});
assert.equal(source, 'member');
});
});
});