Updated tests eslint config to use eslint-plugin-ghost@0.5.0

no issue
- bump eslint-plugin-ghost to v0.5.0
- update core/test eslint config to use "ghost:test" in place of custom ruleset
- apply automated eslint fixes
This commit is contained in:
Kevin Ansfield 2019-08-19 12:41:09 +01:00
parent 80fbfd7a85
commit d0fa149e0e
97 changed files with 870 additions and 1065 deletions

View File

@ -4,235 +4,26 @@
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"plugins": [
"ghost"
],
"extends": [
"eslint:recommended",
"plugin:ghost/test"
],
"rules": {
// these rules were were not previously enforced in our custom rules,
// they're turned off here because they _are_ enforced in our plugin.
// TODO: remove these custom rules and fix the problems in test files where appropriate
"camelcase": "off",
"dot-notation": "off",
"eol-last": "error",
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": "error",
"func-name-matching": "off",
"func-names": "off",
"func-style": "off",
"function-paren-newline": "off",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "off",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "error",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "off",
"lines-around-directive": "off",
"lines-between-class-members": [
"error",
"always"
],
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "off",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-console": "off",
"no-continue": "error",
"no-div-regex": "off",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "off",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "off",
"no-multi-assign": "off",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": ["error", {"max": 1}],
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "off",
"no-plusplus": "error",
"no-process-env": "off",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-regex-spaces": "off",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "off",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "off",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "off",
"no-useless-constructor": "error",
"no-useless-escape": "off",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": [
"error",
{
"consistent": true
}
],
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "off",
"operator-linebreak": "off",
"padded-blocks": [
"error",
"never"
],
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "off",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": [
"error",
"as-needed"
],
"quotes": "off",
"radix": "off",
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": ["error", "always"],
"semi-spacing": "error",
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never"
}
],
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "off",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": [
"error",
"never"
],
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": "error"
// TODO: remove these custom rules and fix problems in test files
"ghost/mocha/max-top-level-suites": "off",
"ghost/mocha/no-identical-title": "off",
"ghost/mocha/no-setup-in-describe": "off",
"ghost/mocha/no-sibling-hooks": "off"
}
}

View File

