Prevent error logging in Urls tests from being output

refs: https://github.com/TryGhost/Toolbox/issues/389
This commit is contained in:
Sam Lord 2023-02-28 11:13:57 +00:00
parent 6512fc770d
commit 579ecd5b0b

View File

@ -2,10 +2,12 @@ const should = require('should');
const sinon = require('sinon');
const events = require('../../../../../core/server/lib/common/events');
const Urls = require('../../../../../core/server/services/url/Urls');
const logging = require('@tryghost/logging');
describe('Unit: services/url/Urls', function () {
let urls;
let eventsToRemember;
let loggingStub;
beforeEach(function () {
urls = new Urls();
@ -70,6 +72,7 @@ describe('Unit: services/url/Urls', function () {
urls.getByResourceId('object-id-x').resource.data.slug.should.eql('a');
loggingStub = sinon.stub(logging, 'error');
// add duplicate
urls.add({
url: '/test/',
@ -81,6 +84,8 @@ describe('Unit: services/url/Urls', function () {
},
generatorId: 1
});
loggingStub.calledOnce.should.eql(true);
loggingStub.firstCall.firstArg.should.have.property('code').eql('URLSERVICE_RESOURCE_DUPLICATE');
should.exist(eventsToRemember['url.added']);