Renamed test function to fix eslint warning

no issue

- teardown is an internal Mocha hook, and eslint would complain about it
  being used outside a test
- our use of teardown is actually a custom function, so it's better to
  rename the function across the board
This commit is contained in:
Daniel Lockyer 2020-02-24 20:51:09 +00:00
parent 119c5359ec
commit 92a0e6abec
11 changed files with 41 additions and 41 deletions

View File

@ -8,8 +8,8 @@ var should = require('should'),
ghostVersion = require('../../../server/lib/ghost-version');
describe('Exporter', function () {
before(testUtils.teardown);
afterEach(testUtils.teardown);
before(testUtils.teardownDb);
afterEach(testUtils.teardownDb);
afterEach(function () {
sinon.restore();
});

View File

@ -112,13 +112,13 @@ const exportedLegacyBody = () => {
// Tests in here do an import for each test
describe('Integration: Importer', function () {
before(testUtils.teardown);
before(testUtils.teardownDb);
beforeEach(function () {
sinon.stub(importer, 'cleanUp');
});
afterEach(testUtils.teardown);
afterEach(testUtils.teardownDb);
afterEach(function () {
sinon.restore();
});
@ -1171,7 +1171,7 @@ describe('Integration: Importer', function () {
});
describe('Existing database', function () {
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('users:roles', 'posts', 'settings'));
it('import multiple users, tags, posts', function () {
@ -1279,7 +1279,7 @@ describe('Integration: Importer', function () {
});
describe('1.0', function () {
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('roles', 'owner', 'settings'));
it('ensure amp field get\'s respected', function () {
@ -1514,7 +1514,7 @@ describe('1.0', function () {
});
describe('LTS', function () {
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('roles', 'owner', 'settings'));
it('disallows importing LTS imports', function () {

View File

@ -6,8 +6,8 @@ var should = require('should'),
Models = require('../../../server/models');
describe('Database Migration (special functions)', function () {
before(testUtils.teardown);
afterEach(testUtils.teardown);
before(testUtils.teardownDb);
afterEach(testUtils.teardownDb);
afterEach(function () {
sinon.restore();
});

View File

@ -20,7 +20,7 @@ describe('Models: listeners', function () {
publishedAtFutureMoment3: moment().add(10, 'hours').startOf('hour')
};
before(testUtils.teardown);
before(testUtils.teardownDb);
beforeEach(testUtils.setup('owner', 'settings'));
@ -36,7 +36,7 @@ describe('Models: listeners', function () {
common.events.on.restore();
sinon.restore();
scope.posts = [];
return testUtils.teardown();
return testUtils.teardownDb();
});
describe('on timezone changed', function () {

View File

@ -25,9 +25,9 @@ var should = require('should'),
describe('Post Model', function () {
var eventsTriggered = {};
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.stopGhost);
after(testUtils.teardown);
after(testUtils.teardownDb);
before(testUtils.setup('users:roles'));
@ -1543,10 +1543,10 @@ describe('Post Model', function () {
});
describe('Multiauthor Posts', function () {
before(testUtils.teardown);
before(testUtils.teardownDb);
after(function () {
return testUtils.teardown()
return testUtils.teardownDb()
.then(function () {
return testUtils.setup('users:roles')();
});

View File

@ -14,8 +14,8 @@ var should = require('should'),
describe('User Model', function run() {
var eventsTriggered = {};
before(testUtils.teardown);
afterEach(testUtils.teardown);
before(testUtils.teardownDb);
afterEach(testUtils.teardownDb);
afterEach(function () {
sinon.restore();
});

View File

@ -20,9 +20,9 @@ describe('Integration: services/url/UrlService', function () {
});
});
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
after(testUtils.teardown);
after(testUtils.teardownDb);
after(function () {
sinon.restore();
@ -205,7 +205,7 @@ describe('Integration: services/url/UrlService', function () {
describe('functional: extended/modified routing set', function () {
let router1, router2, router3, router4, router5;
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
before(function () {

View File

@ -95,7 +95,7 @@ describe('Dynamic Routing', function () {
});
describe('RSS', function () {
before(testUtils.teardown);
before(testUtils.teardownDb);
before(function (done) {
testUtils.initData().then(function () {
@ -105,7 +105,7 @@ describe('Dynamic Routing', function () {
});
});
after(testUtils.teardown);
after(testUtils.teardownDb);
it('should 301 redirect with CC=1year without slash', function (done) {
request.get('/rss')
@ -186,7 +186,7 @@ describe('Dynamic Routing', function () {
}).catch(done);
});
after(testUtils.teardown);
after(testUtils.teardownDb);
it('should return HTML for valid route', function (done) {
request.get('/tag/getting-started/')
@ -326,7 +326,7 @@ describe('Dynamic Routing', function () {
// Inserting more posts takes a bit longer
this.timeout(20000);
before(testUtils.teardown);
before(testUtils.teardownDb);
// Add enough posts to trigger pages
before(function (done) {
@ -341,7 +341,7 @@ describe('Dynamic Routing', function () {
}).catch(done);
});
after(testUtils.teardown);
after(testUtils.teardownDb);
it('should redirect without slash', function (done) {
request.get('/tag/injection/page/2')
@ -459,7 +459,7 @@ describe('Dynamic Routing', function () {
}).catch(done);
});
after(testUtils.teardown);
after(testUtils.teardownDb);
it('should 404 for /author/ route', function (done) {
request.get('/author/')
@ -621,7 +621,7 @@ describe('Dynamic Routing', function () {
}).catch(done);
});
after(testUtils.teardown);
after(testUtils.teardownDb);
it('should redirect without slash', function (done) {
request.get('/author/ghost-owner/page/2')
@ -703,7 +703,7 @@ describe('Dynamic Routing', function () {
}).catch(done);
});
after(testUtils.teardown);
after(testUtils.teardownDb);
after(function () {
return ghostServer.stop();
});

View File

@ -14,7 +14,7 @@ describe('Integration - Web - Site', function () {
let app;
before(testUtils.integrationTesting.urlService.resetGenerators);
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
describe('v2', function () {
@ -1223,7 +1223,7 @@ describe('Integration - Web - Site', function () {
describe('extended routes.yaml: routes', function () {
describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators);
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
before(function () {
@ -2923,7 +2923,7 @@ describe('Integration - Web - Site', function () {
describe('extended routes.yaml: routes', function () {
describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators);
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
before(function () {
@ -4623,7 +4623,7 @@ describe('Integration - Web - Site', function () {
describe('extended routes.yaml: routes', function () {
describe('channels', function () {
before(testUtils.integrationTesting.urlService.resetGenerators);
before(testUtils.teardown);
before(testUtils.teardownDb);
before(testUtils.setup('users:roles', 'posts'));
before(function () {

View File

@ -24,14 +24,14 @@ describe('Update Check', function () {
configUtils.restore();
});
after(testUtils.teardown);
after(testUtils.teardownDb);
describe('fn: updateCheck', function () {
var updateCheckRequestSpy,
updateCheckResponseSpy,
updateCheckErrorSpy;
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('roles', 'owner'));
beforeEach(function () {
@ -117,7 +117,7 @@ describe('Update Check', function () {
configUtils.restore();
});
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('roles', 'owner', 'settings', 'posts', 'perms:setting', 'perms:user', 'perms:init'));
it('should report the correct data', function (done) {
@ -155,7 +155,7 @@ describe('Update Check', function () {
updateCheck.__set__('ghostVersion.original', currentVersionOrig);
});
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('settings', 'roles', 'owner', 'perms:setting', 'perms:notification', 'perms:user', 'perms:init'));
beforeEach(function () {
@ -321,7 +321,7 @@ describe('Update Check', function () {
});
describe('fn: updateCheckResponse', function () {
beforeEach(testUtils.teardown);
beforeEach(testUtils.teardownDb);
beforeEach(testUtils.setup('roles', 'settings', 'perms:setting', 'perms:init'));
it('receives a notifications with messages', function (done) {

View File

@ -43,7 +43,7 @@ var Promise = require('bluebird'),
mockNotExistingModule,
unmockNotExistingModule,
teardown,
teardownDb,
setup,
truncate,
createUser,
@ -738,7 +738,7 @@ createPost = function createPost(options) {
* Has to run in a transaction for MySQL, otherwise the foreign key check does not work.
* Sqlite3 has no truncate command.
*/
teardown = function teardown() {
teardownDb = function teardownDb() {
debug('Database teardown');
urlService.softReset();
@ -855,7 +855,7 @@ startGhost = function startGhost(options) {
// truncate database and re-run fixtures
// we have to ensure that some components in Ghost are reloaded
if (ghostServer && ghostServer.httpServer && !options.forceStart) {
return teardown()
return teardownDb()
.then(function () {
return knexMigrator.init({only: 2});
})
@ -1101,7 +1101,7 @@ module.exports = {
}
}
},
teardown: teardown,
teardownDb: teardownDb,
truncate: truncate,
setup: setup,
createUser: createUser,