mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +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);
|
||||
tracker = mockDb.getTracker();
|
||||
tracker.install();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
mockDb.unmock(knex);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
eventSpy = sinon.spy(events, 'emit');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
tracker.uninstall();
|
||||
mockDb.unmock(knex);
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
@ -63,15 +58,15 @@ describe('Unit: models/settings', function () {
|
||||
|
||||
it('emits edit events', function () {
|
||||
tracker.on('query', (query, step) => {
|
||||
return [
|
||||
function fetchEditQuery() {
|
||||
query.response([{
|
||||
if (query.method === 'select') {
|
||||
return query.response([{
|
||||
id: 1, // NOTE: `id` imitates existing value for 'edit' event
|
||||
key: 'description',
|
||||
value: 'db value'
|
||||
}]);
|
||||
}
|
||||
][step - 1]();
|
||||
|
||||
return query.response([{}]);
|
||||
});
|
||||
|
||||
return models.Settings.edit({
|
||||
|
Loading…
Reference in New Issue
Block a user