From 95fa815eb3d56e1ebc009f8793a41f0debbd7715 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 11 Oct 2019 13:41:36 +0700 Subject: [PATCH] Improved settings model tests no-issue This makes them way less brittle and reliant on correctly indexing an array --- core/test/unit/models/settings_spec.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/test/unit/models/settings_spec.js b/core/test/unit/models/settings_spec.js index d1f751027b..05b7d3e581 100644 --- a/core/test/unit/models/settings_spec.js +++ b/core/test/unit/models/settings_spec.js @@ -114,16 +114,14 @@ describe('Unit: models/settings', function () { return models.Settings.populateDefaults() .then(() => { eventSpy.callCount.should.equal(82); + const eventsEmitted = eventSpy.args.map(args => args[0]); + const checkEventEmitted = event => should.ok(eventsEmitted.includes(event), `${event} event should be emitted`); - eventSpy.args[1][0].should.equal('settings.db_hash.added'); - eventSpy.args[1][1].attributes.type.should.equal('core'); + checkEventEmitted('settings.db_hash.added'); + checkEventEmitted('settings.description.added'); - eventSpy.args[13][0].should.equal('settings.description.added'); - eventSpy.args[13][1].attributes.type.should.equal('blog'); - eventSpy.args[13][1].attributes.value.should.equal('The professional publishing platform'); - - eventSpy.args[77][0].should.equal('settings.default_content_visibility.added'); - eventSpy.args[79][0].should.equal('settings.members_subscription_settings.added'); + checkEventEmitted('settings.default_content_visibility.added'); + checkEventEmitted('settings.members_subscription_settings.added'); }); });