mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 15:29:19 +03:00
Fixed settings unit tests
refs e04f55cce3
- added `tracker.uninstall()` so that previously set up `tracker.on()` listeners are not called by later tests
- fixed `emits edit events` test which was not correctly mocking the select and update queries
This commit is contained in:
parent
62c72cb58b
commit
6504b0f6c3
@ -20,17 +20,12 @@ describe('Unit: models/settings', function () {
|
|||||||
mockDb.mock(knex);
|
mockDb.mock(knex);
|
||||||
tracker = mockDb.getTracker();
|
tracker = mockDb.getTracker();
|
||||||
tracker.install();
|
tracker.install();
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
mockDb.unmock(knex);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
eventSpy = sinon.spy(events, 'emit');
|
eventSpy = sinon.spy(events, 'emit');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
tracker.uninstall();
|
||||||
|
mockDb.unmock(knex);
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,15 +58,15 @@ describe('Unit: models/settings', function () {
|
|||||||
|
|
||||||
it('emits edit events', function () {
|
it('emits edit events', function () {
|
||||||
tracker.on('query', (query, step) => {
|
tracker.on('query', (query, step) => {
|
||||||
return [
|
if (query.method === 'select') {
|
||||||
function fetchEditQuery() {
|
return query.response([{
|
||||||
query.response([{
|
|
||||||
id: 1, // NOTE: `id` imitates existing value for 'edit' event
|
id: 1, // NOTE: `id` imitates existing value for 'edit' event
|
||||||
key: 'description',
|
key: 'description',
|
||||||
value: 'db value'
|
value: 'db value'
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
][step - 1]();
|
|
||||||
|
return query.response([{}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return models.Settings.edit({
|
return models.Settings.edit({
|
||||||
|
Loading…
Reference in New Issue
Block a user