2020-05-25 11:49:38 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
2020-04-29 18:44:27 +03:00
|
|
|
const sinon = require('sinon');
|
|
|
|
const Promise = require('bluebird');
|
2021-10-06 12:52:46 +03:00
|
|
|
const markdownToMobiledoc = require('../../../utils/fixtures/data-generator').markdownToMobiledoc;
|
|
|
|
const next_post = require('../../../../core/frontend/helpers/prev_post');
|
|
|
|
const api = require('../../../../core/server/api');
|
2015-03-21 15:14:51 +03:00
|
|
|
|
|
|
|
describe('{{next_post}} helper', function () {
|
2021-07-07 17:44:21 +03:00
|
|
|
const apiVersion = 'canary';
|
2018-10-17 10:23:59 +03:00
|
|
|
let locals;
|
2020-04-29 18:44:27 +03:00
|
|
|
let browsePostsStub;
|
2015-08-09 22:30:04 +03:00
|
|
|
|
2018-10-17 10:23:59 +03:00
|
|
|
beforeEach(function () {
|
2019-01-21 13:48:18 +03:00
|
|
|
locals = {
|
|
|
|
root: {
|
|
|
|
_locals: {
|
2021-07-07 17:44:21 +03:00
|
|
|
apiVersion: apiVersion
|
2019-01-21 13:48:18 +03:00
|
|
|
},
|
|
|
|
context: ['post']
|
|
|
|
}
|
|
|
|
};
|
2019-09-11 20:10:10 +03:00
|
|
|
|
|
|
|
sinon.stub(api, 'postsPublic').get(() => {
|
|
|
|
return {
|
|
|
|
browse: browsePostsStub
|
|
|
|
};
|
|
|
|
});
|
2018-10-17 10:23:59 +03:00
|
|
|
});
|
|
|
|
|
2015-08-09 22:30:04 +03:00
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2015-08-09 22:30:04 +03:00
|
|
|
});
|
|
|
|
|
2015-03-21 15:14:51 +03:00
|
|
|
describe('with valid post data - ', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-13 17:44:39 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
2015-03-21 15:14:51 +03:00
|
|
|
return Promise.resolve({
|
2017-10-13 17:44:39 +03:00
|
|
|
posts: [{slug: '/next/', title: 'post 3'}]
|
2015-03-21 15:14:51 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'if\' template with next post data', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
2017-10-13 17:44:39 +03:00
|
|
|
published_at: new Date(0),
|
2017-08-27 19:00:32 +03:00
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
2017-10-13 17:44:39 +03:00
|
|
|
|
2017-08-27 19:00:32 +03:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
2015-03-21 15:14:51 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for valid post with no next post', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-13 17:44:39 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
2019-09-11 20:10:10 +03:00
|
|
|
return Promise.resolve({
|
|
|
|
posts: []
|
|
|
|
});
|
2015-03-21 15:14:51 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'else\' template', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
2017-10-13 17:44:39 +03:00
|
|
|
status: 'published',
|
2017-08-27 19:00:32 +03:00
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
2017-10-13 17:44:39 +03:00
|
|
|
published_at: new Date(0),
|
2017-08-27 19:00:32 +03:00
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.called.should.be.true();
|
|
|
|
|
|
|
|
inverse.firstCall.args.should.have.lengthOf(2);
|
|
|
|
inverse.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
inverse.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
2015-03-21 15:14:51 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for invalid post data', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-13 17:44:39 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
2015-03-21 15:14:51 +03:00
|
|
|
return Promise.resolve({});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'else\' template', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call({}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.called.should.be.true();
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.called.should.be.false();
|
2017-10-13 17:44:39 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for page', function () {
|
|
|
|
beforeEach(function () {
|
2019-01-21 13:48:18 +03:00
|
|
|
locals = {
|
|
|
|
root: {
|
|
|
|
_locals: {
|
2021-07-07 17:44:21 +03:00
|
|
|
apiVersion: apiVersion
|
2019-01-21 13:48:18 +03:00
|
|
|
},
|
|
|
|
context: ['page']
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-13 17:44:39 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
|
|
|
return Promise.resolve({posts: [{slug: '/previous/', title: 'post 1'}]});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'else\' template', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2017-10-13 17:44:39 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-10-13 17:44:39 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
url: '/current/',
|
|
|
|
page: true
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.called.should.be.true();
|
|
|
|
|
2017-08-27 19:00:32 +03:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
2015-03-21 15:14:51 +03:00
|
|
|
});
|
|
|
|
});
|
2015-04-16 22:40:32 +03:00
|
|
|
|
|
|
|
describe('for unpublished post', function () {
|
|
|
|
beforeEach(function () {
|
2019-01-21 13:48:18 +03:00
|
|
|
locals = {
|
|
|
|
root: {
|
|
|
|
_locals: {
|
2021-07-07 17:44:21 +03:00
|
|
|
apiVersion: apiVersion
|
2019-01-21 13:48:18 +03:00
|
|
|
},
|
|
|
|
context: ['preview', 'post']
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-13 17:44:39 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
|
|
|
return Promise.resolve({posts: [{slug: '/next/', title: 'post 3'}]});
|
2015-04-16 22:40:32 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'else\' template', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-04-16 22:40:32 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'draft',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
created_at: new Date(0),
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
2017-03-21 11:24:11 +03:00
|
|
|
.then(function () {
|
2017-08-27 19:00:32 +03:00
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.called.should.be.true();
|
2017-10-13 17:44:39 +03:00
|
|
|
|
2017-03-21 11:24:11 +03:00
|
|
|
done();
|
2017-08-27 19:00:32 +03:00
|
|
|
})
|
2017-10-18 20:12:20 +03:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with "in" option', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function (options) {
|
2017-10-18 20:12:20 +03:00
|
|
|
if (options.filter.indexOf('published_at:>') > -1) {
|
|
|
|
return Promise.resolve({
|
|
|
|
posts: [{slug: '/next/', title: 'post 1'}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'if\' template with prev post data with primary_tag set', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'primary_tag'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-10-18 20:12:20 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
primary_tag: {slug: 'test'},
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
|
|
|
browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_tag:test/);
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
2018-03-27 17:16:15 +03:00
|
|
|
it('shows \'if\' template with prev post data with primary_author set', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'primary_author'}};
|
2018-03-27 17:16:15 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2018-03-27 17:16:15 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
primary_author: {slug: 'hans'},
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
|
|
|
browsePostsStub.firstCall.args[0].filter.should.match(/\+primary_author:hans/);
|
2018-03-27 17:16:15 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
2017-10-18 20:12:20 +03:00
|
|
|
it('shows \'if\' template with prev post data with author set', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'author'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-10-18 20:12:20 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
author: {slug: 'author-name'},
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
|
|
|
browsePostsStub.firstCall.args[0].filter.should.match(/\+author:author-name/);
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'if\' template with prev post data & ignores in author if author isnt present', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'author'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-10-18 20:12:20 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
|
|
|
browsePostsStub.firstCall.args[0].filter.should.not.match(/\+author:/);
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows \'if\' template with prev post data & ignores unknown in value', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'magic'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-10-18 20:12:20 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
|
|
|
published_at: new Date(0),
|
|
|
|
author: {slug: 'author-name'},
|
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.calledOnce.should.be.true();
|
|
|
|
inverse.calledOnce.should.be.false();
|
|
|
|
|
|
|
|
fn.firstCall.args.should.have.lengthOf(2);
|
|
|
|
fn.firstCall.args[0].should.have.properties('slug', 'title');
|
|
|
|
fn.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub.calledOnce.should.be.true();
|
|
|
|
browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags');
|
|
|
|
browsePostsStub.firstCall.args[0].filter.should.not.match(/\+magic/);
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
2017-08-27 19:00:32 +03:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('general error handling', function () {
|
|
|
|
beforeEach(function () {
|
2019-09-11 20:10:10 +03:00
|
|
|
browsePostsStub = sinon.stub().callsFake(function () {
|
2020-05-25 11:49:38 +03:00
|
|
|
return Promise.reject(new errors.NotFoundError({message: 'Something wasn\'t found'}));
|
2015-04-16 22:40:32 +03:00
|
|
|
});
|
|
|
|
});
|
2017-08-27 19:00:32 +03:00
|
|
|
|
|
|
|
it('should handle error from the API', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2017-08-27 19:00:32 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call({
|
|
|
|
html: 'content',
|
|
|
|
status: 'published',
|
|
|
|
mobiledoc: markdownToMobiledoc('ff'),
|
|
|
|
title: 'post2',
|
|
|
|
slug: 'current',
|
2017-10-13 17:44:39 +03:00
|
|
|
published_at: new Date(0),
|
2017-08-27 19:00:32 +03:00
|
|
|
url: '/current/'
|
|
|
|
}, optionsData)
|
|
|
|
.then(function () {
|
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.calledOnce.should.be.true();
|
|
|
|
|
|
|
|
inverse.firstCall.args[1].should.be.an.Object().and.have.property('data');
|
|
|
|
inverse.firstCall.args[1].data.should.be.an.Object().and.have.property('error');
|
|
|
|
inverse.firstCall.args[1].data.error.should.match(/^Something wasn't found/);
|
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show warning for call without any options', function (done) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const fn = sinon.spy();
|
|
|
|
const inverse = sinon.spy();
|
|
|
|
const optionsData = {name: 'next_post', data: {root: {}}};
|
2017-08-27 19:00:32 +03:00
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
next_post
|
2017-08-27 19:00:32 +03:00
|
|
|
.call(
|
|
|
|
{},
|
|
|
|
optionsData
|
|
|
|
)
|
|
|
|
.then(function () {
|
|
|
|
fn.called.should.be.false();
|
|
|
|
inverse.called.should.be.false();
|
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
2015-04-16 22:40:32 +03:00
|
|
|
});
|
2015-03-21 15:14:51 +03:00
|
|
|
});
|