mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed regression tests for Tags APIs
refs #12167 - The reason for failing tests was https://github.com/TryGhost/Ghost/issues/6104 . As we already test for ordering elsewhere, didn't include more "if/else" logic in tests just for the sake of passing. Refactored them to be order-independent instead
This commit is contained in:
parent
8cf9dc05e3
commit
0f81e5e84a
3 changed files with 24 additions and 18 deletions
|
@ -1,5 +1,6 @@
|
|||
const should = require('should');
|
||||
const supertest = require('supertest');
|
||||
const _ = require('lodash');
|
||||
const localUtils = require('./utils');
|
||||
const testUtils = require('../../../../utils');
|
||||
const configUtils = require('../../../../utils/configUtils');
|
||||
|
@ -37,9 +38,9 @@ describe('api/canary/content/tags', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can request all tags with count.posts field and custom order', function () {
|
||||
it('Can request all tags with count.posts field', function () {
|
||||
return request
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts&order=name%20DESC`))
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts`))
|
||||
.set('Origin', testUtils.API.getURL())
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
|
@ -60,11 +61,12 @@ describe('api/canary/content/tags', function () {
|
|||
jsonResponse.meta.pagination.should.have.property('next', 2);
|
||||
jsonResponse.meta.pagination.should.have.property('prev', null);
|
||||
|
||||
jsonResponse.tags[0].url.should.eql(`${config.get('url')}/tag/kitchen-sink/`);
|
||||
jsonResponse.tags[1].url.should.eql(`${config.get('url')}/tag/getting-started/`);
|
||||
|
||||
should.exist(jsonResponse.tags[0].count.posts);
|
||||
jsonResponse.tags[0].count.posts.should.equal(2);
|
||||
// Each tag should have the correct count
|
||||
_.find(jsonResponse.tags, {name: 'Getting Started'}).count.posts.should.eql(7);
|
||||
_.find(jsonResponse.tags, {name: 'kitchen sink'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'bacon'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'chorizo'}).count.posts.should.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const should = require('should');
|
||||
const supertest = require('supertest');
|
||||
const _ = require('lodash');
|
||||
const localUtils = require('./utils');
|
||||
const testUtils = require('../../../../utils');
|
||||
const configUtils = require('../../../../utils/configUtils');
|
||||
|
@ -37,9 +38,9 @@ describe('api/v2/content/tags', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can request all tags with count.posts field and custom order', function () {
|
||||
it('Can request all tags with count.posts field', function () {
|
||||
return request
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts&order=name%20DESC`))
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts`))
|
||||
.set('Origin', testUtils.API.getURL())
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
|
@ -60,11 +61,12 @@ describe('api/v2/content/tags', function () {
|
|||
jsonResponse.meta.pagination.should.have.property('next', 2);
|
||||
jsonResponse.meta.pagination.should.have.property('prev', null);
|
||||
|
||||
jsonResponse.tags[0].url.should.eql(`${config.get('url')}/tag/kitchen-sink/`);
|
||||
jsonResponse.tags[1].url.should.eql(`${config.get('url')}/tag/getting-started/`);
|
||||
|
||||
should.exist(jsonResponse.tags[0].count.posts);
|
||||
jsonResponse.tags[0].count.posts.should.equal(2);
|
||||
// Each tag should have the correct count
|
||||
_.find(jsonResponse.tags, {name: 'Getting Started'}).count.posts.should.eql(7);
|
||||
_.find(jsonResponse.tags, {name: 'kitchen sink'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'bacon'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'chorizo'}).count.posts.should.eql(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const should = require('should');
|
||||
const supertest = require('supertest');
|
||||
const _ = require('lodash');
|
||||
const localUtils = require('./utils');
|
||||
const testUtils = require('../../../../utils');
|
||||
const configUtils = require('../../../../utils/configUtils');
|
||||
|
@ -37,9 +38,9 @@ describe('api/v3/content/tags', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can request all tags with count.posts field and custom order', function () {
|
||||
it('Can request all tags with count.posts field', function () {
|
||||
return request
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts&order=name%20DESC`))
|
||||
.get(localUtils.API.getApiQuery(`tags/?key=${validKey}&include=count.posts`))
|
||||
.set('Origin', testUtils.API.getURL())
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
|
@ -60,11 +61,12 @@ describe('api/v3/content/tags', function () {
|
|||
jsonResponse.meta.pagination.should.have.property('next', 2);
|
||||
jsonResponse.meta.pagination.should.have.property('prev', null);
|
||||
|
||||
jsonResponse.tags[0].url.should.eql(`${config.get('url')}/tag/kitchen-sink/`);
|
||||
jsonResponse.tags[1].url.should.eql(`${config.get('url')}/tag/getting-started/`);
|
||||
|
||||
should.exist(jsonResponse.tags[0].count.posts);
|
||||
jsonResponse.tags[0].count.posts.should.equal(2);
|
||||
// Each tag should have the correct count
|
||||
_.find(jsonResponse.tags, {name: 'Getting Started'}).count.posts.should.eql(7);
|
||||
_.find(jsonResponse.tags, {name: 'kitchen sink'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'bacon'}).count.posts.should.eql(2);
|
||||
_.find(jsonResponse.tags, {name: 'chorizo'}).count.posts.should.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue