diff --git a/loader.js b/loader.js index eea0bf9c8a..982d6374e8 100644 --- a/loader.js +++ b/loader.js @@ -87,22 +87,22 @@ Loader.addWorkerEvents = function (worker) { worker.on('message', function (message) { if (message && typeof message === 'object' && message.action) { switch (message.action) { - case 'restart': - console.log('[cluster] Restarting...'); - Loader.restart(); - break; - case 'pubsub': - workers.forEach(function (w) { - w.send(message); - }); - break; - case 'socket.io': - workers.forEach(function (w) { - if (w !== worker) { + case 'restart': + console.log('[cluster] Restarting...'); + Loader.restart(); + break; + case 'pubsub': + workers.forEach(function (w) { w.send(message); - } - }); - break; + }); + break; + case 'socket.io': + workers.forEach(function (w) { + if (w !== worker) { + w.send(message); + } + }); + break; } } }); diff --git a/test/api.js b/test/api.js index fa88a5b990..92bdbe7358 100644 --- a/test/api.js +++ b/test/api.js @@ -120,35 +120,35 @@ describe('Read API', async () => { assert(response[prop] !== null, '"' + prop + '" was null, but schema does not specify it to be a nullable property (path: ' + path + ', context: ' + context + ')'); switch (schema[prop].type) { - case 'string': - assert.strictEqual(typeof response[prop], 'string', '"' + prop + '" was expected to be a string, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); - break; - case 'boolean': - assert.strictEqual(typeof response[prop], 'boolean', '"' + prop + '" was expected to be a boolean, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); - break; - case 'object': - assert.strictEqual(typeof response[prop], 'object', '"' + prop + '" was expected to be an object, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); - compare(schema[prop], response[prop], context ? [context, prop].join('.') : prop); - break; - case 'array': - assert.strictEqual(Array.isArray(response[prop]), true, '"' + prop + '" was expected to be an array, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); - - if (schema[prop].items) { + case 'string': + assert.strictEqual(typeof response[prop], 'string', '"' + prop + '" was expected to be a string, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); + break; + case 'boolean': + assert.strictEqual(typeof response[prop], 'boolean', '"' + prop + '" was expected to be a boolean, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); + break; + case 'object': + assert.strictEqual(typeof response[prop], 'object', '"' + prop + '" was expected to be an object, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); + compare(schema[prop], response[prop], context ? [context, prop].join('.') : prop); + break; + case 'array': + assert.strictEqual(Array.isArray(response[prop]), true, '"' + prop + '" was expected to be an array, but was ' + typeof response[prop] + ' instead (path: ' + path + ', context: ' + context + ')'); + + if (schema[prop].items) { // Ensure the array items have a schema defined - assert(schema[prop].items.type || schema[prop].items.allOf, '"' + prop + '" is defined to be an array, but its items have no schema defined (path: ' + path + ', context: ' + context + ')'); - - // Compare types - if (schema[prop].items.type === 'object' || Array.isArray(schema[prop].items.allOf)) { - response[prop].forEach((res) => { - compare(schema[prop].items, res, context ? [context, prop].join('.') : prop); - }); - } else if (response[prop].length) { // for now - response[prop].forEach((item) => { - assert.strictEqual(typeof item, schema[prop].items.type, '"' + prop + '" should have ' + schema[prop].items.type + ' items, but found ' + typeof items + ' instead (path: ' + path + ', context: ' + context + ')'); - }); + assert(schema[prop].items.type || schema[prop].items.allOf, '"' + prop + '" is defined to be an array, but its items have no schema defined (path: ' + path + ', context: ' + context + ')'); + + // Compare types + if (schema[prop].items.type === 'object' || Array.isArray(schema[prop].items.allOf)) { + response[prop].forEach((res) => { + compare(schema[prop].items, res, context ? [context, prop].join('.') : prop); + }); + } else if (response[prop].length) { // for now + response[prop].forEach((item) => { + assert.strictEqual(typeof item, schema[prop].items.type, '"' + prop + '" should have ' + schema[prop].items.type + ' items, but found ' + typeof items + ' instead (path: ' + path + ', context: ' + context + ')'); + }); + } } - } - break; + break; } } }); @@ -176,15 +176,15 @@ describe('Read API', async () => { assert(param.example !== null && param.example !== undefined, path + ' has parameters without examples'); switch (param.in) { - case 'path': - testPath = testPath.replace('{' + param.name + '}', param.example); - break; - case 'header': - headers[param.name] = param.example; - break; - case 'query': - qs[param.name] = param.example; - break; + case 'path': + testPath = testPath.replace('{' + param.name + '}', param.example); + break; + case 'header': + headers[param.name] = param.example; + break; + case 'query': + qs[param.name] = param.example; + break; } }); } diff --git a/test/flags.js b/test/flags.js index f34df831e9..2ecb189e49 100644 --- a/test/flags.js +++ b/test/flags.js @@ -293,13 +293,13 @@ describe('Flags', function () { history.forEach(function (change) { switch (change.attribute) { - case 'state': - assert.strictEqual('[[flags:state-wip]]', change.value); - break; + case 'state': + assert.strictEqual('[[flags:state-wip]]', change.value); + break; - case 'assignee': - assert.strictEqual(1, change.value); - break; + case 'assignee': + assert.strictEqual(1, change.value); + break; } });