2018-06-02 22:48:23 +03:00
|
|
|
var should = require('should'),
|
2017-03-21 11:24:11 +03:00
|
|
|
sinon = require('sinon'),
|
|
|
|
Promise = require('bluebird'),
|
2017-05-31 17:46:29 +03:00
|
|
|
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc,
|
2017-10-13 17:44:39 +03:00
|
|
|
|
2020-03-30 18:26:47 +03:00
|
|
|
helpers = require('../../../core/frontend/helpers'),
|
|
|
|
api = require('../../../core/server/api'),
|
|
|
|
common = require('../../../core/server/lib/common');
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2020-04-10 15:08:41 +03:00
|
|
|
// These helpers are the same, their name just changes
|
|
|
|
helpers.next_post = helpers.prev_post;
|
|
|
|
|
2015-03-21 15:14:51 +03:00
|
|
|
describe('{{next_post}} helper', function () {
|
2018-10-17 10:23:59 +03:00
|
|
|
let locals;
|
2019-09-11 20:10:10 +03:00
|
|
|
var 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: {
|
2019-09-11 20:10:10 +03:00
|
|
|
apiVersion: 'v2'
|
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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-03-21 15:14:51 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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: {
|
2019-09-11 20:10:10 +03:00
|
|
|
apiVersion: 'v2'
|
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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2017-10-13 17:44:39 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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: {
|
2019-09-11 20:10:10 +03:00
|
|
|
apiVersion: 'v2'
|
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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2015-04-16 22:40:32 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'primary_tag'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'primary_author'}};
|
2018-03-27 17:16:15 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'author'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'author'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse, hash: {in: 'magic'}};
|
2017-10-18 20:12:20 +03:00
|
|
|
|
|
|
|
helpers.next_post
|
|
|
|
.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 () {
|
2017-12-12 00:47:46 +03:00
|
|
|
return Promise.reject(new common.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2018-10-17 10:23:59 +03:00
|
|
|
optionsData = {name: 'next_post', data: locals, fn: fn, inverse: inverse};
|
2017-08-27 19:00:32 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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) {
|
|
|
|
var fn = sinon.spy(),
|
|
|
|
inverse = sinon.spy(),
|
2019-01-21 13:48:18 +03:00
|
|
|
optionsData = {name: 'next_post', data: {root: {}}};
|
2017-08-27 19:00:32 +03:00
|
|
|
|
2017-10-13 17:44:39 +03:00
|
|
|
helpers.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
|
|
|
});
|