@ -14,11 +14,11 @@ let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
describe('DB API', () => {
describe('DB API', function () {
let backupClient;
let schedulerClient;
before(() => {
before(function () {
return ghost()
.then(() => {
request = supertest.agent(config.get('url'));
@ -36,7 +36,7 @@ describe('DB API', () => {
});
});
beforeEach(() => {
beforeEach(function () {
eventsTriggered = {};
sinon.stub(common.events, 'emit').callsFake((eventName, eventObj) => {
@ -48,11 +48,11 @@ describe('DB API', () => {
});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('Can export a JSON database', () => {
it('Can export a JSON database', function () {
return request.get(localUtils.API.getApiQuery(`db/`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
@ -70,7 +70,7 @@ describe('DB API', () => {
});
});
it('Can import a JSON database', () => {
it('Can import a JSON database', function () {
return Promise.resolve()
.then(() => {
return request.delete(localUtils.API.getApiQuery('db/'))
@ -106,7 +106,7 @@ describe('DB API', () => {
});
});
it('Can delete all content', () => {
it('Can delete all content', function () {
return request
.get(localUtils.API.getApiQuery('posts/'))
.set('Origin', config.get('url'))

View File

@ -220,7 +220,7 @@ describe('Settings API', function () {
});
});
it('Can download routes.yaml', () => {
it('Can download routes.yaml', function () {
return request.get(localUtils.API.getApiQuery('settings/routes/yaml/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/yaml')
@ -232,7 +232,7 @@ describe('Settings API', function () {
});
});
it('Can upload routes.yaml', () => {
it('Can upload routes.yaml', function () {
const newRoutesYamlPath = `${os.tmpdir()}/routes.yaml`;
return fs.writeFile(newRoutesYamlPath, 'routes:\ncollections:\ntaxonomies:\n')

View File

@ -90,7 +90,7 @@ const expectedProperties = {
.without('token')
,
webhook: _(schema.webhooks)
.keys()
.keys()
};
_.each(expectedProperties, (value, key) => {

View File

@ -87,9 +87,9 @@ describe('Authors Content API', function () {
localUtils.API.checkResponse(jsonResponse.authors[0], 'author', ['count', 'url'], null, null);
// Each user should have the correct count and be more than 0
_.find(jsonResponse.authors, {slug:'joe-bloggs'}).count.posts.should.eql(4);
_.find(jsonResponse.authors, {slug:'slimer-mcectoplasm'}).count.posts.should.eql(1);
_.find(jsonResponse.authors, {slug:'ghost'}).count.posts.should.eql(7);
_.find(jsonResponse.authors, {slug: 'joe-bloggs'}).count.posts.should.eql(4);
_.find(jsonResponse.authors, {slug: 'slimer-mcectoplasm'}).count.posts.should.eql(1);
_.find(jsonResponse.authors, {slug: 'ghost'}).count.posts.should.eql(7);
const ids = jsonResponse.authors
.filter(author => (author.slug !== 'ghost'))

View File

@ -272,7 +272,7 @@ describe('Posts Content API', function () {
function createFilter(publishedAt, op) {
// This line deliberately uses double quotes because GQL cannot handle either double quotes
// or escaped singles, see TryGhost/GQL#34
return encodeURIComponent("published_at:" + op + "'" + publishedAt + "'");
return encodeURIComponent('published_at:' + op + '\'' + publishedAt + '\'');
}
request

View File

@ -218,7 +218,7 @@ describe('Authentication API v3', function () {
before(function () {
return ghost({forceStart: true})
.then(() => {
.then(() => {
request = supertest.agent(config.get('url'));
})
.then(() => {

View File

@ -16,11 +16,11 @@ let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
describe('DB API', () => {
describe('DB API', function () {
let backupKey;
let schedulerKey;
before(() => {
before(function () {
return ghost()
.then(() => {
request = supertest.agent(config.get('url'));
@ -34,7 +34,7 @@ describe('DB API', () => {
});
});
beforeEach(() => {
beforeEach(function () {
eventsTriggered = {};
sinon.stub(common.events, 'emit').callsFake((eventName, eventObj) => {
@ -46,11 +46,11 @@ describe('DB API', () => {
});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('can export the database with more tables', () => {
it('can export the database with more tables', function () {
return request.get(localUtils.API.getApiQuery('db/?include=clients,client_trusted_domains'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
@ -63,7 +63,7 @@ describe('DB API', () => {
});
});
it('can export & import', () => {
it('can export & import', function () {
const exportFolder = path.join(os.tmpdir(), uuid.v4());
const exportPath = path.join(exportFolder, 'export.json');
@ -106,7 +106,7 @@ describe('DB API', () => {
});
});
it('import should fail without file', () => {
it('import should fail without file', function () {
return request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
@ -114,7 +114,7 @@ describe('DB API', () => {
.expect(422);
});
it('import should fail with unsupported file', () => {
it('import should fail with unsupported file', function () {
return request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
@ -122,7 +122,7 @@ describe('DB API', () => {
.expect(415);
});
it('export can be triggered by backup integration', () => {
it('export can be triggered by backup integration', function () {
const backupQuery = `?filename=test`;
const fsStub = sinon.stub(fs, 'writeFile').resolves();
@ -138,7 +138,7 @@ describe('DB API', () => {
});
});
it('export can not be triggered by integration other than backup', () => {
it('export can not be triggered by integration other than backup', function () {
const fsStub = sinon.stub(fs, 'writeFile').resolves();
return request.post(localUtils.API.getApiQuery(`db/backup`))
@ -153,7 +153,7 @@ describe('DB API', () => {
});
});
it('export can be triggered by Admin authentication', () => {
it('export can be triggered by Admin authentication', function () {
const fsStub = sinon.stub(fs, 'writeFile').resolves();
return request.post(localUtils.API.getApiQuery(`db/backup`))

View File

@ -136,11 +136,11 @@ describe('Posts API', function () {
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201)
.then((res) => {
should.exist(res.body.posts);
should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('(Untitled)');
});
.then((res) => {
should.exist(res.body.posts);
should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('(Untitled)');
});
});
});

View File

@ -11,10 +11,10 @@ const config = require('../../../../../server/config');
const ghost = testUtils.startGhost;
let request;
describe('Redirects API', () => {
describe('Redirects API', function () {
let originalContentPath;
before(() => {
before(function () {
return ghost({redirectsFile: true})
.then(() => {
request = supertest.agent(config.get('url'));
@ -27,12 +27,12 @@ describe('Redirects API', () => {
});
});
describe('Download', () => {
afterEach(() => {
describe('Download', function () {
afterEach(function () {
configUtils.config.set('paths:contentPath', originalContentPath);
});
it('file does not exist', () => {
it('file does not exist', function () {
// Just set any content folder, which does not contain a redirects file.
configUtils.set('paths:contentPath', path.join(__dirname, '../../../utils/fixtures/data'));
@ -50,7 +50,7 @@ describe('Redirects API', () => {
});
});
it('file exists', () => {
it('file exists', function () {
return request
.get(localUtils.API.getApiQuery('redirects/json/?client_id=ghost-admin&client_secret=not_available'))
.set('Origin', config.get('url'))
@ -68,9 +68,9 @@ describe('Redirects API', () => {
});
});
describe('Upload', () => {
describe('Error cases', () => {
it('syntax error', () => {
describe('Upload', function () {
describe('Error cases', function () {
it('syntax error', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), 'something');
return request
@ -81,7 +81,7 @@ describe('Redirects API', () => {
.expect(400);
});
it('wrong format: no array', () => {
it('wrong format: no array', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), JSON.stringify({
from: 'c',
to: 'd'
@ -95,7 +95,7 @@ describe('Redirects API', () => {
.expect(422);
});
it('wrong format: no from/to', () => {
it('wrong format: no from/to', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), JSON.stringify([{to: 'd'}]));
return request
@ -107,7 +107,7 @@ describe('Redirects API', () => {
});
});
describe('Ensure re-registering redirects works', () => {
describe('Ensure re-registering redirects works', function () {
const startGhost = (options) => {
return ghost(options)
.then(() => {
@ -118,7 +118,7 @@ describe('Redirects API', () => {
});
};
it('no redirects file exists', () => {
it('no redirects file exists', function () {
return startGhost({redirectsFile: false, forceStart: true})
.then(() => {
return request
@ -155,7 +155,7 @@ describe('Redirects API', () => {
});
});
it('override', () => {
it('override', function () {
return startGhost({forceStart: true})
.then(() => {
return request

View File

@ -94,8 +94,8 @@ describe('Schedules API', function () {
describe('publish', function () {
let schedulerKey;
before(() => {
schedulerKey = _.find(testUtils.existingData.apiKeys, {integration: {slug: 'ghost-scheduler'}});
before(function () {
schedulerKey = _.find(testUtils.existingData.apiKeys, {integration: {slug: 'ghost-scheduler'}});
});
it('publishes posts', function () {

View File

@ -129,7 +129,7 @@ describe('Subscribers API', function () {
.then((newSubscriber) => {
return request
.put(localUtils.API.getApiQuery(`subscribers/${newSubscriber.id}/`))
.send({subscribers:[subscriberChanged]})
.send({subscribers: [subscriberChanged]})
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)

View File

@ -66,7 +66,7 @@ const expectedProperties = {
.without('token')
,
webhook: _(schema.webhooks)
.keys()
.keys()
};
_.each(expectedProperties, (value, key) => {

View File

@ -38,7 +38,7 @@ describe('Public API', function () {
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.then(() => {});
});
});
});
afterEach(function () {
@ -892,13 +892,13 @@ describe('Public API', function () {
localUtils.API.checkResponse(jsonResponse.users[0], 'user', ['count'], null, null, {public: true});
// Each user should have the correct count
_.find(jsonResponse.users, {slug:'joe-bloggs'}).count.posts.should.eql(4);
_.find(jsonResponse.users, {slug:'contributor'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug:'slimer-mcectoplasm'}).count.posts.should.eql(1);
_.find(jsonResponse.users, {slug:'jimothy-bogendath'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug: 'joe-bloggs'}).count.posts.should.eql(4);
_.find(jsonResponse.users, {slug: 'contributor'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug: 'slimer-mcectoplasm'}).count.posts.should.eql(1);
_.find(jsonResponse.users, {slug: 'jimothy-bogendath'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug: 'smith-wellingsworth'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug:'ghost'}).count.posts.should.eql(7);
_.find(jsonResponse.users, {slug:'inactive'}).count.posts.should.eql(0);
_.find(jsonResponse.users, {slug: 'ghost'}).count.posts.should.eql(7);
_.find(jsonResponse.users, {slug: 'inactive'}).count.posts.should.eql(0);
const ids = jsonResponse.users
.filter(user => (user.slug !== 'ghost'))
@ -1005,6 +1005,7 @@ describe('Public API', function () {
function createFilter(publishedAt, op) {
// This line deliberately uses double quotes because GQL cannot handle either double quotes
// or escaped singles, see TryGhost/GQL#34
// eslint-disable-next-line quotes
return encodeURIComponent("published_at:" + op + "'" + publishedAt + "'");
}

View File

@ -251,7 +251,7 @@ describe('Settings API', function () {
});
});
it('can download routes.yaml', () => {
it('can download routes.yaml', function () {
return request.get(localUtils.API.getApiQuery('settings/routes/yaml/'))
.set('Authorization', 'Bearer ' + accesstoken)
.set('Accept', 'application/yaml')
@ -263,7 +263,7 @@ describe('Settings API', function () {
});
});
it('can upload routes.yaml', () => {
it('can upload routes.yaml', function () {
const newRoutesYamlPath = `${os.tmpdir()}/routes.yaml`;
return fs.writeFile(newRoutesYamlPath, 'routes:\ncollections:\ntaxonomies:\n')

View File

@ -85,7 +85,7 @@ describe('Spam Prevention API', function () {
});
it('Ensure reset works: password grant type', function () {
return executeRequests(userAllowedAttempts - 1, loginAttempt, owner.email, incorrectPassword)
return executeRequests(userAllowedAttempts - 1, loginAttempt, owner.email, incorrectPassword)
.then(() => loginAttempt(owner.email, correctPassword))
// CASE: login in with bad credentials twice - which would
// take us over the limit if the block hasn't been reset

View File

@ -135,7 +135,7 @@ describe('Subscribers API', function () {
.then((newSubscriber) => {
return request
.put(localUtils.API.getApiQuery(`subscribers/${newSubscriber.id}/`))
.send({subscribers:[subscriberChanged]})
.send({subscribers: [subscriberChanged]})
.set('Authorization', 'Bearer ' + accesstoken)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)

View File

@ -13,19 +13,19 @@ var should = require('should'),
describe('Themes API', function () {
var scope = {
ownerAccessToken: '',
editorAccessToken: '',
uploadTheme: function uploadTheme(options) {
var themePath = options.themePath,
fieldName = options.fieldName || 'theme',
accessToken = options.accessToken || scope.ownerAccessToken;
ownerAccessToken: '',
editorAccessToken: '',
uploadTheme: function uploadTheme(options) {
var themePath = options.themePath,
fieldName = options.fieldName || 'theme',
accessToken = options.accessToken || scope.ownerAccessToken;
return request.post(localUtils.API.getApiQuery('themes/upload'))
.set('Authorization', 'Bearer ' + accessToken)
.attach(fieldName, themePath);
},
editor: null
}, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v4(), 'ghost-test');
return request.post(localUtils.API.getApiQuery('themes/upload'))
.set('Authorization', 'Bearer ' + accessToken)
.attach(fieldName, themePath);
},
editor: null
}, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v4(), 'ghost-test');
before(function () {
return ghost()

View File

@ -218,7 +218,7 @@ describe('Authentication API v2', function () {
before(function () {
return ghost({forceStart: true})
.then(() => {
.then(() => {
request = supertest.agent(config.get('url'));
})
.then(() => {

View File

@ -16,11 +16,11 @@ let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
describe('DB API', () => {
describe('DB API', function () {
let backupKey;
let schedulerKey;
before(() => {
before(function () {
return ghost()
.then(() => {
request = supertest.agent(config.get('url'));
@ -34,7 +34,7 @@ describe('DB API', () => {
});
});
beforeEach(() => {
beforeEach(function () {
eventsTriggered = {};
sinon.stub(common.events, 'emit').callsFake((eventName, eventObj) => {
@ -46,11 +46,11 @@ describe('DB API', () => {
});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('can export the database with more tables', () => {
it('can export the database with more tables', function () {
return request.get(localUtils.API.getApiQuery('db/?include=clients,client_trusted_domains'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
@ -63,7 +63,7 @@ describe('DB API', () => {
});
});
it('can export & import', () => {
it('can export & import', function () {
const exportFolder = path.join(os.tmpdir(), uuid.v4());
const exportPath = path.join(exportFolder, 'export.json');
@ -106,7 +106,7 @@ describe('DB API', () => {
});
});
it('import should fail without file', () => {
it('import should fail without file', function () {
return request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
@ -114,7 +114,7 @@ describe('DB API', () => {
.expect(422);
});
it('import should fail with unsupported file', () => {
it('import should fail with unsupported file', function () {
return request.post(localUtils.API.getApiQuery('db/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
@ -122,7 +122,7 @@ describe('DB API', () => {
.expect(415);
});
it('export can be triggered by backup integration', () => {
it('export can be triggered by backup integration', function () {
const backupQuery = `?filename=test`;
const fsStub = sinon.stub(fs, 'writeFile').resolves();
@ -138,7 +138,7 @@ describe('DB API', () => {
});
});
it('export can not be triggered by integration other than backup', () => {
it('export can not be triggered by integration other than backup', function () {
const fsStub = sinon.stub(fs, 'writeFile').resolves();
return request.post(localUtils.API.getApiQuery(`db/backup`))
@ -153,7 +153,7 @@ describe('DB API', () => {
});
});
it('export can be triggered by Admin authentication', () => {
it('export can be triggered by Admin authentication', function () {
const fsStub = sinon.stub(fs, 'writeFile').resolves();
return request.post(localUtils.API.getApiQuery(`db/backup`))

View File

@ -136,11 +136,11 @@ describe('Posts API', function () {
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201)
.then((res) => {
should.exist(res.body.posts);
should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('(Untitled)');
});
.then((res) => {
should.exist(res.body.posts);
should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('(Untitled)');
});
});
});

View File

@ -11,10 +11,10 @@ const config = require('../../../../../server/config');
const ghost = testUtils.startGhost;
let request;
describe('Redirects API', () => {
describe('Redirects API', function () {
let originalContentPath;
before(() => {
before(function () {
return ghost({redirectsFile: true})
.then(() => {
request = supertest.agent(config.get('url'));
@ -27,12 +27,12 @@ describe('Redirects API', () => {
});
});
describe('Download', () => {
afterEach(() => {
describe('Download', function () {
afterEach(function () {
configUtils.config.set('paths:contentPath', originalContentPath);
});
it('file does not exist', () => {
it('file does not exist', function () {
// Just set any content folder, which does not contain a redirects file.
configUtils.set('paths:contentPath', path.join(__dirname, '../../../utils/fixtures/data'));
@ -50,7 +50,7 @@ describe('Redirects API', () => {
});
});
it('file exists', () => {
it('file exists', function () {
return request
.get(localUtils.API.getApiQuery('redirects/json/?client_id=ghost-admin&client_secret=not_available'))
.set('Origin', config.get('url'))
@ -68,9 +68,9 @@ describe('Redirects API', () => {
});
});
describe('Upload', () => {
describe('Error cases', () => {
it('syntax error', () => {
describe('Upload', function () {
describe('Error cases', function () {
it('syntax error', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), 'something');
return request
@ -81,7 +81,7 @@ describe('Redirects API', () => {
.expect(400);
});
it('wrong format: no array', () => {
it('wrong format: no array', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), JSON.stringify({
from: 'c',
to: 'd'
@ -95,7 +95,7 @@ describe('Redirects API', () => {
.expect(422);
});
it('wrong format: no from/to', () => {
it('wrong format: no from/to', function () {
fs.writeFileSync(path.join(config.get('paths:contentPath'), 'redirects.json'), JSON.stringify([{to: 'd'}]));
return request
@ -107,7 +107,7 @@ describe('Redirects API', () => {
});
});
describe('Ensure re-registering redirects works', () => {
describe('Ensure re-registering redirects works', function () {
const startGhost = (options) => {
return ghost(options)
.then(() => {
@ -118,7 +118,7 @@ describe('Redirects API', () => {
});
};
it('no redirects file exists', () => {
it('no redirects file exists', function () {
return startGhost({redirectsFile: false, forceStart: true})
.then(() => {
return request
@ -155,7 +155,7 @@ describe('Redirects API', () => {
});
});
it('override', () => {
it('override', function () {
return startGhost({forceStart: true})
.then(() => {
return request

View File

@ -94,8 +94,8 @@ describe('Schedules API', function () {
describe('publish', function () {
let schedulerKey;
before(() => {
schedulerKey = _.find(testUtils.existingData.apiKeys, {integration: {slug: 'ghost-scheduler'}});
before(function () {
schedulerKey = _.find(testUtils.existingData.apiKeys, {integration: {slug: 'ghost-scheduler'}});
});
it('publishes posts', function () {

View File

@ -129,7 +129,7 @@ describe('Subscribers API', function () {
.then((newSubscriber) => {
return request
.put(localUtils.API.getApiQuery(`subscribers/${newSubscriber.id}/`))
.send({subscribers:[subscriberChanged]})
.send({subscribers: [subscriberChanged]})
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)

View File

@ -66,7 +66,7 @@ const expectedProperties = {
.without('token')
,
webhook: _(schema.webhooks)
.keys()
.keys()
};
_.each(expectedProperties, (value, key) => {

View File

@ -24,7 +24,7 @@ const exportedLatestBody = () => {
db: [{
meta: {
exported_on: 1504269105806,
version: "2.0.0"
version: '2.0.0'
},
data: {
app_fields: [],
@ -55,7 +55,7 @@ const exportedPreviousBody = () => {
db: [{
meta: {
exported_on: 1504269105806,
version: "1.20.0"
version: '1.20.0'
},
data: {
app_fields: [],
@ -86,7 +86,7 @@ const exportedLegacyBody = () => {
db: [{
meta: {
exported_on: 1504269105806,
version: "300"
version: '300'
},
data: {
app_fields: [],
@ -131,7 +131,7 @@ describe('Integration: Importer', function () {
it('ensure return structure', function () {
let exportData;
return dataImporter.doImport(exportedLatestBody().db[0], importOptions)
return dataImporter.doImport(exportedLatestBody().db[0], importOptions)
.then(function (importResult) {
should.exist(importResult);
importResult.hasOwnProperty('data').should.be.true();
@ -143,8 +143,8 @@ describe('Integration: Importer', function () {
let exportData = exportedLatestBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
created_at: "00-00-0000 00:00:00",
updated_at: "Fri, 18 Oct 2013 23:58:44 +0000",
created_at: '00-00-0000 00:00:00',
updated_at: 'Fri, 18 Oct 2013 23:58:44 +0000',
published_at: 1388318310783
});
@ -163,7 +163,7 @@ describe('Integration: Importer', function () {
});
exportData.data.tags[0] = testUtils.DataGenerator.forKnex.createTag({
updated_at: "2016-07-17T12:02:54.000Z"
updated_at: '2016-07-17T12:02:54.000Z'
});
return dataImporter.doImport(exportData, importOptions)
@ -192,8 +192,8 @@ describe('Integration: Importer', function () {
let exportData = exportedLatestBody().db[0];
exportData.data.settings[0] = testUtils.DataGenerator.forKnex.createSetting({
key: "active_theme",
value: "mytheme",
key: 'active_theme',
value: 'mytheme',
type: 'theme'
});
@ -212,9 +212,9 @@ describe('Integration: Importer', function () {
let exportData = exportedLatestBody().db[0];
exportData.data.users[0] = testUtils.DataGenerator.forKnex.createUser({
name: "Joe Bloggs",
slug: "joe-bloggs",
email: "jbloggs@example.com"
name: 'Joe Bloggs',
slug: 'joe-bloggs',
email: 'jbloggs@example.com'
});
exportData.data.users[1] = testUtils.DataGenerator.forKnex.createUser();
@ -234,11 +234,11 @@ describe('Integration: Importer', function () {
let exportData = exportedLatestBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
slug: "same"
slug: 'same'
});
exportData.data.posts[1] = testUtils.DataGenerator.forKnex.createPost({
slug: "same"
slug: 'same'
});
return dataImporter.doImport(exportData, importOptions)
@ -256,11 +256,11 @@ describe('Integration: Importer', function () {
let exportData = exportedLatestBody().db[0];
exportData.data.posts[0] = {
title: "duplicate title"
title: 'duplicate title'
};
exportData.data.posts[1] = {
title: "duplicate title"
title: 'duplicate title'
};
return dataImporter.doImport(exportData, importOptions)
@ -1137,7 +1137,7 @@ describe('Integration: Importer', function () {
});
});
it('import 2.0 Koenig post format', () => {
it('import 2.0 Koenig post format', function () {
const exportData = exportedLatestBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
@ -1407,8 +1407,8 @@ describe('1.0', function () {
});
});
describe('migrate mobiledoc/html', () => {
it('invalid mobiledoc structure', () => {
describe('migrate mobiledoc/html', function () {
it('invalid mobiledoc structure', function () {
const exportData = exportedPreviousBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
@ -1441,7 +1441,7 @@ describe('1.0', function () {
});
});
it('mobiledoc is null, html field is set', () => {
it('mobiledoc is null, html field is set', function () {
const exportData = exportedPreviousBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
@ -1518,7 +1518,7 @@ describe('1.0', function () {
});
});
it('post has "kg-card-markdown" class', () => {
it('post has "kg-card-markdown" class', function () {
const exportData = exportedPreviousBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
@ -1543,7 +1543,7 @@ describe('1.0', function () {
});
});
it('import old Koenig Beta post format', () => {
it('import old Koenig Beta post format', function () {
const exportData = exportedPreviousBody().db[0];
exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({
@ -1620,7 +1620,7 @@ describe('LTS', function () {
return dataImporter.doImport(exportData, importOptions)
.then(function () {
"0".should.eql(1, 'LTS import should fail');
'0'.should.eql(1, 'LTS import should fail');
})
.catch(function (err) {
err.message.should.eql('Detected unsupported file structure.');

View File

@ -81,104 +81,104 @@ describe('Post Model', function () {
it('can findPage, with various options', function (done) {
models.Post.findPage({page: 2})
.then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(2);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(4);
paginationResult.data.length.should.equal(15);
paginationResult.meta.pagination.page.should.equal(2);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(4);
paginationResult.data.length.should.equal(15);
return models.Post.findPage({page: 5});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(5);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(4);
paginationResult.data.length.should.equal(0);
return models.Post.findPage({page: 5});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(5);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(4);
paginationResult.data.length.should.equal(0);
return models.Post.findPage({limit: 30});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(30);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(30);
return models.Post.findPage({limit: 30});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(30);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(30);
// Test both boolean formats
return models.Post.findPage({limit: 10, staticPages: true});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(1);
// Test both boolean formats
return models.Post.findPage({limit: 10, staticPages: true});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(1);
// Test both boolean formats
return models.Post.findPage({limit: 10, staticPages: '1'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(1);
// Test both boolean formats
return models.Post.findPage({limit: 10, staticPages: '1'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(1);
// Test featured pages
return models.Post.findPage({limit: 10, filter: 'featured:true'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
// Test featured pages
return models.Post.findPage({limit: 10, filter: 'featured:true'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
// Test both boolean formats for featured pages
return models.Post.findPage({limit: 10, filter: 'featured:1'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
// Test both boolean formats for featured pages
return models.Post.findPage({limit: 10, filter: 'featured:1'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
return models.Post.findPage({limit: 10, page: 2, status: 'all'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.pages.should.equal(11);
return models.Post.findPage({limit: 10, page: 2, status: 'all'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.pages.should.equal(11);
return models.Post.findPage({limit: 'all', status: 'all'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal('all');
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(108);
return models.Post.findPage({limit: 'all', status: 'all'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal('all');
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(108);
done();
}).catch(done);
done();
}).catch(done);
});
it('can findPage for tag, with various options', function (done) {
// Test tag filter
models.Post.findPage({page: 1, filter: 'tags:bacon'})
.then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
return models.Post.findPage({page: 1, filter: 'tags:kitchen-sink'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
return models.Post.findPage({page: 1, filter: 'tags:kitchen-sink'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(1);
paginationResult.data.length.should.equal(2);
return models.Post.findPage({page: 1, filter: 'tags:injection'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(15);
return models.Post.findPage({page: 1, filter: 'tags:injection'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(15);
return models.Post.findPage({page: 2, filter: 'tags:injection'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(2);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(10);
return models.Post.findPage({page: 2, filter: 'tags:injection'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(2);
paginationResult.meta.pagination.limit.should.equal(15);
paginationResult.meta.pagination.pages.should.equal(2);
paginationResult.data.length.should.equal(10);
done();
}).catch(done);
done();
}).catch(done);
});
});
});
@ -1024,37 +1024,37 @@ describe('Post Model', function () {
return models.Post.add(secondPost, context);
}).then(function (createdSecondPost) {
// Store the slug for comparison later
secondPost.slug = createdSecondPost.get('slug');
secondPost.slug = createdSecondPost.get('slug');
Object.keys(eventsTriggered).length.should.eql(2);
should.exist(eventsTriggered['post.added']);
should.exist(eventsTriggered['user.attached']);
Object.keys(eventsTriggered).length.should.eql(2);
should.exist(eventsTriggered['post.added']);
should.exist(eventsTriggered['user.attached']);
// Update with a conflicting slug from the first post
return createdSecondPost.save({
slug: firstPost.slug
}, context);
}).then(function (updatedSecondPost) {
// Update with a conflicting slug from the first post
return createdSecondPost.save({
slug: firstPost.slug
}, context);
}).then(function (updatedSecondPost) {
// Should have updated from original
updatedSecondPost.get('slug').should.not.equal(secondPost.slug);
// Should not have a conflicted slug from the first
updatedSecondPost.get('slug').should.not.equal(firstPost.slug);
updatedSecondPost.get('slug').should.not.equal(secondPost.slug);
// Should not have a conflicted slug from the first
updatedSecondPost.get('slug').should.not.equal(firstPost.slug);
Object.keys(eventsTriggered).length.should.eql(3);
should.exist(eventsTriggered['post.edited']);
Object.keys(eventsTriggered).length.should.eql(3);
should.exist(eventsTriggered['post.edited']);
return models.Post.findOne({
id: updatedSecondPost.id,
status: 'all'
});
}).then(function (foundPost) {
return models.Post.findOne({
id: updatedSecondPost.id,
status: 'all'
});
}).then(function (foundPost) {
// Should have updated from original
foundPost.get('slug').should.not.equal(secondPost.slug);
// Should not have a conflicted slug from the first
foundPost.get('slug').should.not.equal(firstPost.slug);
foundPost.get('slug').should.not.equal(secondPost.slug);
// Should not have a conflicted slug from the first
foundPost.get('slug').should.not.equal(firstPost.slug);
done();
}).catch(done);
done();
}).catch(done);
});
});

View File

@ -91,7 +91,7 @@ describe('Frontend Routing', function () {
it('should 404 for unknown file', function (done) {
request.get('/content/images/some/file/that/doesnt-exist.jpg')
.expect('Cache-Control', testUtils.cacheRules['private'])
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(404)
.expect(/404 Image not found/)
.end(doEnd(done));

View File

@ -18,7 +18,7 @@ describe('Integration - Web - Site', function () {
before(testUtils.setup('users:roles', 'posts'));
describe('v0.1', function () {
const api = require('../../../server/api')["v0.1"];
const api = require('../../../server/api')['v0.1'];
describe('default routes.yaml', function () {
before(function () {

View File

@ -95,10 +95,10 @@ describe('Scheduling Default Adapter', function () {
const time = moment().add(20, 'milliseconds').valueOf();
scope.adapter.reschedule({
time: time,
time: time,
url: 'something',
extra: {
oldTime: time,
oldTime: time,
method: 'PUT'
}
}, {bootstrap: true});

View File

@ -1,7 +1,7 @@
const should = require('should');
const serializers = require('../../../../../../../server/api/canary/utils/serializers');
describe('Unit: canary/utils/serializers/output/all', () => {
describe('Unit: canary/utils/serializers/output/all', function () {
describe('after', function () {
it('x_by', function () {
const apiConfig = {};

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/canary/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/canary/utils/serializers');
describe('Unit: canary/utils/serializers/output/pages', () => {
describe('Unit: canary/utils/serializers/output/pages', function () {
let pageModel;
beforeEach(() => {
beforeEach(function () {
pageModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: canary/utils/serializers/output/pages', () => {
sinon.stub(mapper, 'mapPost').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper', () => {
it('calls the mapper', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/canary/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/canary/utils/serializers');
describe('Unit: canary/utils/serializers/output/posts', () => {
describe('Unit: canary/utils/serializers/output/posts', function () {
let postModel;
beforeEach(() => {
beforeEach(function () {
postModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: canary/utils/serializers/output/posts', () => {
sinon.stub(mapper, 'mapPost').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper', () => {
it('calls the mapper', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/canary/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/canary/utils/serializers');
describe('Unit: canary/utils/serializers/output/tags', () => {
describe('Unit: canary/utils/serializers/output/tags', function () {
let tagModel;
beforeEach(() => {
beforeEach(function () {
tagModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: canary/utils/serializers/output/tags', () => {
sinon.stub(mapper, 'mapTag').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper when single tag present', () => {
it('calls the mapper when single tag present', function () {
const apiConfig = {};
const frame = {
options: {
@ -35,7 +35,7 @@ describe('Unit: canary/utils/serializers/output/tags', () => {
mapper.mapTag.getCall(0).args.should.eql([ctrlResponse, frame]);
});
it('calls the mapper with multiple tags', () => {
it('calls the mapper with multiple tags', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -3,17 +3,17 @@ const sinon = require('sinon');
const settingsCache = require('../../../../../../../../server/services/settings/cache');
const dateUtil = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/date');
describe('Unit: canary/utils/serializers/output/utils/date', () => {
afterEach(() => {
describe('Unit: canary/utils/serializers/output/utils/date', function () {
afterEach(function () {
sinon.restore();
});
it('creates date strings in ISO 8601 format with UTC offset', () => {
it('creates date strings in ISO 8601 format with UTC offset', function () {
const timezone = 'Europe/Oslo';
const testDates = [
{in: '2014-01-01T01:28:58.593Z', out: '2014-01-01T02:28:58.593+01:00'},
{in:'2014-12-31T23:28:58.123Z', out: '2015-01-01T00:28:58.123+01:00'},
{in:'2014-03-01T01:28:58.593Z', out: '2014-03-01T02:28:58.593+01:00'}
{in: '2014-12-31T23:28:58.123Z', out: '2015-01-01T00:28:58.123+01:00'},
{in: '2014-03-01T01:28:58.593Z', out: '2014-03-01T02:28:58.593+01:00'}
];
sinon.stub(settingsCache, 'get').returns(timezone);

View File

@ -2,7 +2,7 @@ const should = require('should');
const sinon = require('sinon');
const extraAttrsUtil = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/extra-attrs');
describe('Unit: canary/utils/serializers/output/utils/extra-attrs', () => {
describe('Unit: canary/utils/serializers/output/utils/extra-attrs', function () {
const frame = {
options: {}
};
@ -16,7 +16,7 @@ describe('Unit: canary/utils/serializers/output/utils/extra-attrs', () => {
});
describe('for post', function () {
it('respects custom excerpt', () => {
it('respects custom excerpt', function () {
const attrs = {custom_excerpt: 'custom excerpt'};
extraAttrsUtil.forPost(frame, model, attrs);
@ -25,7 +25,7 @@ describe('Unit: canary/utils/serializers/output/utils/extra-attrs', () => {
attrs.excerpt.should.eql(attrs.custom_excerpt);
});
it('no custom excerpt', () => {
it('no custom excerpt', function () {
const attrs = {};
extraAttrsUtil.forPost(frame, model, attrs);
@ -34,7 +34,7 @@ describe('Unit: canary/utils/serializers/output/utils/extra-attrs', () => {
attrs.excerpt.should.eql(new Array(501).join('A'));
});
it('has excerpt when plaintext is null', () => {
it('has excerpt when plaintext is null', function () {
model.get.withArgs('plaintext').returns(null);
const attrs = {};

View File

@ -7,8 +7,8 @@ const cleanUtil = require('../../../../../../../../server/api/canary/utils/seria
const extraAttrsUtils = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/extra-attrs');
const mapper = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/mapper');
describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
beforeEach(() => {
describe('Unit: canary/utils/serializers/output/utils/mapper', function () {
beforeEach(function () {
sinon.stub(dateUtil, 'forPost').returns({});
sinon.stub(urlUtil, 'forPost').returns({});
@ -22,14 +22,14 @@ describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
sinon.stub(cleanUtil, 'author').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
describe('mapPost', () => {
describe('mapPost', function () {
let postModel;
beforeEach(() => {
beforeEach(function () {
postModel = (data) => {
return Object.assign(data, {
toJSON: sinon.stub().returns(data)
@ -37,7 +37,7 @@ describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
};
});
it('calls mapper on relations', () => {
it('calls mapper on relations', function () {
const frame = {
options: {
withRelated: ['tags', 'authors'],
@ -79,16 +79,16 @@ describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapUser', () => {
describe('mapUser', function () {
let userModel;
beforeEach(() => {
beforeEach(function () {
userModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('calls utils', () => {
it('calls utils', function () {
const frame = {
options: {
context: {}
@ -107,16 +107,16 @@ describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapTag', () => {
describe('mapTag', function () {
let tagModel;
beforeEach(() => {
beforeEach(function () {
tagModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('calls utils', () => {
it('calls utils', function () {
const frame = {
options: {
context: {}
@ -135,16 +135,16 @@ describe('Unit: canary/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapIntegration', () => {
describe('mapIntegration', function () {
let integrationModel;
beforeEach(() => {
beforeEach(function () {
integrationModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('formats admin keys', () => {
it('formats admin keys', function () {
const frame = {
};

View File

@ -5,27 +5,27 @@ const urlService = require('../../../../../../../../frontend/services/url');
const urlUtils = require('../../../../../../../../server/lib/url-utils');
const urlUtil = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/url');
describe('Unit: canary/utils/serializers/output/utils/url', () => {
beforeEach(() => {
describe('Unit: canary/utils/serializers/output/utils/url', function () {
beforeEach(function () {
sinon.stub(urlService, 'getUrlByResourceId').returns('getUrlByResourceId');
sinon.stub(urlUtils, 'urlFor').returns('urlFor');
sinon.stub(urlUtils, 'htmlRelativeToAbsolute').returns({html: sinon.stub()});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
describe('Ensure calls url service', () => {
describe('Ensure calls url service', function () {
let pageModel;
beforeEach(() => {
beforeEach(function () {
pageModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('meta & models & relations', () => {
it('meta & models & relations', function () {
const post = pageModel(testUtils.DataGenerator.forKnex.createPost({
id: 'id1',
feature_image: 'value'

View File

@ -1,24 +1,24 @@
const should = require('should');
const optionsUtil = require('../../../../../server/api/shared/utils/options');
describe('Unit: api/shared/util/options', () => {
it('returns an array with empty string when no parameters are passed', () => {
describe('Unit: api/shared/util/options', function () {
it('returns an array with empty string when no parameters are passed', function () {
optionsUtil.trimAndLowerCase().should.eql(['']);
});
it('returns single item array', () => {
it('returns single item array', function () {
optionsUtil.trimAndLowerCase('butter').should.eql(['butter']);
});
it('returns multiple items in array', () => {
it('returns multiple items in array', function () {
optionsUtil.trimAndLowerCase('peanut, butter').should.eql(['peanut', 'butter']);
});
it('lowercases and trims items in the string', () => {
it('lowercases and trims items in the string', function () {
optionsUtil.trimAndLowerCase(' PeanUt, buTTer ').should.eql(['peanut', 'butter']);
});
it('accepts parameters in form of an array', () => {
it('accepts parameters in form of an array', function () {
optionsUtil.trimAndLowerCase([' PeanUt', ' buTTer ']).should.eql(['peanut', 'butter']);
});
});

View File

@ -250,7 +250,7 @@ describe('Unit: api/shared/validators/input/all', function () {
.catch((err) => {
should.exist(err);
});
});
});
});
describe('read', function () {

View File

@ -45,7 +45,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -63,7 +63,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -82,7 +82,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -101,7 +101,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -121,7 +121,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
urlService.getUrlByResourceId.withArgs(object.id).returns('url');
@ -140,7 +140,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -158,7 +158,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
@ -176,7 +176,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};
urlService.getUrlByResourceId.withArgs(object.id).returns('url');
@ -195,7 +195,7 @@ describe('Unit: api:v0.1:decorators:urls', function () {
const options = {
absolute_urls: true,
context: {
public: true
public: true
}
};

View File

@ -518,7 +518,7 @@ describe('API Utils', function () {
apiUtils.checkObject(_.cloneDeep(object), 'posts')
.then(function () {
"Test should fail".should.eql(false);
'Test should fail'.should.eql(false);
})
.catch(function (err) {
(err instanceof common.errors.BadRequestError).should.be.true;
@ -557,7 +557,7 @@ describe('API Utils', function () {
apiUtils.checkObject(_.cloneDeep(object), 'posts')
.then(function () {
"Test should fail".should.eql(false);
'Test should fail'.should.eql(false);
})
.catch(function (err) {
(err instanceof common.errors.BadRequestError).should.be.true;

View File

@ -1,7 +1,7 @@
const should = require('should');
const serializers = require('../../../../../../../server/api/v2/utils/serializers');
describe('Unit: v2/utils/serializers/output/all', () => {
describe('Unit: v2/utils/serializers/output/all', function () {
describe('after', function () {
it('x_by', function () {
const apiConfig = {};

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/v2/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/v2/utils/serializers');
describe('Unit: v2/utils/serializers/output/pages', () => {
describe('Unit: v2/utils/serializers/output/pages', function () {
let pageModel;
beforeEach(() => {
beforeEach(function () {
pageModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: v2/utils/serializers/output/pages', () => {
sinon.stub(mapper, 'mapPost').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper', () => {
it('calls the mapper', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/v2/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/v2/utils/serializers');
describe('Unit: v2/utils/serializers/output/posts', () => {
describe('Unit: v2/utils/serializers/output/posts', function () {
let postModel;
beforeEach(() => {
beforeEach(function () {
postModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: v2/utils/serializers/output/posts', () => {
sinon.stub(mapper, 'mapPost').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper', () => {
it('calls the mapper', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -4,10 +4,10 @@ const testUtils = require('../../../../../../utils');
const mapper = require('../../../../../../../server/api/v2/utils/serializers/output/utils/mapper');
const serializers = require('../../../../../../../server/api/v2/utils/serializers');
describe('Unit: v2/utils/serializers/output/tags', () => {
describe('Unit: v2/utils/serializers/output/tags', function () {
let tagModel;
beforeEach(() => {
beforeEach(function () {
tagModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
@ -15,11 +15,11 @@ describe('Unit: v2/utils/serializers/output/tags', () => {
sinon.stub(mapper, 'mapTag').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
it('calls the mapper when single tag present', () => {
it('calls the mapper when single tag present', function () {
const apiConfig = {};
const frame = {
options: {
@ -35,7 +35,7 @@ describe('Unit: v2/utils/serializers/output/tags', () => {
mapper.mapTag.getCall(0).args.should.eql([ctrlResponse, frame]);
});
it('calls the mapper with multiple tags', () => {
it('calls the mapper with multiple tags', function () {
const apiConfig = {};
const frame = {
options: {

View File

@ -3,17 +3,17 @@ const sinon = require('sinon');
const settingsCache = require('../../../../../../../../server/services/settings/cache');
const dateUtil = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/date');
describe('Unit: v2/utils/serializers/output/utils/date', () => {
afterEach(() => {
describe('Unit: v2/utils/serializers/output/utils/date', function () {
afterEach(function () {
sinon.restore();
});
it('creates date strings in ISO 8601 format with UTC offset', () => {
it('creates date strings in ISO 8601 format with UTC offset', function () {
const timezone = 'Europe/Oslo';
const testDates = [
{in: '2014-01-01T01:28:58.593Z', out: '2014-01-01T02:28:58.593+01:00'},
{in:'2014-12-31T23:28:58.123Z', out: '2015-01-01T00:28:58.123+01:00'},
{in:'2014-03-01T01:28:58.593Z', out: '2014-03-01T02:28:58.593+01:00'}
{in: '2014-12-31T23:28:58.123Z', out: '2015-01-01T00:28:58.123+01:00'},
{in: '2014-03-01T01:28:58.593Z', out: '2014-03-01T02:28:58.593+01:00'}
];
sinon.stub(settingsCache, 'get').returns(timezone);

View File

@ -2,7 +2,7 @@ const should = require('should');
const sinon = require('sinon');
const extraAttrsUtil = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/extra-attrs');
describe('Unit: v2/utils/serializers/output/utils/extra-attrs', () => {
describe('Unit: v2/utils/serializers/output/utils/extra-attrs', function () {
const frame = {
options: {}
};
@ -16,7 +16,7 @@ describe('Unit: v2/utils/serializers/output/utils/extra-attrs', () => {
});
describe('for post', function () {
it('respects custom excerpt', () => {
it('respects custom excerpt', function () {
const attrs = {custom_excerpt: 'custom excerpt'};
extraAttrsUtil.forPost(frame, model, attrs);
@ -25,7 +25,7 @@ describe('Unit: v2/utils/serializers/output/utils/extra-attrs', () => {
attrs.excerpt.should.eql(attrs.custom_excerpt);
});
it('no custom excerpt', () => {
it('no custom excerpt', function () {
const attrs = {};
extraAttrsUtil.forPost(frame, model, attrs);
@ -34,7 +34,7 @@ describe('Unit: v2/utils/serializers/output/utils/extra-attrs', () => {
attrs.excerpt.should.eql(new Array(501).join('A'));
});
it('has excerpt when plaintext is null', () => {
it('has excerpt when plaintext is null', function () {
model.get.withArgs('plaintext').returns(null);
const attrs = {};

View File

@ -7,8 +7,8 @@ const cleanUtil = require('../../../../../../../../server/api/v2/utils/serialize
const extraAttrsUtils = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/extra-attrs');
const mapper = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/mapper');
describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
beforeEach(() => {
describe('Unit: v2/utils/serializers/output/utils/mapper', function () {
beforeEach(function () {
sinon.stub(dateUtil, 'forPost').returns({});
sinon.stub(urlUtil, 'forPost').returns({});
@ -22,14 +22,14 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
sinon.stub(cleanUtil, 'author').returns({});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
describe('mapPost', () => {
describe('mapPost', function () {
let postModel;
beforeEach(() => {
beforeEach(function () {
postModel = (data) => {
return Object.assign(data, {
toJSON: sinon.stub().returns(data)
@ -37,7 +37,7 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
};
});
it('calls mapper on relations', () => {
it('calls mapper on relations', function () {
const frame = {
options: {
withRelated: ['tags', 'authors'],
@ -79,16 +79,16 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapUser', () => {
describe('mapUser', function () {
let userModel;
beforeEach(() => {
beforeEach(function () {
userModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('calls utils', () => {
it('calls utils', function () {
const frame = {
options: {
context: {}
@ -107,16 +107,16 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapTag', () => {
describe('mapTag', function () {
let tagModel;
beforeEach(() => {
beforeEach(function () {
tagModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('calls utils', () => {
it('calls utils', function () {
const frame = {
options: {
context: {}
@ -135,16 +135,16 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
});
});
describe('mapIntegration', () => {
describe('mapIntegration', function () {
let integrationModel;
beforeEach(() => {
beforeEach(function () {
integrationModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('formats admin keys', () => {
it('formats admin keys', function () {
const frame = {
};

View File

@ -5,27 +5,27 @@ const urlService = require('../../../../../../../../frontend/services/url');
const urlUtils = require('../../../../../../../../server/lib/url-utils');
const urlUtil = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/url');
describe('Unit: v2/utils/serializers/output/utils/url', () => {
beforeEach(() => {
describe('Unit: v2/utils/serializers/output/utils/url', function () {
beforeEach(function () {
sinon.stub(urlService, 'getUrlByResourceId').returns('getUrlByResourceId');
sinon.stub(urlUtils, 'urlFor').returns('urlFor');
sinon.stub(urlUtils, 'htmlRelativeToAbsolute').returns({html: sinon.stub()});
});
afterEach(() => {
afterEach(function () {
sinon.restore();
});
describe('Ensure calls url service', () => {
describe('Ensure calls url service', function () {
let pageModel;
beforeEach(() => {
beforeEach(function () {
pageModel = (data) => {
return Object.assign(data, {toJSON: sinon.stub().returns(data)});
};
});
it('meta & models & relations', () => {
it('meta & models & relations', function () {
const post = pageModel(testUtils.DataGenerator.forKnex.createPost({
id: 'id1',
feature_image: 'value'

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
ampComponentsHelper = require('../../../../frontend/apps/amp/lib/helpers/amp_components');
describe('{{amp_components}} helper', function () {

View File

@ -76,10 +76,10 @@ describe('{{amp_content}} helper', function () {
id: 1
},
testData2 = {
html: 'Hello Ghost',
updated_at: 'Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)',
id: 1
},
html: 'Hello Ghost',
updated_at: 'Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)',
id: 1
},
ampResult = ampContentHelper.call(testData1),
amperizeCache = ampContentHelper.__get__('amperizeCache');

View File

@ -1,7 +1,7 @@
// We use the name input_password to match the helper for consistency:
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
input_password = require('../../../../frontend/apps/private-blogging/lib/helpers/input_password');
describe('{{input_password}} helper', function () {

View File

@ -23,7 +23,7 @@ describe('Config', function () {
// we manually call `loadConf` in the tests and we need to ensure that the minimum
// required config properties are available
process.env['paths__contentPath'] = 'content/';
process.env.paths__contentPath = 'content/';
});
afterEach(function () {
@ -32,7 +32,7 @@ describe('Config', function () {
});
it('env parameter is stronger than file', function () {
process.env['database__client'] = 'test';
process.env.database__client = 'test';
customConfig = config.loadNconf({
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
@ -43,7 +43,7 @@ describe('Config', function () {
});
it('argv is stronger than env parameter', function () {
process.env['database__client'] = 'test';
process.env.database__client = 'test';
process.argv[2] = '--database:client=stronger';
customConfig = config.loadNconf({
@ -55,7 +55,7 @@ describe('Config', function () {
});
it('argv or env is NOT stronger than overrides', function () {
process.env['paths__corePath'] = 'try-to-override';
process.env.paths__corePath = 'try-to-override';
process.argv[2] = '--paths:corePath=try-to-override';
customConfig = config.loadNconf({

View File

@ -447,18 +447,18 @@ describe('Importer', function () {
path: '/my/test/testing.png',
name: 'testing.png'
},
{
path: '/my/test/photo/kitten.jpg',
name: 'photo/kitten.jpg'
},
{
path: '/my/test/content/images/animated/bunny.gif',
name: 'content/images/animated/bunny.gif'
},
{
path: '/my/test/images/puppy.jpg',
name: 'images/puppy.jpg'
}],
{
path: '/my/test/photo/kitten.jpg',
name: 'photo/kitten.jpg'
},
{
path: '/my/test/content/images/animated/bunny.gif',
name: 'content/images/animated/bunny.gif'
},
{
path: '/my/test/images/puppy.jpg',
name: 'images/puppy.jpg'
}],
storeSpy = sinon.spy(store, 'getUniqueFileName'),
storageSpy = sinon.spy(storage, 'getStorage');

View File

@ -20,7 +20,7 @@ describe('getAmpUrl', function () {
});
afterEach(function () {
sinon.restore();
sinon.restore();
});
it('should return amp url for post', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
getBlogLogo = require('../../../../frontend/meta/blog_logo'),
sinon = require('sinon'),
var should = require('should'),
getBlogLogo = require('../../../../frontend/meta/blog_logo'),
sinon = require('sinon'),
settingsCache = require('../../../../server/services/settings/cache');
describe('getBlogLogo', function () {

View File

@ -5,53 +5,53 @@ var should = require('should'),
describe('getSchema', function () {
it('should return post schema if context starts with post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
dimensions: {
width: 500,
height: 500
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Custom excerpt for description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Custom excerpt for description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -104,54 +104,54 @@ describe('getSchema', function () {
it('should return page schema if context starts with page', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
dimensions: {
width: 500,
height: 500
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Page Title',
url: 'http://mysite.com/post/my-page-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypagecoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two'],
metaDescription: 'Post meta description',
excerpt: 'Custom excerpt for description'
}, data = {
context: ['page'],
page: {
primary_author: {
name: 'Page Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Page Title',
url: 'http://mysite.com/post/my-page-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypagecoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two'],
metaDescription: 'Post meta description',
excerpt: 'Custom excerpt for description'
}, data = {
context: ['page'],
page: {
primary_author: {
name: 'Page Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
},
schema = getSchema(metadata, data);
schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -204,57 +204,57 @@ describe('getSchema', function () {
it('should return post schema if context starts with amp', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg',
dimensions: {
width: 500,
height: 500
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-amp-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Post meta description'
}, data = {
context: ['amp', 'post'],
post: {
title: 'Post Title',
slug: 'my-amp-post-slug',
mobiledoc: markdownToMobiledoc('some markdown'),
html: 'some html',
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-amp-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Post meta description'
}, data = {
context: ['amp', 'post'],
post: {
title: 'Post Title',
slug: 'my-amp-post-slug',
mobiledoc: markdownToMobiledoc('some markdown'),
html: 'some html',
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser'
}
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -307,33 +307,33 @@ describe('getSchema', function () {
it('should return post schema removing null or undefined values', function (done) {
var metadata = {
blog: {
title: 'Blog Title'
},
authorImage: null,
authorFacebook: undefined,
creatorTwitter: undefined,
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: undefined,
keywords: [],
metaDescription: '',
excerpt: 'Post meta description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: undefined,
bio: null,
facebook: null,
twitter: null
blog: {
title: 'Blog Title'
},
authorImage: null,
authorFacebook: undefined,
creatorTwitter: undefined,
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: undefined,
keywords: [],
metaDescription: '',
excerpt: 'Post meta description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: undefined,
bio: null,
facebook: null,
twitter: null
}
}
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -364,42 +364,42 @@ describe('getSchema', function () {
it('should return image url instead of ImageObjects if no dimensions supplied', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg'
blog: {
title: 'Blog Title',
url: 'http://mysite.com',
logo: {
url: 'http://mysite.com/author/image/url/logo.jpg'
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg'
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg'
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Post meta description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser',
metaDescription: 'My author bio.'
}
}
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg'
},
authorFacebook: 'testuser',
creatorTwitter: '@testuser',
authorUrl: 'http://mysite.com/author/me/',
metaTitle: 'Post Title',
url: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg'
},
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description',
excerpt: 'Post meta description'
}, data = {
context: ['post'],
post: {
primary_author: {
name: 'Post Author',
website: 'http://myblogsite.com/',
bio: 'My author bio.',
facebook: 'testuser',
twitter: '@testuser',
metaDescription: 'My author bio.'
}
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -438,21 +438,21 @@ describe('getSchema', function () {
it('should return home schema if context starts with home', function () {
var metadata = {
blog: {
title: 'Blog Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
metaDescription: 'This is the theme description'
}, data = {
context: ['home']
}, schema = getSchema(metadata, data);
blog: {
title: 'Blog Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
metaDescription: 'This is the theme description'
}, data = {
context: ['home']
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -479,24 +479,24 @@ describe('getSchema', function () {
it('should return tag schema if context starts with tag', function () {
var metadata = {
blog: {
title: 'Blog Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
blog: {
title: 'Blog Title'
},
url: 'http://mysite.com/post/my-post-slug/',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
metaDescription: 'This is the tag description!'
}, data = {
context: ['tag'],
tag: {
name: 'Great Tag'
}
},
metaDescription: 'This is the tag description!'
}, data = {
context: ['tag'],
tag: {
name: 'Great Tag'
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',
@ -524,27 +524,27 @@ describe('getSchema', function () {
it('should return author schema if context starts with author', function () {
var metadata = {
blog: {
title: 'Blog Title',
url: 'http://mysite.com'
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
blog: {
title: 'Blog Title',
url: 'http://mysite.com'
},
authorImage: {
url: 'http://mysite.com/author/image/url/me.jpg',
dimensions: {
width: 500,
height: 500
}
},
authorUrl: 'http://mysite.com/author/me/',
metaDescription: 'This is the author description!'
}, data = {
context: ['author'],
author: {
name: 'Author Name',
website: 'http://myblogsite.com/?user=bambedibu&a=<script>alert("bambedibu")</script>',
twitter: '@testuser'
}
},
authorUrl: 'http://mysite.com/author/me/',
metaDescription: 'This is the author description!'
}, data = {
context: ['author'],
author: {
name: 'Author Name',
website: 'http://myblogsite.com/?user=bambedibu&a=<script>alert("bambedibu")</script>',
twitter: '@testuser'
}
}, schema = getSchema(metadata, data);
}, schema = getSchema(metadata, data);
should.deepEqual(schema, {
'@context': 'https://schema.org',

View File

@ -4,37 +4,37 @@ var should = require('should'),
describe('getStructuredData', function () {
it('should return structured data from metadata per post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
facebook: 'testuser',
twitter: '@testuser'
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
ogImage: {
url: null
},
twitterImage: null,
ogTitle: '',
ogDescription: '',
twitterTitle: '',
twitterDescription: '',
authorFacebook: 'testpage',
creatorTwitter: '@twitterpage',
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description'
}, structuredData = getStructuredData(metadata);
blog: {
title: 'Blog Title',
facebook: 'testuser',
twitter: '@testuser'
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
coverImage: {
url: 'http://mysite.com/content/image/mypostcoverimage.jpg',
dimensions: {
width: 500,
height: 500
}
},
ogImage: {
url: null
},
twitterImage: null,
ogTitle: '',
ogDescription: '',
twitterTitle: '',
twitterDescription: '',
authorFacebook: 'testpage',
creatorTwitter: '@twitterpage',
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description'
}, structuredData = getStructuredData(metadata);
should.deepEqual(structuredData, {
'article:modified_time': '2016-01-21T22:13:05.412Z',
@ -67,34 +67,34 @@ describe('getStructuredData', function () {
it('should return structured data from metadata with provided og and twitter images only per post', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
facebook: 'testuser',
twitter: '@testuser'
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
ogImage: {
url: 'http://mysite.com/content/image/mypostogimage.jpg',
dimensions: {
width: 20,
height: 100
}
},
twitterImage: 'http://mysite.com/content/image/myposttwitterimage.jpg',
ogTitle: 'Custom Facebook title',
ogDescription: 'Custom Facebook description',
twitterTitle: 'Custom Twitter title',
twitterDescription: 'Custom Twitter description',
authorFacebook: 'testpage',
creatorTwitter: '@twitterpage',
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description'
}, structuredData = getStructuredData(metadata);
blog: {
title: 'Blog Title',
facebook: 'testuser',
twitter: '@testuser'
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
publishedDate: '2015-12-25T05:35:01.234Z',
modifiedDate: '2016-01-21T22:13:05.412Z',
ogImage: {
url: 'http://mysite.com/content/image/mypostogimage.jpg',
dimensions: {
width: 20,
height: 100
}
},
twitterImage: 'http://mysite.com/content/image/myposttwitterimage.jpg',
ogTitle: 'Custom Facebook title',
ogDescription: 'Custom Facebook description',
twitterTitle: 'Custom Twitter title',
twitterDescription: 'Custom Twitter description',
authorFacebook: 'testpage',
creatorTwitter: '@twitterpage',
keywords: ['one', 'two', 'tag'],
metaDescription: 'Post meta description'
}, structuredData = getStructuredData(metadata);
should.deepEqual(structuredData, {
'article:modified_time': '2016-01-21T22:13:05.412Z',
@ -127,32 +127,32 @@ describe('getStructuredData', function () {
it('should return structured data from metadata with no nulls', function (done) {
var metadata = {
blog: {
title: 'Blog Title',
facebook: '',
twitter: ''
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
modifiedDate: '2016-01-21T22:13:05.412Z',
authorFacebook: null,
creatorTwitter: null,
coverImage: {
url: undefined
},
ogImage: {
url: null
},
twitterImage: null,
ogTitle: null,
ogDescription: null,
twitterTitle: null,
twitterDescription: null,
keywords: null,
metaDescription: null
}, structuredData = getStructuredData(metadata);
blog: {
title: 'Blog Title',
facebook: '',
twitter: ''
},
authorName: 'Test User',
ogType: 'article',
metaTitle: 'Post Title',
canonicalUrl: 'http://mysite.com/post/my-post-slug/',
modifiedDate: '2016-01-21T22:13:05.412Z',
authorFacebook: null,
creatorTwitter: null,
coverImage: {
url: undefined
},
ogImage: {
url: null
},
twitterImage: null,
ogTitle: null,
ogDescription: null,
twitterTitle: null,
twitterDescription: null,
keywords: null,
metaDescription: null
}, structuredData = getStructuredData(metadata);
should.deepEqual(structuredData, {
'article:modified_time': '2016-01-21T22:13:05.412Z',

View File

@ -30,7 +30,7 @@ describe('{{author}} helper', function () {
});
it('Returns a blank string where author data is missing', function () {
const result = helpers.author.call({author:null}, {hash: {}});
const result = helpers.author.call({author: null}, {hash: {}});
String(result).should.equal('');
});

View File

@ -1,7 +1,7 @@
var should = require('should'),
themeList = require('../../../frontend/services/themes/list'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{body_class}} helper', function () {

View File

@ -40,8 +40,8 @@ describe('{{concat}} helper', function () {
it('can correctly concat things that resolve to empty', function () {
compile('{{concat tag.slug slug}}')
.with({tag: {}})
.should.eql('');
.with({tag: {}})
.should.eql('');
});
it('can concat simple strings', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{content}} helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers'),
moment = require('moment-timezone');

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{encode}} helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{excerpt}} Helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{facebook_url}} helper', function () {

View File

@ -63,10 +63,10 @@ describe('{{#get}} helper', function () {
meta = {pagination: {}};
beforeEach(function () {
browsePostsStub = sinon.stub(api["v0.1"].posts, 'browse');
readPostsStub = sinon.stub(api["v0.1"].posts, 'read');
readTagsStub = sinon.stub(api["v0.1"].tags, 'read').returns(new Promise.resolve({tags: []}));
readUsersStub = sinon.stub(api["v0.1"].users, 'read').returns(new Promise.resolve({users: []}));
browsePostsStub = sinon.stub(api['v0.1'].posts, 'browse');
readPostsStub = sinon.stub(api['v0.1'].posts, 'read');
readTagsStub = sinon.stub(api['v0.1'].tags, 'read').returns(new Promise.resolve({tags: []}));
readUsersStub = sinon.stub(api['v0.1'].users, 'read').returns(new Promise.resolve({users: []}));
browsePostsStub.returns(new Promise.resolve({posts: testPostsArr, meta: meta}));
browsePostsStub.withArgs({limit: '3'}).returns(new Promise.resolve({
@ -258,7 +258,7 @@ describe('{{#get}} helper', function () {
const meta = {pagination: {}};
beforeEach(function () {
browseUsersStub = sinon.stub(api["v0.1"].users, 'browse');
browseUsersStub = sinon.stub(api['v0.1'].users, 'browse');
browseUsersStub.returns(new Promise.resolve({users: [], meta: meta}));
});
@ -285,7 +285,7 @@ describe('{{#get}} helper', function () {
const meta = {pagination: {}};
beforeEach(function () {
browseUsersStub = sinon.stub(api["v0.1"].users, 'browse');
browseUsersStub = sinon.stub(api['v0.1'].users, 'browse');
browseUsersStub.returns(new Promise.resolve({users: [], meta: meta}));
});
@ -310,7 +310,7 @@ describe('{{#get}} helper', function () {
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v2'}}};
browseUsersStub = sinon.stub(api["v2"], 'authorsPublic').get(() => {
browseUsersStub = sinon.stub(api.v2, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
@ -343,7 +343,7 @@ describe('{{#get}} helper', function () {
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'v2'}}};
browseUsersStub = sinon.stub(api["v2"], 'authorsPublic').get(() => {
browseUsersStub = sinon.stub(api.v2, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
@ -376,7 +376,7 @@ describe('{{#get}} helper', function () {
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'canary'}}};
browseUsersStub = sinon.stub(api["canary"], 'authorsPublic').get(() => {
browseUsersStub = sinon.stub(api.canary, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
@ -409,7 +409,7 @@ describe('{{#get}} helper', function () {
beforeEach(function () {
locals = {root: {_locals: {apiVersion: 'canary'}}};
browseUsersStub = sinon.stub(api["canary"], 'authorsPublic').get(() => {
browseUsersStub = sinon.stub(api.canary, 'authorsPublic').get(() => {
return {
browse: sinon.stub().resolves({authors: [], meta: meta})
};
@ -490,8 +490,8 @@ describe('{{#get}} helper', function () {
};
beforeEach(function () {
browseStub = sinon.stub(api["v0.1"].posts, 'browse').returns(new Promise.resolve());
readStub = sinon.stub(api["v0.1"].posts, 'read').returns(new Promise.resolve());
browseStub = sinon.stub(api['v0.1'].posts, 'browse').returns(new Promise.resolve());
readStub = sinon.stub(api['v0.1'].posts, 'read').returns(new Promise.resolve());
});
it('should resolve post.tags alias', function (done) {
@ -554,7 +554,7 @@ describe('{{#get}} helper', function () {
helpers.get.call(
resource,
'posts',
{hash: {filter: "published_at:<='{{post.published_at}}'"}, data: locals, fn: fn, inverse: inverse}
{hash: {filter: 'published_at:<=\'{{post.published_at}}\''}, data: locals, fn: fn, inverse: inverse}
).then(function () {
browseStub.firstCall.args.should.be.an.Array().with.lengthOf(1);
browseStub.firstCall.args[0].should.be.an.Object().with.property('filter');

View File

@ -1,3 +1,4 @@
/* eslint-disable no-regex-spaces */
const should = require('should'),
sinon = require('sinon'),
_ = require('lodash'),
@ -517,8 +518,8 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on post page with author image and post cover image', function (done) {
var renderObject = {
post: posts[2]
}, postBk = _.cloneDeep(renderObject.post);
post: posts[2]
}, postBk = _.cloneDeep(renderObject.post);
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: renderObject,
@ -586,8 +587,8 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on post page with custom excerpt for description and meta description', function (done) {
var renderObject = {
post: posts[3]
}, postBk = _.cloneDeep(renderObject.post);
post: posts[3]
}, postBk = _.cloneDeep(renderObject.post);
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: renderObject,
@ -646,8 +647,8 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on post page with fall back excerpt if no meta description provided', function (done) {
var renderObject = {
post: posts[4]
}, postBk = _.cloneDeep(renderObject.post);
post: posts[4]
}, postBk = _.cloneDeep(renderObject.post);
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: renderObject,
@ -695,8 +696,8 @@ describe('{{ghost_head}} helper', function () {
it('returns structured data on AMP post page with author image and post cover image', function (done) {
var renderObject = {
post: posts[5]
}, postBk = _.cloneDeep(renderObject.post);
post: posts[5]
}, postBk = _.cloneDeep(renderObject.post);
helpers.ghost_head(testUtils.createHbsResponse({
renderObject: renderObject,

View File

@ -1,7 +1,7 @@
var should = require('should'),
sinon = require('sinon'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{#has}} helper', function () {

View File

@ -102,14 +102,14 @@ describe('{{link}} helper', function () {
it('can handle classes that come from variables', function () {
compile('{{#link href="#myheading" class=slug}}text{{/link}}')
.with({slug: 'fred'})
.should.eql('<a class="fred" href="#myheading">text</a>');
.with({slug: 'fred'})
.should.eql('<a class="fred" href="#myheading">text</a>');
});
it('can handle classes that come from helpers', function () {
compile('{{#link href="#myheading" class=(concat "my-" slug)}}text{{/link}}')
.with({slug: 'fred'})
.should.eql('<a class="my-fred" href="#myheading">text</a>');
.with({slug: 'fred'})
.should.eql('<a class="my-fred" href="#myheading">text</a>');
});
it('supports multiple attributes', function () {

View File

@ -1,8 +1,8 @@
const should = require('should');
const hbs = require('../../../frontend/services/themes/engine');
const configUtils = require('../../utils/configUtils');
const path = require('path');
const helpers = require('../../../frontend/helpers');
const should = require('should');
const hbs = require('../../../frontend/services/themes/engine');
const configUtils = require('../../utils/configUtils');
const path = require('path');
const helpers = require('../../../frontend/helpers');
const runHelper = data => helpers.navigation.call({}, data);
const runHelperThunk = data => () => runHelper(data);

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{page_url}} helper', function () {

View File

@ -25,10 +25,10 @@ describe('{{pagination}} helper', function () {
it('should throw if pagination data is incorrect', function () {
var runHelper = function (data) {
return function () {
helpers.pagination.call(data);
};
}, expectedMessage = 'The {{pagination}} helper was used outside of a paginated context. See https://ghost.org/docs/api/handlebars-themes/helpers/pagination/.';
return function () {
helpers.pagination.call(data);
};
}, expectedMessage = 'The {{pagination}} helper was used outside of a paginated context. See https://ghost.org/docs/api/handlebars-themes/helpers/pagination/.';
runHelper('not an object').should.throwError(expectedMessage);
runHelper(function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{plural}} helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{post_class}} helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
var almostOneMinute =
@ -71,10 +71,10 @@ describe('{{reading_time}} helper', function () {
it('[success] adds time for feature image', function () {
var data = {
html: almostOneAndAHalfMinute,
title: 'Test',
slug: 'slug',
feature_image: '/content/images/someimage.jpg'
html: almostOneAndAHalfMinute,
title: 'Test',
slug: 'slug',
feature_image: '/content/images/someimage.jpg'
},
result = helpers.reading_time.call(data);
@ -85,10 +85,10 @@ describe('{{reading_time}} helper', function () {
it('[success] adds time for inline images', function () {
var data = {
html: almostOneAndAHalfMinute +
html: almostOneAndAHalfMinute +
'<img src="test.png">',
title: 'Test',
slug: 'slug'
title: 'Test',
slug: 'slug'
},
result = helpers.reading_time.call(data);

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{title}} Helper', function () {

View File

@ -1,6 +1,6 @@
var should = require('should'),
// Stuff we are testing
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{twitter_url}} helper', function () {

View File

@ -49,9 +49,9 @@ describe('Request', function () {
const requestMock = nock('http://some-website.com')
.get('/endpoint/')
.reply(301, 'Oops, got redirected',
{
location: 'http://someredirectedurl.com/files/'
});
{
location: 'http://someredirectedurl.com/files/'
});
const secondRequestMock = nock('http://someredirectedurl.com')
.get('/files/')
@ -133,7 +133,7 @@ describe('Request', function () {
const requestMock = nock('http://nofilehere.com')
.get('/files/test.txt')
.times(3) // 1 original request + 2 default retries
.times(3) // 1 original request + 2 default retries
.reply(500, {message: 'something awful happened', code: 'AWFUL_ERROR'});
return request(url, options).then(() => {

View File

@ -48,9 +48,9 @@ describe('Unit: models/settings', function () {
});
return models.Settings.edit({
key: 'description',
value: 'added value'
})
key: 'description',
value: 'added value'
})
.then(() => {
eventSpy.calledTwice.should.be.true();
eventSpy.firstCall.calledWith('settings.added').should.be.true();
@ -63,7 +63,7 @@ describe('Unit: models/settings', function () {
return [
function fetchEditQuery() {
query.response([{
id: 1, // NOTE: `id` imitates existing value for 'edit' event
id: 1, // NOTE: `id` imitates existing value for 'edit' event
key: 'description',
value: 'db value'
}]);
@ -72,9 +72,9 @@ describe('Unit: models/settings', function () {
});
return models.Settings.edit({
key: 'description',
value: 'edited value'
})
key: 'description',
value: 'edited value'
})
.then(() => {
eventSpy.calledTwice.should.be.true();
eventSpy.firstCall.calledWith('settings.edited').should.be.true();

View File

@ -59,8 +59,8 @@ describe('OAuth', function () {
sinon.stub(models.User, 'check')
.withArgs({email: 'username', password: 'password'}).returns(Promise.resolve({
id: 1
}));
id: 1
}));
sinon.stub(authUtils, 'createTokens')
.returns(Promise.resolve({
@ -160,8 +160,8 @@ describe('OAuth', function () {
sinon.stub(models.User, 'check')
.withArgs({email: 'username', password: 'password'}).returns(new Promise.resolve({
id: 1
}));
id: 1
}));
sinon.stub(authUtils, 'createTokens')
.returns(new Promise.reject({
@ -201,12 +201,12 @@ describe('OAuth', function () {
sinon.stub(models.Refreshtoken, 'findOne')
.withArgs({token: 'token'}).returns(new Promise.resolve({
toJSON: function () {
return {
expires: Date.now() + 3600
};
}
}));
toJSON: function () {
return {
expires: Date.now() + 3600
};
}
}));
sinon.stub(authUtils, 'createTokens')
.returns(new Promise.resolve({
@ -270,12 +270,12 @@ describe('OAuth', function () {
sinon.stub(models.Refreshtoken, 'findOne')
.withArgs({token: 'token'}).returns(new Promise.resolve({
toJSON: function () {
return {
expires: Date.now() - 3600
};
}
}));
toJSON: function () {
return {
expires: Date.now() - 3600
};
}
}));
oAuth.generateAccessToken(req, res, function (err) {
err.errorType.should.eql('UnauthorizedError');
@ -297,12 +297,12 @@ describe('OAuth', function () {
sinon.stub(models.Refreshtoken, 'findOne')
.withArgs({token: 'token'}).returns(new Promise.resolve({
toJSON: function () {
return {
expires: Date.now() + 3600
};
}
}));
toJSON: function () {
return {
expires: Date.now() + 3600
};
}
}));
sinon.stub(authUtils, 'createTokens').callsFake(function () {
return Promise.reject(new Error('DB error'));

View File

@ -41,9 +41,9 @@ describe('Unit - services/routing/controllers/channel', function () {
sinon.stub(themeService, 'getActive').returns({
updateTemplateOptions: sinon.stub(),
config: function (key) {
key.should.eql('posts_per_page');
return postsPerPage;
}
key.should.eql('posts_per_page');
return postsPerPage;
}
});
sinon.stub(helpers, 'renderEntries').returns(renderStub);

View File

@ -42,9 +42,9 @@ describe('Unit - services/routing/controllers/collection', function () {
sinon.stub(themeService, 'getActive').returns({
updateTemplateOptions: sinon.stub(),
config: function (key) {
key.should.eql('posts_per_page');
return postsPerPage;
}
key.should.eql('posts_per_page');
return postsPerPage;
}
});
sinon.stub(helpers, 'renderEntries').returns(renderStub);

View File

@ -21,7 +21,7 @@ describe('RSS: Renderer', function () {
});
afterEach(function () {
sinon.restore();
sinon.restore();
});
it('calls the cache and attempts to render, even without data', function (done) {

View File

@ -24,10 +24,10 @@ describe('UNIT > Settings Service:', function () {
const settingsStubFile = {
routes: null,
collections: {
'/': {
permalink: '/{slug}/',
template: ['home', 'index']
}
'/': {
permalink: '/{slug}/',
template: ['home', 'index']
}
},
resources: {tag: '/tag/{slug}/', author: '/author/{slug}/'}
};
@ -84,10 +84,10 @@ describe('UNIT > Settings Service:', function () {
const settingsStubFile1 = {
routes: null,
collections: {
'/': {
permalink: '/{slug}/',
template: ['home', 'index']
}
'/': {
permalink: '/{slug}/',
template: ['home', 'index']
}
},
resources: {tag: '/tag/{slug}/', author: '/author/{slug}/'}
},

View File

@ -112,7 +112,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without trailing slash', function () {
try {
validate({
routes: {
@ -127,7 +127,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without leading slashe', function () {
try {
validate({
routes: {
@ -142,7 +142,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without leading slash with permalink', function () {
try {
validate({
collections: {
@ -159,7 +159,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without leading or trailing slashes with permalink', function () {
try {
validate({
collections: {
@ -176,7 +176,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without trailing slash with permalink', function () {
try {
validate({
collections: {
@ -193,7 +193,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without trailing slash in permalink', function () {
try {
validate({
collections: {
@ -210,7 +210,7 @@ describe('UNIT: services/settings/validate', function () {
throw new Error('should fail');
});
it('throws error without leading or trailing slashes', function () {
it('throws error without leading or trailing slashes in permalink', function () {
try {
validate({
collections: {

View File

@ -142,7 +142,7 @@ describe('Unit: services/url/Queue', function () {
});
common.logging.error.calledOnce.should.be.true();
queue.toNotify['nachos'].notified.length.should.eql(0);
queue.toNotify.nachos.notified.length.should.eql(0);
});
});

View File

@ -138,7 +138,7 @@ describe('XMLRPC', function () {
it('captures && logs XML errors from requests with newlines between tags', function (done) {
var testPost = _.clone(testUtils.DataGenerator.Content.posts[2]),
ping1 = nock('http://rpc.pingomatic.com').post('/').reply(200,
`<?xml version="1.0"?>
`<?xml version="1.0"?>
<methodResponse>
<params>
<param>
@ -179,7 +179,7 @@ describe('XMLRPC', function () {
it('captures && logs XML errors from requests without newlines between tags', function (done) {
var testPost = _.clone(testUtils.DataGenerator.Content.posts[2]),
ping1 = nock('http://rpc.pingomatic.com').post('/').reply(200,
(`<?xml version="1.0"?>
(`<?xml version="1.0"?>
<methodResponse>
<params>
<param>
@ -220,7 +220,7 @@ describe('XMLRPC', function () {
it('does not error with responses that have 0 as flerror value', function (done) {
var testPost = _.clone(testUtils.DataGenerator.Content.posts[2]),
ping1 = nock('http://rpc.pingomatic.com').post('/').reply(200,
`<?xml version="1.0"?>
`<?xml version="1.0"?>
<methodResponse>
<params>
<param>

View File

@ -4,7 +4,7 @@ const configUtils = require('../../../utils/configUtils');
const controller = require('../../../../server/web/admin/controller');
describe('Admin App', function () {
describe('controller', function () {
describe('controller', function () {
const req = {};
let res;
@ -41,5 +41,5 @@ describe('Admin App', function () {
sinon.match.hasNested('headers.X-Frame-Options')
).should.be.false();
});
});
});
});

View File

@ -1,5 +1,5 @@
var should = require('should'),
sinon = require('sinon'),
var should = require('should'),
sinon = require('sinon'),
versionMatch = require('../../../../../server/web/shared/middlewares/api/version-match');
describe('Version Mismatch', function () {

View File

@ -12,11 +12,11 @@ describe('Theme Handler', function () {
next = sinon.spy();
sinon.stub(themeService, 'getActive').callsFake(() => {
return {
engine() {
return 'v0.1';
}
};
return {
engine() {
return 'v0.1';
}
};
});
});

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
module.exports = {
answer: 42
};

View File

@ -195,9 +195,9 @@ fixtures = {
let tags = results[1].toJSON();
const injectionTagId = _.chain(tags)
.filter({name: 'injection'})
.map('id')
.value()[0];
.filter({name: 'injection'})
.map('id')
.value()[0];
if (max > posts.length) {
throw new Error('Trying to add more posts_tags than the number of posts.');
@ -291,7 +291,7 @@ fixtures = {
},
createUsersWithoutOwner: function createUsersWithoutOwner() {
var usersWithoutOwner = _.cloneDeep(DataGenerator.forKnex.users.slice(1));
var usersWithoutOwner = _.cloneDeep(DataGenerator.forKnex.users.slice(1));
return Promise.map(usersWithoutOwner, function (user) {
let userRolesRelations = _.filter(DataGenerator.forKnex.roles_users, {user_id: user.id});
@ -317,7 +317,7 @@ fixtures = {
createExtraUsers: function createExtraUsers() {
// grab 3 more users
var extraUsers = _.cloneDeep(DataGenerator.Content.users.slice(2, 6));
var extraUsers = _.cloneDeep(DataGenerator.Content.users.slice(2, 6));
extraUsers = _.map(extraUsers, function (user) {
return DataGenerator.forKnex.createUser(_.extend({}, user, {
id: ObjectId.generate(),
@ -338,7 +338,7 @@ fixtures = {
DataGenerator.Content.extraUsers = extraUsers;
return Promise.map(extraUsers, function (user) {
user.roles = roles[user.id];
user.roles = roles[user.id];
return models.User.add(user, module.exports.context.internal);
});
},
@ -401,7 +401,7 @@ fixtures = {
},
permissionsFor: function permissionsFor(obj) {
var permsToInsert = _.cloneDeep(fixtureUtils.findModelFixtures('Permission', {object_type: obj}).entries),
var permsToInsert = _.cloneDeep(fixtureUtils.findModelFixtures('Permission', {object_type: obj}).entries),
permsRolesToInsert = fixtureUtils.findPermissionRelationsForObject(obj).entries,
actions = [],
permissionsRoles = {},

View File

@ -130,7 +130,7 @@
},
"devDependencies": {
"eslint": "6.1.0",
"eslint-plugin-ghost": "0.4.0",
"eslint-plugin-ghost": "0.5.0",
"grunt": "1.0.4",
"grunt-bg-shell": "2.3.3",
"grunt-cli": "1.3.2",

View File

@ -2243,14 +2243,22 @@ eslint-plugin-ember@^6.7.0:
ember-rfc176-data "^0.3.9"
snake-case "^2.1.0"
eslint-plugin-ghost@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ghost/-/eslint-plugin-ghost-0.4.0.tgz#40076b79e0446f51daecfebd85bf400986aead7a"
integrity sha512-BoU/pc4okZAMiZz6M/bz5ru8dYuVJvlPbJ4bXwXbLIykzLVlIQskpEs/bokR8gUZUa5b/VW4HfY4WVWZ0it22A==
eslint-plugin-ghost@0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ghost/-/eslint-plugin-ghost-0.5.0.tgz#f5ee691409b8be4ad2951bc7711380f6df029ca3"
integrity sha512-fI3kjj81IqlrZ3TwBUg6KqJciKyAtpYBlOxVxg+YiGxXMVqIivpAHVwdh4LEmym2TdFSX5sNhFkW5hzEVqZesQ==
dependencies:
eslint-plugin-ember "^6.7.0"
eslint-plugin-mocha "^6.0.0"
eslint-plugin-sort-imports-es6-autofix "0.4.0"
eslint-plugin-mocha@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-6.0.0.tgz#0a2af057280962e9deab929361141865b2b8a761"
integrity sha512-Qgy1q64cTKqiHiYP3ZPAcMlEoPejeM7GLKDs2pvYG/fXbVDYDJw7ELlHlbn3147SL9+cPSqat7uCCbbNmVpc1g==
dependencies:
ramda "^0.26.1"
eslint-plugin-sort-imports-es6-autofix@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-sort-imports-es6-autofix/-/eslint-plugin-sort-imports-es6-autofix-0.4.0.tgz#3bcc87f7cc8596dea48ca3eb12b0103dfc21c98c"
@ -6817,6 +6825,11 @@ rai@~0.1.11:
resolved "https://registry.yarnpkg.com/rai/-/rai-0.1.12.tgz#8ccfd014d0f9608630dd73c19b8e4b057754a6a6"
integrity sha1-jM/QFND5YIYw3XPBm45LBXdUpqY=
ramda@^0.26.1:
version "0.26.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06"
integrity sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==
random-bytes@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b"