From 961e776f1f1e390d45fbabc04c477cb9d4528fb5 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sat, 13 May 2023 17:36:30 -0400 Subject: [PATCH] fix lint --- .../fastboot-express-middleware/src/index.js | 6 +- .../test/helpers/fixture-path.js | 2 +- .../test/helpers/test-http-server.js | 2 +- .../test/middleware-test.js | 49 +++---- packages/fastboot/dev/memory-usage.js | 2 +- packages/fastboot/src/ember-app.js | 8 +- packages/fastboot/src/fastboot-request.js | 2 +- packages/fastboot/src/fastboot-schema.js | 6 +- packages/fastboot/src/index.js | 2 +- packages/fastboot/src/result.js | 18 +-- packages/fastboot/src/sandbox.js | 4 +- .../test/fastboot-dependencies-test.js | 8 +- .../fastboot/test/fastboot-headers-test.js | 30 ++--- packages/fastboot/test/fastboot-info-test.js | 16 +-- .../fastboot/test/fastboot-request-test.js | 28 ++-- .../fastboot/test/fastboot-response-test.js | 18 +-- .../fastboot/test/fastboot-shoebox-test.js | 20 +-- packages/fastboot/test/fastboot-test.js | 126 +++++++++--------- .../fastboot/test/get-package-name-test.js | 4 +- .../fastboot/test/html-entrypoint-test.js | 24 ++-- packages/fastboot/test/queue-test.js | 20 +-- packages/fastboot/test/result-test.js | 94 ++++++------- 22 files changed, 245 insertions(+), 244 deletions(-) diff --git a/packages/fastboot-express-middleware/src/index.js b/packages/fastboot-express-middleware/src/index.js index da3c04a71..05ad810a7 100644 --- a/packages/fastboot-express-middleware/src/index.js +++ b/packages/fastboot-express-middleware/src/index.js @@ -13,7 +13,7 @@ function fastbootExpressMiddleware(distPath, options) { opts = opts || {}; - let log = opts.log !== false ? _log : function () {}; + let log = opts.log !== false ? _log : function() {}; let fastboot = opts.fastboot; @@ -25,7 +25,7 @@ function fastbootExpressMiddleware(distPath, options) { }); } - return async function (req, res, next) { + return async function(req, res, next) { let path = req.url; try { @@ -53,7 +53,7 @@ function fastbootExpressMiddleware(distPath, options) { } else if (result.error) { res.send(body[0]); } else { - body.forEach((chunk) => res.write(chunk)); + body.forEach(chunk => res.write(chunk)); res.end(); } } catch (error) { diff --git a/packages/fastboot-express-middleware/test/helpers/fixture-path.js b/packages/fastboot-express-middleware/test/helpers/fixture-path.js index 5c392780e..c53a6f6d8 100644 --- a/packages/fastboot-express-middleware/test/helpers/fixture-path.js +++ b/packages/fastboot-express-middleware/test/helpers/fixture-path.js @@ -1,5 +1,5 @@ var path = require('path'); -module.exports = function (fixturePath) { +module.exports = function(fixturePath) { return path.join(__dirname, '../fixtures/', fixturePath); }; diff --git a/packages/fastboot-express-middleware/test/helpers/test-http-server.js b/packages/fastboot-express-middleware/test/helpers/test-http-server.js index 997701346..910331fdb 100644 --- a/packages/fastboot-express-middleware/test/helpers/test-http-server.js +++ b/packages/fastboot-express-middleware/test/helpers/test-http-server.js @@ -35,7 +35,7 @@ class TestHTTPServer { }); } - return new Promise((resolve) => { + return new Promise(resolve => { let port = options.port || 3000; let host = options.host || 'localhost'; diff --git a/packages/fastboot-express-middleware/test/middleware-test.js b/packages/fastboot-express-middleware/test/middleware-test.js index e13688aee..f088be48e 100644 --- a/packages/fastboot-express-middleware/test/middleware-test.js +++ b/packages/fastboot-express-middleware/test/middleware-test.js @@ -6,27 +6,27 @@ const fastbootMiddleware = require('./../src/index'); const fixture = require('./helpers/fixture-path'); const TestHTTPServer = require('./helpers/test-http-server'); -describe('FastBoot', function () { +describe('FastBoot', function() { let server; this.timeout(10000); - afterEach(function () { + afterEach(function() { if (server) { server.stop(); server = null; } }); - it('throws an exception if no distPath is provided', function () { - let fn = function () { + it('throws an exception if no distPath is provided', function() { + let fn = function() { fastbootMiddleware(); }; expect(fn).to.throw(/You must instantiate FastBoot with a distPath option/); }); - it('can provide distPath as the first argument', async function () { + it('can provide distPath as the first argument', async function() { let middleware = fastbootMiddleware(fixture('basic-app')); server = new TestHTTPServer(middleware); await server.start(); @@ -35,7 +35,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can provide distPath as an option', async function () { + it('can provide distPath as an option', async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), }); @@ -46,7 +46,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can be provided with a custom FastBoot instance', async function () { + it('can be provided with a custom FastBoot instance', async function() { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -62,7 +62,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can reload the FastBoot instance', async function () { + it('can reload the FastBoot instance', async function() { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -85,7 +85,7 @@ describe('FastBoot', function () { expect(html).to.match(/Goodbye from Ember/); }); - it('it appends multivalue headers', async function () { + it('it appends multivalue headers', async function() { let middleware = fastbootMiddleware(fixture('multivalue-headers')); server = new TestHTTPServer(middleware); await server.start(); @@ -94,7 +94,7 @@ describe('FastBoot', function () { expect(headers['x-fastboot']).to.eq('a, b, c'); }); - it('can pass metadata info to the app', async function () { + it('can pass metadata info to the app', async function() { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), visitOptions: { @@ -111,7 +111,8 @@ describe('FastBoot', function () { // FIXME: // TODO: // https://github.com/ember-fastboot/ember-cli-fastboot/pull/840#issuecomment-894329631 - xit('works without metadata passed', async function () { + // eslint-disable-next-line mocha/no-skipped-tests + xit('works without metadata passed', async function() { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), }); @@ -123,10 +124,10 @@ describe('FastBoot', function () { }); /* eslint-disable mocha/no-setup-in-describe */ - [true, false].forEach((chunkedResponse) => { - describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function () { + [true, false].forEach(chunkedResponse => { + describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function() { if (chunkedResponse) { - it('responds with a chunked response', async function () { + it('responds with a chunked response', async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -140,7 +141,7 @@ describe('FastBoot', function () { }); } - it("returns 404 when navigating to a URL that doesn't exist", async function () { + it("returns 404 when navigating to a URL that doesn't exist", async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -155,7 +156,7 @@ describe('FastBoot', function () { } }); - it('returns a 500 error if an error occurs', async function () { + it('returns a 500 error if an error occurs', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), chunkedResponse, @@ -170,8 +171,8 @@ describe('FastBoot', function () { } }); - describe('when resilient mode is enabled', function () { - it('renders no FastBoot markup', async function () { + describe('when resilient mode is enabled', function() { + it('renders no FastBoot markup', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -184,7 +185,7 @@ describe('FastBoot', function () { expect(html).to.not.match(/error/); }); - it('propagates to error handling middleware', async function () { + it('propagates to error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -201,7 +202,7 @@ describe('FastBoot', function () { expect(body).to.match(/hello world/); }); - it('is does not propagate errors when and there is no error handling middleware', async function () { + it('is does not propagate errors when and there is no error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -219,7 +220,7 @@ describe('FastBoot', function () { expect(body).to.match(/hello world/); }); - it('allows post-fastboot middleware to recover the response when it fails', async function () { + it('allows post-fastboot middleware to recover the response when it fails', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -237,8 +238,8 @@ describe('FastBoot', function () { }); }); - describe('when resilient mode is disabled', function () { - it('propagates to error handling middleware', async function () { + describe('when resilient mode is disabled', function() { + it('propagates to error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, @@ -257,7 +258,7 @@ describe('FastBoot', function () { } }); - it('allows post-fastboot middleware to recover the response when it fails', async function () { + it('allows post-fastboot middleware to recover the response when it fails', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, diff --git a/packages/fastboot/dev/memory-usage.js b/packages/fastboot/dev/memory-usage.js index c9d0bcf26..0cdd88b18 100644 --- a/packages/fastboot/dev/memory-usage.js +++ b/packages/fastboot/dev/memory-usage.js @@ -28,7 +28,7 @@ session.connect(); let file; // uses whatever the "current" file is -session.on('HeapProfiler.addHeapSnapshotChunk', (m) => { +session.on('HeapProfiler.addHeapSnapshotChunk', m => { fs.writeSync(file, m.params.chunk); }); diff --git a/packages/fastboot/src/ember-app.js b/packages/fastboot/src/ember-app.js index 342c29037..5436bc85d 100644 --- a/packages/fastboot/src/ember-app.js +++ b/packages/fastboot/src/ember-app.js @@ -165,7 +165,7 @@ class EmberApp { debug('files evaluated'); // Retrieve the application factory from within the sandbox - let AppFactory = sandbox.run(function (ctx) { + let AppFactory = sandbox.run(function(ctx) { return ctx.require('~fastboot/app-factory'); }); @@ -316,7 +316,7 @@ class EmberApp { if (destroyAppInstanceInMs > 0) { // start a timer to destroy the appInstance forcefully in the given ms. // This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes. - destroyAppInstanceTimer = setTimeout(function () { + destroyAppInstanceTimer = setTimeout(function() { if (result._destroy()) { result.error = new Error( 'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms' @@ -418,7 +418,7 @@ const JSON_ESCAPE = { const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g; function escapeJSONString(string) { - return string.replace(JSON_ESCAPE_REGEXP, function (match) { + return string.replace(JSON_ESCAPE_REGEXP, function(match) { return JSON_ESCAPE[match]; }); } @@ -432,7 +432,7 @@ function registerFastBootInfo(info, instance) { } function buildScripts(filePaths) { - return filePaths.filter(Boolean).map((filePath) => { + return filePaths.filter(Boolean).map(filePath => { let source = fs.readFileSync(filePath, { encoding: 'utf8' }); return new vm.Script(source, { filename: filePath }); diff --git a/packages/fastboot/src/fastboot-request.js b/packages/fastboot/src/fastboot-request.js index d6cec8c61..ed7a1c70f 100644 --- a/packages/fastboot/src/fastboot-request.js +++ b/packages/fastboot/src/fastboot-request.js @@ -23,7 +23,7 @@ class FastBootRequest { } var host = this.headers.get('host'); - var matchFound = this.hostWhitelist.some(function (entry) { + var matchFound = this.hostWhitelist.some(function(entry) { if (entry[0] === '/' && entry.slice(-1) === '/') { var regexp = new RegExp(entry.slice(1, -1)); return regexp.test(host); diff --git a/packages/fastboot/src/fastboot-schema.js b/packages/fastboot/src/fastboot-schema.js index 70b9cc1cd..d08c7b747 100644 --- a/packages/fastboot/src/fastboot-schema.js +++ b/packages/fastboot/src/fastboot-schema.js @@ -127,7 +127,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { } } - let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function (file) { + let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function(file) { return path.join(distPath, file); }); let html = fs.readFileSync(path.join(distPath, manifest.htmlFile), 'utf8'); @@ -149,7 +149,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { * @param {boolean} isLegacyWhiteList flag to enable legacy behavior */ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { - whitelist.forEach(function (whitelistedModule) { + whitelist.forEach(function(whitelistedModule) { debug('module whitelisted; module=%s', whitelistedModule); if (isLegacyWhitelist) { @@ -161,7 +161,7 @@ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { } }); - return function (moduleName) { + return function(moduleName) { let packageName = getPackageName(moduleName); let isWhitelisted = whitelist.indexOf(packageName) > -1; diff --git a/packages/fastboot/src/index.js b/packages/fastboot/src/index.js index d7172f2d2..4d9f795d4 100644 --- a/packages/fastboot/src/index.js +++ b/packages/fastboot/src/index.js @@ -55,7 +55,7 @@ class FastBoot { console.warn( '[DEPRECATION] Instantiating `fastboot` with a `sandboxGlobals` option has been deprecated. Please migrate to specifying `buildSandboxGlobals` instead.' ); - buildSandboxGlobals = (globals) => Object.assign({}, globals, options.sandboxGlobals); + buildSandboxGlobals = globals => Object.assign({}, globals, options.sandboxGlobals); } this.buildSandboxGlobals = buildSandboxGlobals; diff --git a/packages/fastboot/src/result.js b/packages/fastboot/src/result.js index dd4f23acb..1c3426b30 100644 --- a/packages/fastboot/src/result.js +++ b/packages/fastboot/src/result.js @@ -80,7 +80,7 @@ class Result { this._body, this._bodyAttributes, this._bodyClass - ).then((html) => { + ).then(html => { let docParts = html.match(HTML_HEAD_REGEX); if (!docParts || docParts.length === 1) { return [html]; @@ -97,7 +97,7 @@ class Result { let [plainBody, ...shoeboxes] = body.split(SHOEBOX_TAG_PATTERN); let chunks = [head, plainBody].concat( - shoeboxes.map((shoebox) => `${SHOEBOX_TAG_PATTERN}${shoebox}`) + shoeboxes.map(shoebox => `${SHOEBOX_TAG_PATTERN}${shoebox}`) ); return chunks; @@ -203,10 +203,10 @@ function extractExtraAttributes(element) { let klass; let attributes; if (element.attributes.length > 0) { - let elementClass = element.attributes.find((attr) => attr.name === 'class'); + let elementClass = element.attributes.find(attr => attr.name === 'class'); if (elementClass) { klass = elementClass; - let otherAttrs = element.attributes.filter((attr) => attr.name !== 'class'); + let otherAttrs = element.attributes.filter(attr => attr.name !== 'class'); if (otherAttrs.length > 0) { attributes = HTMLSerializer.attributes(otherAttrs); } else { @@ -229,9 +229,9 @@ function missingTag(tag) { } function addClass(html, regex, newClass) { - return html.replace(regex, function (_, tag, attributes) { + return html.replace(regex, function(_, tag, attributes) { if (/class="([^"]*)"/i.test(attributes)) { - attributes = attributes.replace(/class="([^"]*)"/i, function (_, klass) { + attributes = attributes.replace(/class="([^"]*)"/i, function(_, klass) { return `class="${klass} ${newClass}"`; }); } else { @@ -256,7 +256,7 @@ async function insertIntoIndexHTML( let isBodyReplaced = false; let isHeadReplaced = false; - html = html.replace(//g, function (match, tag) { + html = html.replace(//g, function(match, tag) { if (tag === 'HEAD' && head && !isHeadReplaced) { isHeadReplaced = true; return head; @@ -271,7 +271,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(html)(.*)>/i, htmlClass.value); } if (htmlAttributes) { - html = html.replace(/]*/i, function (match) { + html = html.replace(/]*/i, function(match) { return match + ' ' + htmlAttributes; }); } @@ -280,7 +280,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(body)(.*)>/i, bodyClass.value); } if (bodyAttributes) { - html = html.replace(/]*/i, function (match) { + html = html.replace(/]*/i, function(match) { return match + ' ' + bodyAttributes; }); } diff --git a/packages/fastboot/src/sandbox.js b/packages/fastboot/src/sandbox.js index 3aa2e4408..e462a0693 100644 --- a/packages/fastboot/src/sandbox.js +++ b/packages/fastboot/src/sandbox.js @@ -46,10 +46,10 @@ module.exports = class Sandbox { buildWrappedConsole() { let wrappedConsole = Object.create(console); - wrappedConsole.error = function (...args) { + wrappedConsole.error = function(...args) { console.error.apply( console, - args.map(function (a) { + args.map(function(a) { return typeof a === 'string' ? chalk.red(a) : a; }) ); diff --git a/packages/fastboot/test/fastboot-dependencies-test.js b/packages/fastboot/test/fastboot-dependencies-test.js index beb48faa6..3b8cb2b2f 100644 --- a/packages/fastboot/test/fastboot-dependencies-test.js +++ b/packages/fastboot/test/fastboot-dependencies-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBoot with dependencies', function () { - it('it works with dependencies', function () { +describe('FastBoot with dependencies', function() { + it('it works with dependencies', function() { var fastboot = new FastBoot({ distPath: fixture('app-with-dependencies'), }); return fastboot .visit('/') - .then((r) => r.html()) - .then((html) => { + .then(r => r.html()) + .then(html => { expect(html).to.match(/https:\/\/emberjs.com/); expect(html).to.match(/FOO/); expect(html).to.match(/BAR/); diff --git a/packages/fastboot/test/fastboot-headers-test.js b/packages/fastboot/test/fastboot-headers-test.js index b7714a7a8..1d65353fa 100644 --- a/packages/fastboot/test/fastboot-headers-test.js +++ b/packages/fastboot/test/fastboot-headers-test.js @@ -3,8 +3,8 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); -describe('FastBootHeaders', function () { - it('lower normalizes the headers to lowercase', function () { +describe('FastBootHeaders', function() { + it('lower normalizes the headers to lowercase', function() { var headers = { 'X-Test-Header': 'value1, value2', }; @@ -13,7 +13,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array from getAll when header value is string', function () { + it('returns an array from getAll when header value is string', function() { var headers = { 'x-test-header': 'value1, value2', }; @@ -22,7 +22,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array of header values from getAll, regardless of header name casing', function () { + it('returns an array of header values from getAll, regardless of header name casing', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -32,7 +32,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1', 'value2']); }); - it('returns an emtpy array when a header is not present', function () { + it('returns an emtpy array when a header is not present', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -42,7 +42,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('host')).to.deep.equal([]); }); - it('returns the first value when using get, regardless of case', function () { + it('returns the first value when using get, regardless of case', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -52,7 +52,7 @@ describe('FastBootHeaders', function () { expect(headers.get('x-test-header')).to.equal('value1'); }); - it('returns null when using get when a header is not present', function () { + it('returns null when using get when a header is not present', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -62,7 +62,7 @@ describe('FastBootHeaders', function () { expect(headers.get('host')).to.be.null; }); - it('returns whether or not a header is present via has, regardless of casing', function () { + it('returns whether or not a header is present via has, regardless of casing', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -74,7 +74,7 @@ describe('FastBootHeaders', function () { expect(headers.has('host')).to.be.false; }); - it('appends entries onto a header, regardless of casing', function () { + it('appends entries onto a header, regardless of casing', function() { var headers = new FastBootHeaders(); expect(headers.has('x-foo')).to.be.false; @@ -87,7 +87,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-foo')).to.deep.equal(['bar', 'baz']); }); - it('deletes entries onto a header, regardless of casing', function () { + it('deletes entries onto a header, regardless of casing', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'bar'); @@ -97,7 +97,7 @@ describe('FastBootHeaders', function () { expect(headers.has('x-foo')).to.be.false; }); - it('returns an iterator for the header/value pairs when calling entries', function () { + it('returns an iterator for the header/value pairs when calling entries', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -111,7 +111,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('returns an iterator for keys containing all the keys', function () { + it('returns an iterator for keys containing all the keys', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -125,7 +125,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('sets a header, overwriting existing values, regardless of casing', function () { + it('sets a header, overwriting existing values, regardless of casing', function() { var headers = new FastBootHeaders(); expect(headers.getAll('x-foo')).to.deep.equal([]); @@ -141,7 +141,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-bar')).to.deep.equal(['baz']); }); - it('returns an iterator for values containing all the values', function () { + it('returns an iterator for values containing all the values', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -155,7 +155,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () { + it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; diff --git a/packages/fastboot/test/fastboot-info-test.js b/packages/fastboot/test/fastboot-info-test.js index 1cf24afee..67f91df94 100644 --- a/packages/fastboot/test/fastboot-info-test.js +++ b/packages/fastboot/test/fastboot-info-test.js @@ -4,7 +4,7 @@ var FastBootResponse = require('./../src/fastboot-response.js'); var FastBootRequest = require('./../src/fastboot-request.js'); function delayFor(ms) { - let promise = new Promise((resolve) => { + let promise = new Promise(resolve => { setTimeout(() => { resolve(); }, ms); @@ -13,7 +13,7 @@ function delayFor(ms) { return promise; } -describe('FastBootInfo', function () { +describe('FastBootInfo', function() { var response; var request; var fastbootInfo; @@ -22,13 +22,13 @@ describe('FastBootInfo', function () { baz: 'apple', }; - beforeEach(function () { + beforeEach(function() { response = {}; request = { cookie: '', protocol: 'http', headers: {}, - get: function () { + get: function() { return this.cookie; }, }; @@ -36,19 +36,19 @@ describe('FastBootInfo', function () { fastbootInfo = new FastBootInfo(request, response, { metadata }); }); - it('has a FastBootRequest', function () { + it('has a FastBootRequest', function() { expect(fastbootInfo.request).to.be.an.instanceOf(FastBootRequest); }); - it('has a FastBootResponse', function () { + it('has a FastBootResponse', function() { expect(fastbootInfo.response).to.be.an.instanceOf(FastBootResponse); }); - it('has metadata', function () { + it('has metadata', function() { expect(fastbootInfo.metadata).to.deep.equal(metadata); }); - it('can use deferRendering', async function () { + it('can use deferRendering', async function() { let steps = []; steps.push('deferRendering called'); diff --git a/packages/fastboot/test/fastboot-request-test.js b/packages/fastboot/test/fastboot-request-test.js index 052649119..4e2b096e9 100644 --- a/packages/fastboot/test/fastboot-request-test.js +++ b/packages/fastboot/test/fastboot-request-test.js @@ -1,8 +1,8 @@ var expect = require('chai').expect; var FastBootRequest = require('./../src/fastboot-request.js'); -describe('FastBootRequest', function () { - it('throws an exception if no hostWhitelist is provided', function () { +describe('FastBootRequest', function() { + it('throws an exception if no hostWhitelist is provided', function() { var request = { protocol: 'http', headers: { @@ -11,13 +11,13 @@ describe('FastBootRequest', function () { }; var fastbootRequest = new FastBootRequest(request); - var fn = function () { + var fn = function() { fastbootRequest.host(); }; expect(fn).to.throw(/You must provide a hostWhitelist to retrieve the host/); }); - it('throws an exception if the host header does not match an entry in the hostWhitelist', function () { + it('throws an exception if the host header does not match an entry in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -28,7 +28,7 @@ describe('FastBootRequest', function () { var hostWhitelist = ['example.com', 'localhost:4200']; var fastbootRequest = new FastBootRequest(request, hostWhitelist); - var fn = function () { + var fn = function() { fastbootRequest.host(); }; expect(fn).to.throw( @@ -36,7 +36,7 @@ describe('FastBootRequest', function () { ); }); - it('returns the host if it is in the hostWhitelist', function () { + it('returns the host if it is in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -51,7 +51,7 @@ describe('FastBootRequest', function () { expect(host).to.equal('localhost:4200'); }); - it('returns the host if it matches a regex in the hostWhitelist', function () { + it('returns the host if it matches a regex in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -66,7 +66,7 @@ describe('FastBootRequest', function () { expect(host).to.equal('localhost:4200'); }); - it('captures the query params from the request', function () { + it('captures the query params from the request', function() { var request = { protocol: 'http', query: { @@ -81,7 +81,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.queryParams.foo).to.equal('bar'); }); - it('captures the path from the request', function () { + it('captures the path from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -94,7 +94,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.path).to.equal('/foo'); }); - it('captures the headers from the request', function () { + it('captures the headers from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -108,7 +108,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.headers.get('Host')).to.equal('localhost:4200'); }); - it('captures the protocol from the request', function () { + it('captures the protocol from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -122,7 +122,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.protocol).to.equal('http:'); }); - it('captures the cookies from the request', function () { + it('captures the cookies from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -136,7 +136,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.cookies.test).to.equal('bar'); }); - it('captures the method from the request', function () { + it('captures the method from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -151,7 +151,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.method).to.equal('GET'); }); - it('captures the body from the request', function () { + it('captures the body from the request', function() { var request = { protocol: 'http', url: '/foo', diff --git a/packages/fastboot/test/fastboot-response-test.js b/packages/fastboot/test/fastboot-response-test.js index 426747a69..545cf8607 100644 --- a/packages/fastboot/test/fastboot-response-test.js +++ b/packages/fastboot/test/fastboot-response-test.js @@ -2,10 +2,10 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); var FastBootResponse = require('./../src/fastboot-response.js'); -describe('FastBootResponse', function () { +describe('FastBootResponse', function() { var fastBootResponse; - beforeEach(function () { + beforeEach(function() { var mockResponse = { getHeaders() { return { @@ -18,27 +18,27 @@ describe('FastBootResponse', function () { fastBootResponse = new FastBootResponse(mockResponse); }); - describe('headers', function () { - it('should have headers', function () { + describe('headers', function() { + it('should have headers', function() { expect(fastBootResponse).to.have.ownProperty('headers'); }); - it('should be an instance of FastBootHeaders', function () { + it('should be an instance of FastBootHeaders', function() { expect(fastBootResponse.headers).to.be.an.instanceOf(FastBootHeaders); }); - it("should contain the original response's headers", function () { + it("should contain the original response's headers", function() { var header = fastBootResponse.headers.getAll('i-am-a'); expect(header).to.deep.equal(['mock header', 'me too']); }); }); - describe('statusCode', function () { - it('should have a statusCode', function () { + describe('statusCode', function() { + it('should have a statusCode', function() { expect(fastBootResponse).to.have.ownProperty('statusCode'); }); - it('should default to 200', function () { + it('should default to 200', function() { expect(fastBootResponse.statusCode).to.equal(200); }); }); diff --git a/packages/fastboot/test/fastboot-shoebox-test.js b/packages/fastboot/test/fastboot-shoebox-test.js index f992a7b5b..e6d9afe85 100644 --- a/packages/fastboot/test/fastboot-shoebox-test.js +++ b/packages/fastboot/test/fastboot-shoebox-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBootShoebox', function () { - it('can render the escaped shoebox HTML', function () { +describe('FastBootShoebox', function() { + it('can render the escaped shoebox HTML', function() { var fastboot = new FastBoot({ distPath: fixture('shoebox'), }); return fastboot .visit('/') - .then((r) => r.html()) - .then((html) => { + .then(r => r.html()) + .then(html => { expect(html).to.match( /'; var boundaryEndTag = ''; - beforeEach(function () { + beforeEach(function() { doc.head.appendChild(doc.createRawHTMLSection(HEAD)); doc.body.appendChild(doc.createRawHTMLSection(BODY)); result._finalize(); }); - it('should return the FastBoot-rendered document body', function () { + it('should return the FastBoot-rendered document body', function() { var domContents = result.domContents(); expect(domContents.head).to.include(HEAD); expect(domContents.body).to.include(BODY);