diff --git a/bin/build-for-publishing.js b/bin/build-for-publishing.js index 9e7e16fb44e..46e31ff6b08 100755 --- a/bin/build-for-publishing.js +++ b/bin/build-for-publishing.js @@ -27,7 +27,7 @@ function updatePackageJSONVersion() { pkg._originalVersion = pkg.version; pkg.version = VERSION; fs.writeFileSync(packageJSONPath, JSON.stringify(pkg, null, 2), { - encoding: 'utf-8' + encoding: 'utf-8', }); } @@ -46,7 +46,7 @@ function updateDocumentationVersion() { let docs = JSON.parse(contents); docs.project.version = VERSION; fs.writeFileSync(docsPath, JSON.stringify(docs, null, 2), { - encoding: 'utf-8' + encoding: 'utf-8', }); } @@ -72,12 +72,10 @@ Promise.resolve() version: VERSION, buildType: process.env.BUILD_TYPE, SHA: process.env.TRAVIS_COMMIT, - assetPath: `/${process.env.BUILD_TYPE}/shas/${ - process.env.TRAVIS_COMMIT - }.tgz` + assetPath: `/${process.env.BUILD_TYPE}/shas/${process.env.TRAVIS_COMMIT}.tgz`, }; fs.writeFileSync('build-metadata.json', JSON.stringify(metadata, null, 2), { - encoding: 'utf-8' + encoding: 'utf-8', }); // using npm pack here because `yarn pack` does not honor the `package.json`'s `files` diff --git a/bin/publish_to_s3.js b/bin/publish_to_s3.js index c15b5084ba6..c8cffde8b14 100755 --- a/bin/publish_to_s3.js +++ b/bin/publish_to_s3.js @@ -13,10 +13,7 @@ // ./bin/publish_to_s3.js // ``` var S3Publisher = require('ember-publisher'); -var configPath = require('path').join( - __dirname, - '../config/s3ProjectConfig.js' -); +var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js'); var publisher = new S3Publisher({ projectConfigPath: configPath }); @@ -27,7 +24,7 @@ publisher.currentBranch = function() { master: 'canary', beta: 'beta', release: 'release', - 'lts-2-4': 'lts-2-4' + 'lts-2-4': 'lts-2-4', }[this.CURRENT_BRANCH] ); }; diff --git a/bin/run-browserstack-tests.js b/bin/run-browserstack-tests.js index a2d18fa622f..ef39e91e794 100755 --- a/bin/run-browserstack-tests.js +++ b/bin/run-browserstack-tests.js @@ -48,7 +48,7 @@ RSVP.resolve() '--host', '127.0.0.1', '--port', - '7774' + '7774', ]); }) .finally(function() { diff --git a/bin/run-tests.js b/bin/run-tests.js index edb2eb53bef..9bbed5a49e3 100755 --- a/bin/run-tests.js +++ b/bin/run-tests.js @@ -86,11 +86,7 @@ function runInBrowser(url, retries, resolve, reject) { response += ', '; } - response += - 'expected: ' + - details.expected + - ', but was: ' + - details.actual; + response += 'expected: ' + details.expected + ', but was: ' + details.actual; } if (details.source) { @@ -143,7 +139,7 @@ function runInBrowser(url, retries, resolve, reject) { if (typeof window.callPhantom === 'function') { window.callPhantom({ name: 'QUnit.done', - data: result + data: result, }); } }); @@ -156,9 +152,7 @@ function runInBrowser(url, retries, resolve, reject) { var failed = !result || !result.total || result.failed; if (!result.total) { - console.error( - 'No tests were executed. Are you loading tests asynchronously?' - ); + console.error('No tests were executed. Are you loading tests asynchronously?'); } var code = failed ? 1 : 0; @@ -175,9 +169,7 @@ function runInBrowser(url, retries, resolve, reject) { } else { console.log(chalk.red('Giving up! (╯°□°)╯︵ ┻━┻')); console.log( - chalk.yellow( - 'This might be a known issue with Chrome headless, skipping for now' - ) + chalk.yellow('This might be a known issue with Chrome headless, skipping for now') ); resolve(result); } @@ -276,12 +268,8 @@ function runChecker(bin, args) { function codeQualityChecks() { var checkers = [ runChecker('node', [require.resolve('typescript/bin/tsc'), '--noEmit']), - runChecker('node', [ - require.resolve('tslint/bin/tslint'), - '-p', - 'tsconfig.json' - ]), - runChecker('node', [require.resolve('eslint/bin/eslint'), '.']) + runChecker('node', [require.resolve('tslint/bin/tslint'), '-p', 'tsconfig.json']), + runChecker('node', [require.resolve('eslint/bin/eslint'), '.']), ]; return RSVP.Promise.all(checkers).then(function(results) { results.forEach(result => { diff --git a/bin/run-travis-browser-tests.js b/bin/run-travis-browser-tests.js index d2d17b74b01..a9edd70a0f6 100755 --- a/bin/run-travis-browser-tests.js +++ b/bin/run-travis-browser-tests.js @@ -44,7 +44,7 @@ RSVP.resolve() '--file', 'testem.travis-browsers.js', '--port', - '7000' + '7000', ]); }) .catch(function(error) { diff --git a/bin/yarn-link-glimmer.js b/bin/yarn-link-glimmer.js index 72daa167167..29310d2cfb4 100755 --- a/bin/yarn-link-glimmer.js +++ b/bin/yarn-link-glimmer.js @@ -4,13 +4,11 @@ const child_process = require('child_process'); const yarnConfig = JSON.parse( JSON.parse( require('child_process').execSync('yarn --json config current', { - encoding: 'utf8' + encoding: 'utf8', }) ).data ); -const linkedModules = yarnConfig.linkedModules.filter(m => - m.startsWith('@glimmer/') -); +const linkedModules = yarnConfig.linkedModules.filter(m => m.startsWith('@glimmer/')); linkedModules.forEach(mod => { child_process.execSync(`yarn link "${mod}"`); diff --git a/bin/yarn-unlink-glimmer.js b/bin/yarn-unlink-glimmer.js index cdd161bb1c0..cc4884fcb0a 100755 --- a/bin/yarn-unlink-glimmer.js +++ b/bin/yarn-unlink-glimmer.js @@ -4,13 +4,11 @@ const child_process = require('child_process'); const yarnConfig = JSON.parse( JSON.parse( require('child_process').execSync('yarn --json config current', { - encoding: 'utf8' + encoding: 'utf8', }) ).data ); -const linkedModules = yarnConfig.linkedModules.filter(m => - m.startsWith('@glimmer/') -); +const linkedModules = yarnConfig.linkedModules.filter(m => m.startsWith('@glimmer/')); linkedModules.forEach(mod => { child_process.execSync(`yarn unlink "${mod}"`); diff --git a/blueprints/-addon-import.js b/blueprints/-addon-import.js index d950ca1d8f3..31c2c4275c9 100644 --- a/blueprints/-addon-import.js +++ b/blueprints/-addon-import.js @@ -20,35 +20,29 @@ module.exports = { return path.join('lib', options.inRepoAddon, 'app'); } return 'app'; - } + }, }; }, locals: function(options) { - var addonRawName = options.inRepoAddon - ? options.inRepoAddon - : options.project.name(); + var addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); var addonName = stringUtil.dasherize(addonRawName); var fileName = stringUtil.dasherize(options.entity.name); var blueprintName = options.originBlueprintName; var modulePathSegments = [ addonName, inflector.pluralize(options.originBlueprintName), - fileName + fileName, ]; if (blueprintName.match(/-addon/)) { blueprintName = blueprintName.substr(0, blueprintName.indexOf('-addon')); - modulePathSegments = [ - addonName, - inflector.pluralize(blueprintName), - fileName - ]; + modulePathSegments = [addonName, inflector.pluralize(blueprintName), fileName]; } return { modulePath: modulePathSegments.join('/'), - blueprintName: blueprintName + blueprintName: blueprintName, }; - } + }, }; diff --git a/blueprints/acceptance-test/index.js b/blueprints/acceptance-test/index.js index db6cd7619a5..2a305ae25d0 100644 --- a/blueprints/acceptance-test/index.js +++ b/blueprints/acceptance-test/index.js @@ -14,11 +14,7 @@ module.exports = useTestFrameworkDetector({ let testFolderRoot = stringUtils.dasherize(options.project.name()); if (options.project.isEmberCLIAddon()) { - testFolderRoot = pathUtil.getRelativeParentPath( - options.entity.name, - -1, - false - ); + testFolderRoot = pathUtil.getRelativeParentPath(options.entity.name, -1, false); } let destroyAppExists = fs.existsSync( @@ -27,13 +23,13 @@ module.exports = useTestFrameworkDetector({ let friendlyTestName = [ 'Acceptance', - stringUtils.dasherize(options.entity.name).replace(/[-]/g, ' ') + stringUtils.dasherize(options.entity.name).replace(/[-]/g, ' '), ].join(' | '); return { testFolderRoot: testFolderRoot, friendlyTestName, - destroyAppExists + destroyAppExists, }; - } + }, }); diff --git a/blueprints/component-addon/index.js b/blueprints/component-addon/index.js index 3386da0ac77..8bcf3eaf961 100644 --- a/blueprints/component-addon/index.js +++ b/blueprints/component-addon/index.js @@ -13,11 +13,7 @@ module.exports = { return { __path__: function(options) { if (options.pod) { - return path.join( - options.podPath, - options.locals.path, - options.dasherizedModuleName - ); + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); } return 'components'; }, @@ -32,7 +28,7 @@ module.exports = { return path.join('lib', options.inRepoAddon, 'app'); } return 'app'; - } + }, }; }, @@ -43,22 +39,18 @@ module.exports = { }, locals: function(options) { - let addonRawName = options.inRepoAddon - ? options.inRepoAddon - : options.project.name(); + let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); let addonName = stringUtil.dasherize(addonRawName); let fileName = stringUtil.dasherize(options.entity.name); let importPathName = [addonName, 'components', fileName].join('/'); if (options.pod) { - importPathName = [addonName, 'components', fileName, 'component'].join( - '/' - ); + importPathName = [addonName, 'components', fileName, 'component'].join('/'); } return { modulePath: importPathName, - path: getPathOption(options) + path: getPathOption(options), }; - } + }, }; diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js index d3f8a17aab8..c41b881a98f 100644 --- a/blueprints/component-test/index.js +++ b/blueprints/component-test/index.js @@ -6,8 +6,7 @@ const isPackageMissing = require('ember-cli-is-package-missing'); const getPathOption = require('ember-cli-get-component-path-option'); const useTestFrameworkDetector = require('../test-framework-detector'); -const isModuleUnificationProject = require('../module-unification') - .isModuleUnificationProject; +const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject; module.exports = useTestFrameworkDetector({ description: 'Generates a component integration or unit test.', @@ -21,9 +20,9 @@ module.exports = useTestFrameworkDetector({ { i: 'integration' }, { u: 'unit' }, { integration: 'integration' }, - { unit: 'unit' } - ] - } + { unit: 'unit' }, + ], + }, ], fileMapTokens: function() { @@ -50,7 +49,7 @@ module.exports = useTestFrameworkDetector({ throw "Pods aren't supported within a module unification app"; } return path.join('ui', 'components', options.dasherizedModuleName); - } + }, }; } else { return { @@ -62,14 +61,10 @@ module.exports = useTestFrameworkDetector({ }, __path__(options) { if (options.pod) { - return path.join( - options.podPath, - options.locals.path, - options.dasherizedModuleName - ); + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); } return 'components'; - } + }, }; } }, @@ -82,13 +77,11 @@ module.exports = useTestFrameworkDetector({ let friendlyTestDescription = [ testType === 'unit' ? 'Unit' : 'Integration', 'Component', - dasherizedModuleName + dasherizedModuleName, ].join(' | '); if (options.pod && options.path !== 'components' && options.path !== '') { - componentPathName = [options.path, dasherizedModuleName] - .filter(Boolean) - .join('/'); + componentPathName = [options.path, dasherizedModuleName].filter(Boolean).join('/'); } else if (isModuleUnificationProject(this.project)) { if (options.inRepoAddon) { componentPathName = `${options.inRepoAddon}::${dasherizedModuleName}`; @@ -101,7 +94,7 @@ module.exports = useTestFrameworkDetector({ path: getPathOption(options), testType: testType, componentPathName: componentPathName, - friendlyTestDescription: friendlyTestDescription + friendlyTestDescription: friendlyTestDescription, }; }, @@ -112,8 +105,8 @@ module.exports = useTestFrameworkDetector({ isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile') ) { return this.addPackagesToProject([ - { name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' } + { name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' }, ]); } - } + }, }); diff --git a/blueprints/component/index.js b/blueprints/component/index.js index 0da7e32a69a..7e80148076d 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -6,8 +6,7 @@ const pathUtil = require('ember-cli-path-utils'); const validComponentName = require('ember-cli-valid-component-name'); const getPathOption = require('ember-cli-get-component-path-option'); const normalizeEntityName = require('ember-cli-normalize-entity-name'); -const isModuleUnificationProject = require('../module-unification') - .isModuleUnificationProject; +const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject; module.exports = { description: 'Generates a component. Name must contain a hyphen.', @@ -17,8 +16,8 @@ module.exports = { name: 'path', type: String, default: 'components', - aliases: [{ 'no-path': '' }] - } + aliases: [{ 'no-path': '' }], + }, ], filesPath: function() { @@ -45,28 +44,20 @@ module.exports = { }, __path__(options) { return path.join('ui', 'components', options.dasherizedModuleName); - } + }, }; } else { return { __path__: function(options) { if (options.pod) { - return path.join( - options.podPath, - options.locals.path, - options.dasherizedModuleName - ); + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); } else { return 'components'; } }, __templatepath__: function(options) { if (options.pod) { - return path.join( - options.podPath, - options.locals.path, - options.dasherizedModuleName - ); + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); } return 'templates/components'; }, @@ -75,7 +66,7 @@ module.exports = { return 'template'; } return options.dasherizedModuleName; - } + }, }; } }, @@ -92,10 +83,7 @@ module.exports = { let contents = ''; // if we're in an addon, build import statement - if ( - options.project.isEmberCLIAddon() || - (options.inRepoAddon && !options.inDummy) - ) { + if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) { if (options.pod) { templatePath = './template'; } else { @@ -111,7 +99,7 @@ module.exports = { return { importTemplate: importTemplate, contents: contents, - path: getPathOption(options) + path: getPathOption(options), }; - } + }, }; diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js index e6c7c3cbe01..edd7db3f429 100644 --- a/blueprints/controller-test/index.js +++ b/blueprints/controller-test/index.js @@ -11,11 +11,7 @@ module.exports = useTestFrameworkDetector({ let controllerPathName = dasherizedModuleName; return { controllerPathName: controllerPathName, - friendlyTestDescription: [ - 'Unit', - 'Controller', - dasherizedModuleName - ].join(' | ') + friendlyTestDescription: ['Unit', 'Controller', dasherizedModuleName].join(' | '), }; - } + }, }); diff --git a/blueprints/controller/index.js b/blueprints/controller/index.js index 42d57b86121..68960e4b276 100644 --- a/blueprints/controller/index.js +++ b/blueprints/controller/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates a controller.' + description: 'Generates a controller.', }; diff --git a/blueprints/helper-test/index.js b/blueprints/helper-test/index.js index 6d755147f78..ebbb8cff206 100644 --- a/blueprints/helper-test/index.js +++ b/blueprints/helper-test/index.js @@ -17,32 +17,28 @@ module.exports = useTestFrameworkDetector({ { i: 'integration' }, { u: 'unit' }, { integration: 'integration' }, - { unit: 'unit' } - ] - } + { unit: 'unit' }, + ], + }, ], fileMapTokens: function() { return { __testType__: function(options) { return options.locals.testType || 'integration'; - } + }, }; }, locals: function(options) { let testType = options.testType || 'integration'; let testName = testType === 'integration' ? 'Integration' : 'Unit'; - let friendlyTestName = [testName, 'Helper', options.entity.name].join( - ' | ' - ); + let friendlyTestName = [testName, 'Helper', options.entity.name].join(' | '); return { friendlyTestName: friendlyTestName, - dasherizedModulePrefix: stringUtils.dasherize( - options.project.config().modulePrefix - ), - testType: testType + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix), + testType: testType, }; }, @@ -53,8 +49,8 @@ module.exports = useTestFrameworkDetector({ isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile') ) { return this.addPackagesToProject([ - { name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' } + { name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' }, ]); } - } + }, }); diff --git a/blueprints/helper/index.js b/blueprints/helper/index.js index f409976dd42..fb1df4e4dff 100644 --- a/blueprints/helper/index.js +++ b/blueprints/helper/index.js @@ -6,5 +6,5 @@ module.exports = { description: 'Generates a helper function.', normalizeEntityName: function(entityName) { return normalizeEntityName(entityName); - } + }, }; diff --git a/blueprints/initializer-test/index.js b/blueprints/initializer-test/index.js index c4410f6c23d..d12730ad441 100644 --- a/blueprints/initializer-test/index.js +++ b/blueprints/initializer-test/index.js @@ -10,15 +10,11 @@ module.exports = useTestFrameworkDetector({ description: 'Generates an initializer unit test.', locals: function(options) { return { - friendlyTestName: ['Unit', 'Initializer', options.entity.name].join( - ' | ' - ), - dasherizedModulePrefix: stringUtils.dasherize( - options.project.config().modulePrefix - ), + friendlyTestName: ['Unit', 'Initializer', options.entity.name].join(' | '), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix), destroyAppExists: fs.existsSync( path.join(this.project.root, '/tests/helpers/destroy-app.js') - ) + ), }; - } + }, }); diff --git a/blueprints/initializer/index.js b/blueprints/initializer/index.js index 1a96d3a0735..201732241cd 100644 --- a/blueprints/initializer/index.js +++ b/blueprints/initializer/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates an initializer.' + description: 'Generates an initializer.', }; diff --git a/blueprints/instance-initializer-test/index.js b/blueprints/instance-initializer-test/index.js index 3b5c3086423..9b5282c7b85 100644 --- a/blueprints/instance-initializer-test/index.js +++ b/blueprints/instance-initializer-test/index.js @@ -10,17 +10,11 @@ module.exports = useTestFrameworkDetector({ description: 'Generates an instance initializer unit test.', locals: function(options) { return { - friendlyTestName: [ - 'Unit', - 'Instance Initializer', - options.entity.name - ].join(' | '), - dasherizedModulePrefix: stringUtils.dasherize( - options.project.config().modulePrefix - ), + friendlyTestName: ['Unit', 'Instance Initializer', options.entity.name].join(' | '), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix), destroyAppExists: fs.existsSync( path.join(this.project.root, '/tests/helpers/destroy-app.js') - ) + ), }; - } + }, }); diff --git a/blueprints/instance-initializer/index.js b/blueprints/instance-initializer/index.js index 885428c4562..79c87c1db92 100644 --- a/blueprints/instance-initializer/index.js +++ b/blueprints/instance-initializer/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates an instance initializer.' + description: 'Generates an instance initializer.', }; diff --git a/blueprints/mixin-test/index.js b/blueprints/mixin-test/index.js index df0dc09d194..4755a6f025f 100644 --- a/blueprints/mixin-test/index.js +++ b/blueprints/mixin-test/index.js @@ -6,10 +6,8 @@ module.exports = useTestFrameworkDetector({ description: 'Generates a mixin unit test.', locals: function(options) { return { - projectName: options.inRepoAddon - ? options.inRepoAddon - : options.project.name(), - friendlyTestName: ['Unit', 'Mixin', options.entity.name].join(' | ') + projectName: options.inRepoAddon ? options.inRepoAddon : options.project.name(), + friendlyTestName: ['Unit', 'Mixin', options.entity.name].join(' | '), }; - } + }, }); diff --git a/blueprints/mixin/index.js b/blueprints/mixin/index.js index 8034b1a86ad..f4053a45451 100644 --- a/blueprints/mixin/index.js +++ b/blueprints/mixin/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates a mixin.' + description: 'Generates a mixin.', }; diff --git a/blueprints/module-unification.js b/blueprints/module-unification.js index a1cf1b69ed8..90897cdc51b 100644 --- a/blueprints/module-unification.js +++ b/blueprints/module-unification.js @@ -3,5 +3,5 @@ module.exports = { isModuleUnificationProject(project) { return project.isModuleUnification && project.isModuleUnification(); - } + }, }; diff --git a/blueprints/route-addon/index.js b/blueprints/route-addon/index.js index 6e794435d32..6727e51cb1e 100644 --- a/blueprints/route-addon/index.js +++ b/blueprints/route-addon/index.js @@ -41,22 +41,18 @@ module.exports = { } return 'app'; - } + }, }; }, locals: function(options) { let locals = {}; - let addonRawName = options.inRepoAddon - ? options.inRepoAddon - : options.project.name(); + let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); let addonName = stringUtil.dasherize(addonRawName); let fileName = stringUtil.dasherize(options.entity.name); ['route', 'template'].forEach(function(blueprint) { - let pathName = [addonName, inflector.pluralize(blueprint), fileName].join( - '/' - ); + let pathName = [addonName, inflector.pluralize(blueprint), fileName].join('/'); if (options.pod) { pathName = [addonName, fileName, blueprint].join('/'); @@ -66,5 +62,5 @@ module.exports = { }); return locals; - } + }, }; diff --git a/blueprints/route-test/index.js b/blueprints/route-test/index.js index 268895d0ebf..9d9e90e5493 100644 --- a/blueprints/route-test/index.js +++ b/blueprints/route-test/index.js @@ -10,8 +10,8 @@ module.exports = useTestFrameworkDetector({ availableOptions: [ { name: 'reset-namespace', - type: Boolean - } + type: Boolean, + }, ], fileMapTokens: function() { @@ -30,7 +30,7 @@ module.exports = useTestFrameworkDetector({ return path.join(options.podPath, options.locals.moduleName); } return 'routes'; - } + }, }; }, @@ -42,10 +42,8 @@ module.exports = useTestFrameworkDetector({ } return { - friendlyTestDescription: ['Unit', 'Route', options.entity.name].join( - ' | ' - ), - moduleName: stringUtil.dasherize(moduleName) + friendlyTestDescription: ['Unit', 'Route', options.entity.name].join(' | '), + moduleName: stringUtil.dasherize(moduleName), }; - } + }, }); diff --git a/blueprints/route/index.js b/blueprints/route/index.js index 28fd3eb3ff3..4b9a9a6ce20 100644 --- a/blueprints/route/index.js +++ b/blueprints/route/index.js @@ -7,24 +7,23 @@ const stringUtil = require('ember-cli-string-utils'); const EmberRouterGenerator = require('ember-router-generator'); module.exports = { - description: - 'Generates a route and a template, and registers the route with the router.', + description: 'Generates a route and a template, and registers the route with the router.', availableOptions: [ { name: 'path', type: String, - default: '' + default: '', }, { name: 'skip-router', type: Boolean, - default: false + default: false, }, { name: 'reset-namespace', - type: Boolean - } + type: Boolean, + }, ], fileMapTokens: function() { @@ -67,7 +66,7 @@ module.exports = { } return 'app'; - } + }, }; }, @@ -79,7 +78,7 @@ module.exports = { } return { - moduleName: stringUtil.dasherize(moduleName) + moduleName: stringUtil.dasherize(moduleName), }; }, @@ -112,14 +111,14 @@ module.exports = { afterUninstall: function(options) { updateRouter.call(this, 'remove', options); - } + }, }; function updateRouter(action, options) { let entity = options.entity; let actionColorMap = { add: 'green', - remove: 'red' + remove: 'red', }; let color = actionColorMap[action] || 'gray'; @@ -135,12 +134,7 @@ function findRouter(options) { let routerPathParts = [options.project.root]; if (options.dummy && options.project.isEmberCLIAddon()) { - routerPathParts = routerPathParts.concat([ - 'tests', - 'dummy', - 'app', - 'router.js' - ]); + routerPathParts = routerPathParts.concat(['tests', 'dummy', 'app', 'router.js']); } else { routerPathParts = routerPathParts.concat(['app', 'router.js']); } diff --git a/blueprints/service-test/index.js b/blueprints/service-test/index.js index 844307cda2b..e4f134c7ca7 100644 --- a/blueprints/service-test/index.js +++ b/blueprints/service-test/index.js @@ -6,9 +6,7 @@ module.exports = useTestFrameworkDetector({ description: 'Generates a service unit test.', locals: function(options) { return { - friendlyTestDescription: ['Unit', 'Service', options.entity.name].join( - ' | ' - ) + friendlyTestDescription: ['Unit', 'Service', options.entity.name].join(' | '), }; - } + }, }); diff --git a/blueprints/service/index.js b/blueprints/service/index.js index 7fef3dd66b6..15567f6d17e 100644 --- a/blueprints/service/index.js +++ b/blueprints/service/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates a service.' + description: 'Generates a service.', }; diff --git a/blueprints/template/index.js b/blueprints/template/index.js index 3366254ecb7..d3d0ec6d874 100644 --- a/blueprints/template/index.js +++ b/blueprints/template/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates a template.' + description: 'Generates a template.', }; diff --git a/blueprints/util-test/index.js b/blueprints/util-test/index.js index 6fb39fd0403..7e9e6b7b316 100644 --- a/blueprints/util-test/index.js +++ b/blueprints/util-test/index.js @@ -9,9 +9,7 @@ module.exports = useTestFrameworkDetector({ locals: function(options) { return { friendlyTestName: ['Unit', 'Utility', options.entity.name].join(' | '), - dasherizedModulePrefix: stringUtils.dasherize( - options.project.config().modulePrefix - ) + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix), }; - } + }, }); diff --git a/blueprints/util/index.js b/blueprints/util/index.js index 04c6a362912..b35cf61b309 100644 --- a/blueprints/util/index.js +++ b/blueprints/util/index.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - description: 'Generates a simple utility module/function.' + description: 'Generates a simple utility module/function.', }; diff --git a/broccoli/babel-helpers.js b/broccoli/babel-helpers.js index 298111438d2..324e979c280 100644 --- a/broccoli/babel-helpers.js +++ b/broccoli/babel-helpers.js @@ -14,6 +14,6 @@ module.exports = function(env) { files: [file], getDestinationPath() { return 'ember-babel.js'; - } + }, }); }; diff --git a/broccoli/bootstrap-modules.js b/broccoli/bootstrap-modules.js index 2e47c2155d0..ebc88b2ca9b 100644 --- a/broccoli/bootstrap-modules.js +++ b/broccoli/bootstrap-modules.js @@ -18,7 +18,7 @@ module.exports = function bootstrapModule(moduleExport, type = 'sideeffects') { let moduleType = { default: defaultExport, umd, - sideeffects + sideeffects, }; return new WriteFile('bootstrap', moduleType[type](moduleExport)); diff --git a/broccoli/concat-bundle.js b/broccoli/concat-bundle.js index 00647068d32..315fcd820c8 100644 --- a/broccoli/concat-bundle.js +++ b/broccoli/concat-bundle.js @@ -27,6 +27,6 @@ module.exports = function(tree, options) { footerFiles: footerFiles, inputFiles: ['**/*'], annotation: outputFile, - footer: footer + '\n}());' + footer: footer + '\n}());', }); }; diff --git a/broccoli/find-package.js b/broccoli/find-package.js index b25117a7b15..e57bd9ae3c4 100644 --- a/broccoli/find-package.js +++ b/broccoli/find-package.js @@ -11,7 +11,7 @@ module.exports = function findPackage(name, from) { if (info === undefined) { let basedir = from === void 0 ? __dirname : findPackage(from).dir; let resolved = resolve.sync(name + '/package.json', { - basedir: basedir + basedir: basedir, }); info = new PackageInfo(fs.realpathSync(resolved)); cache.set(key, info); @@ -51,7 +51,7 @@ class PackageInfo { return { dir: parsed.dir, base: parsed.base, - path: resolved + path: resolved, }; } } diff --git a/broccoli/glimmer-template-compiler.js b/broccoli/glimmer-template-compiler.js index 897a6fa826a..51a7ba30473 100644 --- a/broccoli/glimmer-template-compiler.js +++ b/broccoli/glimmer-template-compiler.js @@ -26,12 +26,9 @@ GlimmerTemplatePrecompiler.prototype.baseDir = function() { return __dirname; }; -GlimmerTemplatePrecompiler.prototype.processString = function( - content, - relativePath -) { +GlimmerTemplatePrecompiler.prototype.processString = function(content, relativePath) { var compiled = this.precompile(content, { - meta: { moduleName: relativePath } + meta: { moduleName: relativePath }, }); return stripIndent` import template from '../template'; diff --git a/broccoli/minify.js b/broccoli/minify.js index 7b0a6f9636b..ab32d4d8f5f 100644 --- a/broccoli/minify.js +++ b/broccoli/minify.js @@ -11,16 +11,16 @@ module.exports = function _minify(tree) { // this is adversely affects heuristics for IIFE eval negate_iife: false, // limit sequences because of memory issues during parsing - sequences: 0 + sequences: 0, }, mangle: { - safari10: true + safari10: true, }, output: { // no difference in size and much easier to debug - semicolons: false - } - } + semicolons: false, + }, + }, }; return new Uglify(tree, options); diff --git a/broccoli/packages.js b/broccoli/packages.js index f1c706f4d75..4a357412e43 100644 --- a/broccoli/packages.js +++ b/broccoli/packages.js @@ -28,10 +28,10 @@ module.exports.routerES = function _routerES() { input: 'index.js', output: { file: 'router.js', - format: 'es' - } + format: 'es', + }, }, - annotation: 'router.js' + annotation: 'router.js', }); }; @@ -39,7 +39,7 @@ module.exports.jquery = function _jquery() { return new Funnel(findLib('jquery'), { files: ['jquery.js'], destDir: 'jquery', - annotation: 'jquery' + annotation: 'jquery', }); }; @@ -49,7 +49,7 @@ module.exports.internalLoader = function _internalLoader() { getDestinationPath() { return 'loader.js'; }, - annotation: 'internal loader' + annotation: 'internal loader', }); }; @@ -57,56 +57,44 @@ module.exports.qunit = function _qunit() { return new Funnel(findLib('qunit'), { files: ['qunit.js', 'qunit.css'], destDir: 'qunit', - annotation: 'qunit' + annotation: 'qunit', }); }; module.exports.emberTypescriptPkgES = function emberTypescriptPkg(name) { let input = new Funnel(`packages/${name}`, { - destDir: `packages/${name}` + destDir: `packages/${name}`, }); let debuggedInput = debugTree(input, `${name}:input`); - let compiledTemplatesAndTypescript = new GlimmerTemplatePrecompiler( - debuggedInput, - { - persist: true, - glimmer: require('@glimmer/compiler'), - annotation: `${name} templates -> es` - } - ); + let compiledTemplatesAndTypescript = new GlimmerTemplatePrecompiler(debuggedInput, { + persist: true, + glimmer: require('@glimmer/compiler'), + annotation: `${name} templates -> es`, + }); let debuggedCompiledTemplatesAndTypeScript = debugTree( compiledTemplatesAndTypescript, `${name}:templates-output` ); - let nonTypeScriptContents = new Funnel( - debuggedCompiledTemplatesAndTypeScript, - { - srcDir: 'packages', - exclude: ['**/*.ts'] - } - ); + let nonTypeScriptContents = new Funnel(debuggedCompiledTemplatesAndTypeScript, { + srcDir: 'packages', + exclude: ['**/*.ts'], + }); let typescriptContents = new Funnel(debuggedCompiledTemplatesAndTypeScript, { - include: ['**/*.ts'] + include: ['**/*.ts'], }); - let typescriptCompiled = typescript( - debugTree(typescriptContents, `${name}:ts:input`) - ); + let typescriptCompiled = typescript(debugTree(typescriptContents, `${name}:ts:input`)); - let debuggedCompiledTypescript = debugTree( - typescriptCompiled, - `${name}:ts:output` - ); + let debuggedCompiledTypescript = debugTree(typescriptCompiled, `${name}:ts:output`); - let mergedFinalOutput = new MergeTrees( - [nonTypeScriptContents, debuggedCompiledTypescript], - { overwrite: true } - ); + let mergedFinalOutput = new MergeTrees([nonTypeScriptContents, debuggedCompiledTypescript], { + overwrite: true, + }); return debugTree(mergedFinalOutput, `${name}:output`); }; @@ -135,15 +123,15 @@ module.exports.rollupEmberGlimmerES = function(emberGlimmerES) { 'ember-routing', 'node-module', 'rsvp', - 'container' + 'container', ], input: 'ember-glimmer/index.js', output: { file: 'ember-glimmer.js', format: 'es', - exports: 'named' - } - } + exports: 'named', + }, + }, }); }; @@ -155,10 +143,10 @@ module.exports.handlebarsES = function _handlebars() { output: { file: 'handlebars.js', format: 'es', - exports: 'named' + exports: 'named', }, - plugins: [handlebarsFix()] - } + plugins: [handlebarsFix()], + }, }); }; @@ -171,15 +159,12 @@ function handlebarsFix() { return { code: code .replace('exports.__esModule = true;', '') - .replace( - "exports['default'] = handlebars;", - 'export default handlebars;' - ), + .replace("exports['default'] = handlebars;", 'export default handlebars;'), - map: { mappings: null } + map: { mappings: null }, }; } - } + }, }; } @@ -192,23 +177,23 @@ module.exports.rsvpES = function _rsvpES() { output: { file: 'rsvp.js', format: 'es', - exports: 'named' - } - } + exports: 'named', + }, + }, }); }; module.exports.backburnerES = function _backburnerES() { return funnelLib('backburner.js', 'dist/es6', { files: ['backburner.js'], - annotation: 'backburner es' + annotation: 'backburner es', }); }; module.exports.dagES = function _dagES() { let lib = funnelLib('dag-map', { files: ['dag-map.js'], - annotation: 'dag-map es' + annotation: 'dag-map es', }); return new StringReplace(lib, { @@ -216,10 +201,10 @@ module.exports.dagES = function _dagES() { patterns: [ { match: /\/\/# sourceMappingURL=dag-map.js.map/g, - replacement: '' - } + replacement: '', + }, ], - annotation: 'remove sourcemap annotation (dag-map)' + annotation: 'remove sourcemap annotation (dag-map)', }); }; @@ -229,7 +214,7 @@ module.exports.routeRecognizerES = function _routeRecognizerES() { getDestinationPath() { return 'route-recognizer.js'; }, - annotation: 'route-recognizer es' + annotation: 'route-recognizer es', }); }; @@ -243,9 +228,9 @@ module.exports.simpleHTMLTokenizerES = function _simpleHTMLTokenizerES() { output: { file: 'simple-html-tokenizer.js', format: 'es', - exports: 'named' - } - } + exports: 'named', + }, + }, }); }; @@ -259,16 +244,16 @@ module.exports.emberPkgES = function _emberPkgES(name, rollup, externs) { output: { file: `${name}.js`, format: 'es', - exports: 'named' - } - } + exports: 'named', + }, + }, }); } return new Funnel(`packages/${name}/lib`, { exclude: ['.gitkeep', '**/*.d.ts'], destDir: name, - annotation: `${name} es` + annotation: `${name} es`, }); }; @@ -284,10 +269,10 @@ function rollupGlimmerPackage(pkg) { external: pkg.dependencies, output: { file: name + '.js', - format: 'es' - } + format: 'es', + }, }, - annotation: name + annotation: name, }); glimmerTrees.set(name, tree); } @@ -336,20 +321,20 @@ module.exports.emberTestsES = function _emberTestES(name) { return new Funnel(`packages/${name}/tests`, { exclude: ['.gitkeep'], destDir: `${name}/tests`, - annotation: `${name} tests es` + annotation: `${name} tests es`, }); }; module.exports.nodeModuleUtils = function _nodeModuleUtils() { return new Funnel('packages/node-module/lib', { - files: ['node-module.js'] + files: ['node-module.js'], }); }; module.exports.emberVersionES = function _emberVersionES() { let content = 'export default ' + JSON.stringify(VERSION) + ';\n'; return new WriteFile('ember/version.js', content, { - annotation: 'ember/version' + annotation: 'ember/version', }); }; @@ -360,14 +345,14 @@ module.exports.buildEmberEnvFlagsES = function(flags) { } return new WriteFile('ember-env-flags.js', content, { - annotation: 'ember-env-flags' + annotation: 'ember-env-flags', }); }; module.exports.emberLicense = function _emberLicense() { let license = new Funnel('generators', { files: ['license.js'], - annotation: 'license' + annotation: 'license', }); return new StringReplace(license, { @@ -375,10 +360,10 @@ module.exports.emberLicense = function _emberLicense() { patterns: [ { match: VERSION_PLACEHOLDER, - replacement: VERSION - } + replacement: VERSION, + }, ], - annotation: 'license' + annotation: 'license', }); }; @@ -393,30 +378,24 @@ module.exports.emberFeaturesES = function _emberFeaturesES(production = false) { ${Object.keys(toConst(FEATURES)) .map(FEATURE => { - return `export const ${FEATURE} = FEATURES["${FEATURE.replace( - /_/g, - '-' - ).toLowerCase()}"];`; + return `export const ${FEATURE} = FEATURES["${FEATURE.replace(/_/g, '-').toLowerCase()}"];`; }) .join('\n')} `; return new WriteFile('ember/features.js', content, { - annotation: `ember/features ${production ? 'production' : 'debug'}` + annotation: `ember/features ${production ? 'production' : 'debug'}`, }); }; module.exports.nodeTests = function _nodeTests() { return new Funnel('tests', { - include: ['**/*/*.js'] + include: ['**/*/*.js'], }); }; module.exports.rollupEmberMetal = function _rollupEmberMetal(tree, options) { - options = Object.assign( - { transformModules: false, annotation: 'ember metal' }, - options - ); + options = Object.assign({ transformModules: false, annotation: 'ember metal' }, options); let emberMetalES5 = toES5(tree, options); return toES5( new Rollup(emberMetalES5, { @@ -427,7 +406,7 @@ module.exports.rollupEmberMetal = function _rollupEmberMetal(tree, options) { amd: { id: 'ember-metal' }, file: 'ember-metal.js', format: 'amd', - exports: 'named' + exports: 'named', }, external: [ 'node-module', @@ -440,9 +419,9 @@ module.exports.rollupEmberMetal = function _rollupEmberMetal(tree, options) { 'backburner', 'ember-console', 'ember-env-flags', - 'ember/features' - ] - } + 'ember/features', + ], + }, }), { transformDefine: true } ); diff --git a/broccoli/rename.js b/broccoli/rename.js index d1f2d84a153..bd7f2bdf8f3 100644 --- a/broccoli/rename.js +++ b/broccoli/rename.js @@ -10,6 +10,6 @@ module.exports = function rename(tree, mappings) { } return relativePath; - } + }, }); }; diff --git a/broccoli/test-index-html.js b/broccoli/test-index-html.js index be7ce04ba04..649b2a63307 100644 --- a/broccoli/test-index-html.js +++ b/broccoli/test-index-html.js @@ -8,20 +8,20 @@ module.exports = function testIndexHTML() { let index = new Funnel('tests', { files: ['index.html'], destDir: 'tests', - annotation: 'tests/index.html' + annotation: 'tests/index.html', }); index = new StringReplace(index, { files: ['tests/index.html'], patterns: [ { match: /\{\{DEV_FEATURES\}\}/g, - replacement: JSON.stringify(FEATURES.DEBUG) + replacement: JSON.stringify(FEATURES.DEBUG), }, { match: /\{\{PROD_FEATURES\}\}/g, - replacement: JSON.stringify(FEATURES.RELEASE) - } - ] + replacement: JSON.stringify(FEATURES.RELEASE), + }, + ], }); index._annotation = 'tests/index.html FEATURES'; return index; diff --git a/broccoli/to-es5.js b/broccoli/to-es5.js index b101ed3e8f0..e38e6486cd4 100644 --- a/broccoli/to-es5.js +++ b/broccoli/to-es5.js @@ -11,7 +11,7 @@ const resolveModuleSource = require('amd-name-resolver').moduleResolve; module.exports = function toES5(tree, _options) { let options = Object.assign( { - environment: 'developement' + environment: 'developement', }, _options ); @@ -25,24 +25,21 @@ module.exports = function toES5(tree, _options) { { debugTools: { source: 'ember-debug', - assertPredicateIndex: 1 + assertPredicateIndex: 1, }, envFlags: { source: 'ember-env-flags', - flags: { DEBUG: options.environment !== 'production' } + flags: { DEBUG: options.environment !== 'production' }, }, features: { name: 'ember', source: 'ember/features', - flags: - options.environment === 'production' - ? toConst(RELEASE) - : toConst(DEBUG) + flags: options.environment === 'production' ? toConst(RELEASE) : toConst(DEBUG), }, externalizeHelpers: { - module: true - } - } + module: true, + }, + }, ], ['transform-es2015-template-literals', { loose: true }], ['transform-es2015-literals'], @@ -59,7 +56,7 @@ module.exports = function toES5(tree, _options) { ['transform-object-assign'], injectNodeGlobals, ['transform-es2015-modules-amd', { noInterop: true, strict: true }], - enifed + enifed, ]; if (options.transformDefine) { @@ -89,8 +86,8 @@ function stripForProd(tree) { let options = { plugins: [ [stripClassCallCheck, { source: 'ember-babel' }], - ['minify-dead-code-elimination', { optimizeRawSize: true }] - ] + ['minify-dead-code-elimination', { optimizeRawSize: true }], + ], }; return new Babel(tree, options); diff --git a/broccoli/to-named-amd.js b/broccoli/to-named-amd.js index 956b084a93a..ba11134712d 100644 --- a/broccoli/to-named-amd.js +++ b/broccoli/to-named-amd.js @@ -10,11 +10,11 @@ module.exports = function processModulesOnly(tree, annotation) { // in both browser and node-land injectNodeGlobals, ['transform-es2015-modules-amd', { loose: true, noInterop: true }], - enifed + enifed, ], moduleIds: true, resolveModuleSource, - annotation + annotation, }; return new Babel(tree, options); diff --git a/broccoli/transforms/inject-babel-helpers.js b/broccoli/transforms/inject-babel-helpers.js index ca286130bfb..4aaa99e80f0 100644 --- a/broccoli/transforms/inject-babel-helpers.js +++ b/broccoli/transforms/inject-babel-helpers.js @@ -9,7 +9,7 @@ function injectBabelHelpers() { } return file.addImport('ember-babel', name, name); }); - } + }, }; } diff --git a/broccoli/transforms/inject-node-globals.js b/broccoli/transforms/inject-node-globals.js index a0c1ffc1481..fb089b26e30 100644 --- a/broccoli/transforms/inject-node-globals.js +++ b/broccoli/transforms/inject-node-globals.js @@ -12,22 +12,16 @@ function injectNodeGlobals({ types: t }) { if (requireId || moduleId) { let specifiers = []; - let source = t.stringLiteral( - this.file.resolveModuleSource('node-module') - ); + let source = t.stringLiteral(this.file.resolveModuleSource('node-module')); if (requireId) { delete path.scope.globals.require; - specifiers.push( - t.importSpecifier(requireId, t.identifier('require')) - ); + specifiers.push(t.importSpecifier(requireId, t.identifier('require'))); } if (moduleId) { delete path.scope.globals.module; - specifiers.push( - t.importSpecifier(moduleId, t.identifier('module')) - ); + specifiers.push(t.importSpecifier(moduleId, t.identifier('module'))); } importDecl = t.importDeclaration(specifiers, source); @@ -38,14 +32,14 @@ function injectNodeGlobals({ types: t }) { if (requireId) { path.scope.rename('require'); } - } + }, }, ImportDeclaration(path) { if (path.node === importDecl) { path.scope.registerDeclaration(path); } - } - } + }, + }, }; } diff --git a/broccoli/transforms/strip-class-call-check.js b/broccoli/transforms/strip-class-call-check.js index 5949576a837..57810ed278a 100644 --- a/broccoli/transforms/strip-class-call-check.js +++ b/broccoli/transforms/strip-class-call-check.js @@ -42,7 +42,7 @@ function stripClassCallCheck({ traverse }) { this.binding.remove(); elements[this.index].remove(); } - } + }, }, CallExpression(path) { @@ -71,8 +71,8 @@ function stripClassCallCheck({ traverse }) { path.remove(); } } - } - } + }, + }, }; } diff --git a/broccoli/transforms/transform-define.js b/broccoli/transforms/transform-define.js index a5f7e674f29..166218837b0 100644 --- a/broccoli/transforms/transform-define.js +++ b/broccoli/transforms/transform-define.js @@ -16,9 +16,9 @@ function transformDefine(babel) { ) { expressionStatement.expression.callee.name = 'enifed'; } - } - } - } + }, + }, + }, }; } diff --git a/config/s3ProjectConfig.js b/config/s3ProjectConfig.js index 74f4e6b37ea..15442a1df50 100644 --- a/config/s3ProjectConfig.js +++ b/config/s3ProjectConfig.js @@ -4,14 +4,7 @@ const semver = require('semver'); function fileMap(revision, tag, date) { let filesToPublish = { - '../docs/data.json': fileObject( - 'ember-docs', - '.json', - 'application/json', - revision, - tag, - date - ) + '../docs/data.json': fileObject('ember-docs', '.json', 'application/json', revision, tag, date), }; let version = require('../package').version; @@ -23,8 +16,8 @@ function fileMap(revision, tag, date) { alpha: [`alpha/daily/${date}.tgz`, `alpha/shas/${revision}.tgz`], canary: [`canary/daily/${date}.tgz`, `canary/shas/${revision}.tgz`], beta: [`beta/daily/${date}.tgz`, `beta/shas/${revision}.tgz`], - release: [`release/daily/${date}.tgz`, `release/shas/${revision}.tgz`] - } + release: [`release/daily/${date}.tgz`, `release/shas/${revision}.tgz`], + }, }; filesToPublish['../build-metadata.json'] = { contentType: 'application/json', @@ -32,21 +25,14 @@ function fileMap(revision, tag, date) { alpha: ['alpha.json'], canary: ['canary.json'], beta: ['beta.json'], - release: ['release.json'] - } + release: ['release.json'], + }, }; return filesToPublish; } -function fileObject( - baseName, - extension, - contentType, - currentRevision, - tag, - date -) { +function fileObject(baseName, extension, contentType, currentRevision, tag, date) { var fullName = '/' + baseName + extension; var obj = { contentType: contentType, @@ -54,27 +40,27 @@ function fileObject( alpha: [ 'alpha' + fullName, 'alpha/daily/' + date + fullName, - 'alpha/shas/' + currentRevision + fullName + 'alpha/shas/' + currentRevision + fullName, ], canary: [ 'latest' + fullName, 'canary' + fullName, 'canary/daily/' + date + fullName, - 'canary/shas/' + currentRevision + fullName + 'canary/shas/' + currentRevision + fullName, ], release: [ 'stable' + fullName, 'release' + fullName, 'release/daily/' + date + fullName, - 'release/shas/' + currentRevision + fullName + 'release/shas/' + currentRevision + fullName, ], beta: [ 'beta' + fullName, 'beta/daily/' + date + fullName, - 'beta/shas/' + currentRevision + fullName + 'beta/shas/' + currentRevision + fullName, ], - wildcard: [] - } + wildcard: [], + }, }; if (tag) { diff --git a/d8-app.js b/d8-app.js index 1bb224f41ba..cfcb09a2f74 100644 --- a/d8-app.js +++ b/d8-app.js @@ -3,7 +3,7 @@ var Router = Ember.Router.extend({ location: 'none', - rootURL: '/' + rootURL: '/', }); Router.map(function() { this.route('my-route', { path: '/my-route' }, function() {}); @@ -12,17 +12,17 @@ Ember.TEMPLATES['index'] = Ember.HTMLBars.template({ id: null, block: '{"statements":[["text","index"]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}', - meta: {} + meta: {}, }); Ember.TEMPLATES['my-route/index'] = Ember.HTMLBars.template({ id: null, block: '{"statements":[["text","my-route"]],"locals":[],"named":[],"yields":[],"blocks":[],"hasPartials":false}', - meta: {} + meta: {}, }); var App = Ember.Application.extend({ Router: Router, - autoboot: false + autoboot: false, }); var app = new App(); var serializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); @@ -31,7 +31,7 @@ var options = { isBrowser: false, document: doc, rootElement: doc.body, - shouldRender: true + shouldRender: true, }; app .visit('/', options) diff --git a/d8-runner.js b/d8-runner.js index ee050800584..4d13d9820c5 100644 --- a/d8-runner.js +++ b/d8-runner.js @@ -49,7 +49,7 @@ function loadFile(file) { global.console = { log(...args) { print(...args); - } + }, }; global.setTimeout = function(callback) { diff --git a/ember-cli-build.js b/ember-cli-build.js index f13523b216d..0acac2dd27f 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -35,7 +35,7 @@ const { emberFeaturesES, nodeTests, rollupEmberMetal, - buildEmberEnvFlagsES + buildEmberEnvFlagsES, } = require('./broccoli/packages'); const SHOULD_ROLLUP = true; const ENV = process.env.EMBER_ENV || 'development'; @@ -69,22 +69,22 @@ module.exports = function() { emberPkgES('ember-utils'), emberPkgES('ember-views'), emberPkgES('ember'), - ...dependenciesES({ includeGlimmerCompiler: true }) + ...dependenciesES({ includeGlimmerCompiler: true }), ]); let es = new Funnel(combinedES, { - destDir: 'es' + destDir: 'es', }); let esMin = minify( new Funnel(combinedES, { - destDir: 'es-min' + destDir: 'es-min', }) ); let emberTestsES = buildEmberTestsES(); let pkgAndTestES = new MergeTrees([combinedES, ...emberTestsES], { - overwrite: true + overwrite: true, }); let pkgAndTestESInAMD = toNamedAMD(pkgAndTestES); @@ -95,7 +95,7 @@ module.exports = function() { { headerFiles: ['loader.js'], inputFiles: ['**/*.js'], - outputFile: 'ember-all.debug.js' + outputFile: 'ember-all.debug.js', } ); @@ -107,26 +107,24 @@ module.exports = function() { let emberDebugES5 = toES5(emberDebug, { annotation: 'ember-debug' }); let emberTemplateCompiler = emberPkgES('ember-template-compiler'); let emberTemplateCompilerES5 = toES5(emberTemplateCompiler, { - annotation: 'ember-template-compiler' + annotation: 'ember-template-compiler', }); let babelDebugHelpersES5 = toES5(babelHelpers('debug'), { - annotation: 'babel helpers debug' + annotation: 'babel helpers debug', }); let inlineParser = toES5(handlebarsES(), { annotation: 'handlebars' }); let tokenizer = toES5(simpleHTMLTokenizerES(), { annotation: 'tokenizer' }); let rsvp = toES5(rsvpES(), { annotation: 'rsvp' }); let emberMetal = new Funnel('packages/ember-metal/lib', { destDir: '/', - include: ['**/*.js'] + include: ['**/*.js'], }); let emberMetalES5 = rollupEmberMetal(emberMetal); - let emberConsole = emberPkgES('ember-console', SHOULD_ROLLUP, [ - 'ember-environment' - ]); + let emberConsole = emberPkgES('ember-console', SHOULD_ROLLUP, ['ember-environment']); let emberConsoleES5 = toES5(emberConsole, { annotation: 'ember-console' }); let emberEnvironment = emberPkgES('ember-environment', SHOULD_ROLLUP); let emberEnvironmentES5 = toES5(emberEnvironment, { - annotation: 'ember-environment' + annotation: 'ember-environment', }); let emberUtils = emberPkgES('ember-utils', SHOULD_ROLLUP); let emberUtilsES5 = toES5(emberUtils, { annotation: 'ember-utils' }); @@ -135,7 +133,7 @@ module.exports = function() { 'ember-utils', 'ember-environment', 'ember-env-flags', - 'ember/features' + 'ember/features', ]); let containerES5 = toES5(container, { annotation: 'container' }); let emberCoreES = emberES().concat(rollupEmberGlimmerES(emberGlimmerES)); @@ -153,7 +151,7 @@ module.exports = function() { loader, nodeModule, license, - babelDebugHelpersES5 + babelDebugHelpersES5, ]); let emberDebugBase = [ @@ -171,12 +169,12 @@ module.exports = function() { license, loader, nodeModule, - bootstrapModule('ember') + bootstrapModule('ember'), ]; emberTestsBundle = concatBundle(emberTestsBundle, { outputFile: 'ember-tests.js', - hasBootstrap: false + hasBootstrap: false, }); let emberDebugBundle = new MergeTrees([ @@ -184,11 +182,11 @@ module.exports = function() { emberTestingES5, babelDebugHelpersES5, inlineParser, - debugFeatures + debugFeatures, ]); emberDebugBundle = concatBundle(emberDebugBundle, { - outputFile: 'ember.debug.js' + outputFile: 'ember.debug.js', }); let emberTestingBundle = new MergeTrees([ @@ -197,7 +195,7 @@ module.exports = function() { emberTestingES5, emberDebugES5, babelDebugHelpersES5, - nodeModule + nodeModule, ]); emberTestingBundle = concatBundle(emberTestingBundle, { @@ -209,7 +207,7 @@ module.exports = function() { Ember.Test.Adapter = testing.Adapter; Ember.Test.QUnitAdapter = testing.QUnitAdapter; Ember.setupForTesting = testing.setupForTesting; - ` + `, }); function templateCompiler(babelHelpers) { @@ -228,7 +226,7 @@ module.exports = function() { tokenizer, inlineParser, babelHelpers, - bootstrapModule('ember-template-compiler', 'umd') + bootstrapModule('ember-template-compiler', 'umd'), ]; } @@ -236,14 +234,12 @@ module.exports = function() { if (ENV === 'production') { let babelProdHelpersES5 = toES5(babelHelpers('prod'), { - environment: 'production' + environment: 'production', }); let productionFeatures = toES5(emberFeaturesES(true), { - environment: 'production' + environment: 'production', }); - let emberMetalProd = stripForProd( - rollupEmberMetal(emberMetal, { environment: 'production' }) - ); + let emberMetalProd = stripForProd(rollupEmberMetal(emberMetal, { environment: 'production' })); let emberProdES5 = [ ...emberCoreES, @@ -252,7 +248,7 @@ module.exports = function() { emberUtils, emberEnvironment, emberConsole, - emberDebug + emberDebug, ].map(tree => { return stripForProd(toES5(tree, { environment: 'production' })); }); @@ -272,7 +268,7 @@ module.exports = function() { containerES5, rsvp, license, - bootstrapModule('ember-runtime', 'default') + bootstrapModule('ember-runtime', 'default'), ]); let emberProdBundle = new MergeTrees([ @@ -285,15 +281,13 @@ module.exports = function() { license, loader, nodeModule, - bootstrapModule('ember') + bootstrapModule('ember'), ]); // Note: // We have to build custom production template compiler // because we strip babel helpers in the prod build - let prodTemplateCompiler = new MergeTrees( - templateCompiler(babelProdHelpersES5) - ); + let prodTemplateCompiler = new MergeTrees(templateCompiler(babelProdHelpersES5)); prodTemplateCompiler = stripForProd(prodTemplateCompiler); @@ -302,11 +296,11 @@ module.exports = function() { prodTemplateCompiler, version, license, - loader + loader, ]); prodTemplateCompiler = concatBundle(prodTemplateCompiler, { - outputFile: 'ember-template-compiler.js' + outputFile: 'ember-template-compiler.js', }); let emberProdTestsBundle = new MergeTrees([ @@ -315,24 +309,24 @@ module.exports = function() { babelProdHelpersES5, license, loader, - nodeModule + nodeModule, ]); emberRuntimeBundle = concatBundle(emberRuntimeBundle, { - outputFile: 'ember-runtime.js' + outputFile: 'ember-runtime.js', }); emberProdBundle = concatBundle(emberProdBundle, { - outputFile: 'ember.prod.js' + outputFile: 'ember.prod.js', }); emberProdTestsBundle = concatBundle(emberProdTestsBundle, { outputFile: 'ember-tests.prod.js', - hasBootstrap: false + hasBootstrap: false, }); let emberProdMinRename = rename(emberProdBundle, { - 'ember.prod.js': 'ember.min.js' + 'ember.prod.js': 'ember.min.js', }); let emberMinBundle = minify(emberProdMinRename); @@ -353,11 +347,11 @@ module.exports = function() { version, license, loader, - nodeModule + nodeModule, ]); emberTemplateCompilerBundle = concatBundle(emberTemplateCompilerBundle, { - outputFile: 'ember-template-compiler.js' + outputFile: 'ember-template-compiler.js', }); trees.push(emberTemplateCompilerBundle); @@ -371,16 +365,12 @@ module.exports = function() { emberTestsBundle, emberDebugBundle, emberTestingBundle, - nodeTests() + nodeTests(), ]); }; function dependenciesES(options = {}) { - let glimmerEntries = [ - '@glimmer/node', - '@glimmer/opcode-compiler', - '@glimmer/runtime' - ]; + let glimmerEntries = ['@glimmer/node', '@glimmer/opcode-compiler', '@glimmer/runtime']; if (options.includeGlimmerCompiler) { glimmerEntries.push('@glimmer/compiler'); @@ -397,12 +387,7 @@ function dependenciesES(options = {}) { glimmerEntries.push('@glimmer/debug', '@glimmer/local-debug-flags'); } } - return [ - dagES(), - routerES(), - routeRecognizerES(), - ...glimmerTrees(glimmerEntries) - ]; + return [dagES(), routerES(), routeRecognizerES(), ...glimmerTrees(glimmerEntries)]; } function buildEmberTestsES() { @@ -420,7 +405,7 @@ function buildEmberTestsES() { emberPkgTestsES('ember-routing'), emberPkgTestsES('ember-utils'), emberPkgTestsES('ember-testing'), - emberPkgTestsES('internal-test-helpers') + emberPkgTestsES('internal-test-helpers'), ]; } @@ -431,7 +416,7 @@ function emberES() { emberPkgES('ember-application'), emberPkgES('ember-runtime'), emberPkgES('ember-extension-support'), - emberPkgES('ember-routing') + emberPkgES('ember-routing'), ]; } diff --git a/lib/index.js b/lib/index.js index ba26d7b13fa..5ae47411596 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,7 +12,7 @@ function add(paths, name, path) { configurable: false, get: function() { return path; - } + }, }); } @@ -63,7 +63,7 @@ module.exports = { var jquery = new Funnel(jqueryPath + '/dist', { destDir: 'ember/jquery', - files: ['jquery.js'] + files: ['jquery.js'], }); var emberFiles = [ @@ -72,7 +72,7 @@ module.exports = { 'ember-testing.js', 'ember.debug.js', 'ember.min.js', - 'ember.prod.js' + 'ember.prod.js', ] .map(function(file) { return [file, file.replace('.js', '.map')]; @@ -88,9 +88,9 @@ module.exports = { var ember = new Funnel(__dirname + '../dist', { destDir: 'ember', - files: emberFiles + files: emberFiles, }); return new MergeTrees([ember, jquery]); - } + }, }; diff --git a/lib/packages.js b/lib/packages.js index f98cd4c819e..4889c1cab4c 100644 --- a/lib/packages.js +++ b/lib/packages.js @@ -5,65 +5,55 @@ module.exports = function() { requirements: ['ember-utils'], isTypeScript: true, vendorRequirements: ['@glimmer/di'], - requiresJQuery: false + requiresJQuery: false, }, 'ember-environment': { trees: null, requirements: [], skipTests: true, - requiresJQuery: false + requiresJQuery: false, }, 'ember-utils': { trees: null, requirements: [], requiresJQuery: false }, 'ember-console': { trees: null, requirements: [], skipTests: true, - requiresJQuery: false + requiresJQuery: false, }, 'ember-metal': { trees: null, requirements: ['ember-environment', 'ember-utils'], vendorRequirements: ['backburner'], - requiresJQuery: false + requiresJQuery: false, }, 'ember-debug': { trees: null, requirements: [], requiresJQuery: false }, 'ember-runtime': { trees: null, vendorRequirements: ['rsvp'], - requirements: [ - 'container', - 'ember-environment', - 'ember-console', - 'ember-metal' - ], - requiresJQuery: false + requirements: ['container', 'ember-environment', 'ember-console', 'ember-metal'], + requiresJQuery: false, }, 'ember-views': { trees: null, requirements: ['ember-runtime'], - skipTests: true + skipTests: true, }, 'ember-extension-support': { trees: null, requirements: ['ember-application'], - requiresJQuery: false + requiresJQuery: false, }, 'ember-testing': { trees: null, requiresJQuery: false, requirements: ['ember-application', 'ember-routing'], - testing: true + testing: true, }, 'ember-template-compiler': { trees: null, templateCompilerOnly: true, requiresJQuery: false, - requirements: [ - 'container', - 'ember-metal', - 'ember-environment', - 'ember-console' - ], + requirements: ['container', 'ember-metal', 'ember-environment', 'ember-console'], templateCompilerVendor: [ 'simple-html-tokenizer', 'backburner', @@ -73,20 +63,20 @@ module.exports = function() { '@glimmer/compiler', '@glimmer/reference', '@glimmer/runtime', - 'handlebars' - ] + 'handlebars', + ], }, 'ember-routing': { trees: null, vendorRequirements: ['router', 'route-recognizer'], requirements: ['ember-runtime', 'ember-views'], - requiresJQuery: false + requiresJQuery: false, }, 'ember-application': { trees: null, vendorRequirements: ['dag-map'], requirements: ['ember-routing'], - requiresJQuery: false + requiresJQuery: false, }, ember: { trees: null, requirements: ['ember-application'] }, 'internal-test-helpers': { trees: null, requiresJQuery: false }, @@ -101,10 +91,10 @@ module.exports = function() { '@glimmer/reference', '@glimmer/util', '@glimmer/wire-format', - '@glimmer/node' + '@glimmer/node', ], - testingVendorRequirements: [] - } + testingVendorRequirements: [], + }, }; return packages; diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js index aad3c39b62f..3cbeb06441f 100644 --- a/node-tests/blueprints/acceptance-test-test.js +++ b/node-tests/blueprints/acceptance-test-test.js @@ -46,7 +46,7 @@ describe('Blueprint: acceptance-test', function() { beforeEach(function() { return modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); }); diff --git a/node-tests/blueprints/component-test-test.js b/node-tests/blueprints/component-test-test.js index c0509fd9a9e..ff7f9cf12b4 100644 --- a/node-tests/blueprints/component-test-test.js +++ b/node-tests/blueprints/component-test-test.js @@ -42,14 +42,11 @@ describe('Blueprint: component-test', function() { }); it('component-test x-foo --unit', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--unit'], - _file => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/unit.js') - ); - } - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], _file => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/unit.js') + ); + }); }); describe('with usePods=true', function() { @@ -65,9 +62,9 @@ describe('Blueprint: component-test', function() { it('component-test x-foo', function() { return emberGenerateDestroy(['component-test', 'x-foo'], _file => { - expect( - _file('tests/integration/components/x-foo/component-test.js') - ).to.equal(fixture('component-test/default.js')); + expect(_file('tests/integration/components/x-foo/component-test.js')).to.equal( + fixture('component-test/default.js') + ); }); }); }); @@ -86,14 +83,11 @@ describe('Blueprint: component-test', function() { }); it('component-test x-foo --unit', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--unit'], - _file => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/rfc232-unit.js') - ); - } - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], _file => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/rfc232-unit.js') + ); + }); }); }); @@ -101,7 +95,7 @@ describe('Blueprint: component-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); @@ -115,14 +109,11 @@ describe('Blueprint: component-test', function() { }); it('component-test x-foo --unit', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--unit'], - _file => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/mocha-unit.js') - ); - } - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], _file => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/mocha-unit.js') + ); + }); }); }); @@ -130,7 +121,7 @@ describe('Blueprint: component-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); @@ -144,14 +135,11 @@ describe('Blueprint: component-test', function() { }); it('component-test x-foo --unit', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--unit'], - _file => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/mocha-0.12-unit.js') - ); - } - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], _file => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/mocha-0.12-unit.js') + ); + }); }); }); }); @@ -175,9 +163,7 @@ describe('Blueprint: component-test', function() { throw 'the command should raise an exception'; }) .catch(error => { - expect(error).to.equal( - "The --unit flag isn't supported within a module unification app" - ); + expect(error).to.equal("The --unit flag isn't supported within a module unification app"); }); }); @@ -225,7 +211,7 @@ describe('Blueprint: component-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); @@ -250,7 +236,7 @@ describe('Blueprint: component-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); @@ -288,29 +274,23 @@ describe('Blueprint: component-test', function() { }); it('component-test x-foo --unit', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--unit'], - _file => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/unit.js') - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], _file => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/unit.js') + ); - expect(_file('app/component-test/x-foo.js')).to.not.exist; - } - ); + expect(_file('app/component-test/x-foo.js')).to.not.exist; + }); }); it('component-test x-foo --dummy', function() { - return emberGenerateDestroy( - ['component-test', 'x-foo', '--dummy'], - _file => { - expect(_file('tests/integration/components/x-foo-test.js')).to.equal( - fixture('component-test/default.js') - ); + return emberGenerateDestroy(['component-test', 'x-foo', '--dummy'], _file => { + expect(_file('tests/integration/components/x-foo-test.js')).to.equal( + fixture('component-test/default.js') + ); - expect(_file('app/component-test/x-foo.js')).to.not.exist; - } - ); + expect(_file('app/component-test/x-foo.js')).to.not.exist; + }); }); }); diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index d8252b6f170..13fa93878f0 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -25,9 +25,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/templates/components/x-foo.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/templates/components/x-foo.hbs')).to.equal('{{yield}}'); expect(_file('tests/integration/components/x-foo-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -46,9 +44,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/templates/components/foo/x-foo.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/templates/components/foo/x-foo.hbs')).to.equal('{{yield}}'); expect(_file('tests/integration/components/foo/x-foo-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -61,29 +57,22 @@ describe('Blueprint: component', function() { }); it('component x-foo --path foo', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--path', 'foo'], - _file => { - expect(_file('app/components/x-foo.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--path', 'foo'], _file => { + expect(_file('app/components/x-foo.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/templates/components/x-foo.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/templates/components/x-foo.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/components/x-foo-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('x-foo'") - .to.contain('integration: true') - .to.contain('{{x-foo}}') - .to.contain('{{#x-foo}}'); - } - ); + expect(_file('tests/integration/components/x-foo-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('x-foo'") + .to.contain('integration: true') + .to.contain('{{x-foo}}') + .to.contain('{{#x-foo}}'); + }); }); it('component x-foo --pod', function() { @@ -93,9 +82,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/components/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/components/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('tests/integration/components/x-foo/component-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -106,103 +93,79 @@ describe('Blueprint: component', function() { }); it('component foo/x-foo --pod', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod'], - _file => { - expect(_file('app/components/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod'], _file => { + expect(_file('app/components/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/components/foo/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/components/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - expect( - _file('tests/integration/components/foo/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{foo/x-foo}}') - .to.contain('{{#foo/x-foo}}'); - } - ); + expect(_file('tests/integration/components/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{foo/x-foo}}') + .to.contain('{{#foo/x-foo}}'); + }); }); it('component x-foo --pod --path bar', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '--path', 'bar'], - _file => { - expect(_file('app/bar/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], _file => { + expect(_file('app/bar/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/bar/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/bar/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/bar/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('bar/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/x-foo}}') - .to.contain('{{#bar/x-foo}}'); - } - ); + expect(_file('tests/integration/bar/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('bar/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/x-foo}}') + .to.contain('{{#bar/x-foo}}'); + }); }); it('component foo/x-foo --pod --path bar', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '--path', 'bar'], - _file => { - expect(_file('app/bar/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], _file => { + expect(_file('app/bar/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/bar/foo/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/bar/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/bar/foo/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('bar/foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/foo/x-foo}}') - .to.contain('{{#bar/foo/x-foo}}'); - } - ); + expect(_file('tests/integration/bar/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('bar/foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/foo/x-foo}}') + .to.contain('{{#bar/foo/x-foo}}'); + }); }); it('component x-foo --pod --path bar/baz', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '--path', 'bar/baz'], - _file => { - expect(_file('app/bar/baz/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], _file => { + expect(_file('app/bar/baz/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/bar/baz/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/bar/baz/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/bar/baz/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('bar/baz/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/baz/x-foo}}') - .to.contain('{{#bar/baz/x-foo}}'); - } - ); + expect(_file('tests/integration/bar/baz/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('bar/baz/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/baz/x-foo}}') + .to.contain('{{#bar/baz/x-foo}}'); + }); }); it('component foo/x-foo --pod --path bar/baz', function() { @@ -214,14 +177,10 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/bar/baz/foo/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/bar/baz/foo/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('tests/integration/bar/baz/foo/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("import hbs from 'htmlbars-inline-precompile';") .to.contain("moduleForComponent('bar/baz/foo/x-foo'") .to.contain('integration: true') @@ -232,51 +191,41 @@ describe('Blueprint: component', function() { }); it('component x-foo --pod -no-path', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '-no-path'], - _file => { - expect(_file('app/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '-no-path'], _file => { + expect(_file('app/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('x-foo'") - .to.contain('integration: true') - .to.contain('{{x-foo}}') - .to.contain('{{#x-foo}}'); - } - ); + expect(_file('tests/integration/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('x-foo'") + .to.contain('integration: true') + .to.contain('{{x-foo}}') + .to.contain('{{#x-foo}}'); + }); }); it('component foo/x-foo --pod -no-path', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '-no-path'], - _file => { - expect(_file('app/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], _file => { + expect(_file('app/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/foo/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/foo/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{foo/x-foo}}') - .to.contain('{{#foo/x-foo}}'); - } - ); + expect(_file('tests/integration/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{foo/x-foo}}') + .to.contain('{{#foo/x-foo}}'); + }); }); describe('with podModulePrefix', function() { @@ -291,16 +240,10 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/pods/components/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/pods/components/x-foo/template.hbs')).to.equal('{{yield}}'); - expect( - _file('tests/integration/pods/components/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + expect(_file('tests/integration/pods/components/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("import hbs from 'htmlbars-inline-precompile';") .to.contain("moduleForComponent('x-foo'") .to.contain('integration: true') @@ -310,114 +253,78 @@ describe('Blueprint: component', function() { }); it('component foo/x-foo --pod', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod'], - _file => { - expect(_file('app/pods/components/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod'], _file => { + expect(_file('app/pods/components/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect( - _file('app/pods/components/foo/x-foo/template.hbs') - ).to.equal('{{yield}}'); - - expect( - _file( - 'tests/integration/pods/components/foo/x-foo/component-test.js' - ) - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{foo/x-foo}}') - .to.contain('{{#foo/x-foo}}'); - } - ); + expect(_file('app/pods/components/foo/x-foo/template.hbs')).to.equal('{{yield}}'); + + expect(_file('tests/integration/pods/components/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{foo/x-foo}}') + .to.contain('{{#foo/x-foo}}'); + }); }); it('component x-foo --pod --path bar', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '--path', 'bar'], - _file => { - expect(_file('app/pods/bar/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], _file => { + expect(_file('app/pods/bar/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/pods/bar/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/pods/bar/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/pods/bar/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('bar/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/x-foo}}') - .to.contain('{{#bar/x-foo}}'); - } - ); + expect(_file('tests/integration/pods/bar/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('bar/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/x-foo}}') + .to.contain('{{#bar/x-foo}}'); + }); }); it('component foo/x-foo --pod --path bar', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '--path', 'bar'], - _file => { - expect(_file('app/pods/bar/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], _file => { + expect(_file('app/pods/bar/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/pods/bar/foo/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); - - expect( - _file('tests/integration/pods/bar/foo/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("moduleForComponent('bar/foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/foo/x-foo}}') - .to.contain('{{#bar/foo/x-foo}}'); - } - ); + expect(_file('app/pods/bar/foo/x-foo/template.hbs')).to.equal('{{yield}}'); + + expect(_file('tests/integration/pods/bar/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("moduleForComponent('bar/foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/foo/x-foo}}') + .to.contain('{{#bar/foo/x-foo}}'); + }); }); it('component x-foo --pod --path bar/baz', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '--path', 'bar/baz'], - _file => { - expect(_file('app/pods/bar/baz/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], _file => { + expect(_file('app/pods/bar/baz/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/pods/bar/baz/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/pods/bar/baz/x-foo/template.hbs')).to.equal('{{yield}}'); - expect( - _file('tests/integration/pods/bar/baz/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('bar/baz/x-foo'") - .to.contain('integration: true') - .to.contain('{{bar/baz/x-foo}}') - .to.contain('{{#bar/baz/x-foo}}'); - } - ); + expect(_file('tests/integration/pods/bar/baz/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('bar/baz/x-foo'") + .to.contain('integration: true') + .to.contain('{{bar/baz/x-foo}}') + .to.contain('{{#bar/baz/x-foo}}'); + }); }); it('component foo/x-foo --pod --path bar/baz', function() { @@ -429,18 +336,10 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('app/pods/bar/baz/foo/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); - - expect( - _file( - 'tests/integration/pods/bar/baz/foo/x-foo/component-test.js' - ) - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + expect(_file('app/pods/bar/baz/foo/x-foo/template.hbs')).to.equal('{{yield}}'); + + expect(_file('tests/integration/pods/bar/baz/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("import hbs from 'htmlbars-inline-precompile';") .to.contain("moduleForComponent('bar/baz/foo/x-foo'") .to.contain('integration: true') @@ -451,53 +350,41 @@ describe('Blueprint: component', function() { }); it('component x-foo --pod -no-path', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '-no-path'], - _file => { - expect(_file('app/pods/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--pod', '-no-path'], _file => { + expect(_file('app/pods/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/pods/x-foo/template.hbs')).to.equal('{{yield}}'); + expect(_file('app/pods/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/pods/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('x-foo'") - .to.contain('integration: true') - .to.contain('{{x-foo}}') - .to.contain('{{#x-foo}}'); - } - ); + expect(_file('tests/integration/pods/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('x-foo'") + .to.contain('integration: true') + .to.contain('{{x-foo}}') + .to.contain('{{#x-foo}}'); + }); }); it('component foo/x-foo --pod -no-path', function() { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '-no-path'], - _file => { - expect(_file('app/pods/foo/x-foo/component.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], _file => { + expect(_file('app/pods/foo/x-foo/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect(_file('app/pods/foo/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('app/pods/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/pods/foo/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('foo/x-foo'") - .to.contain('integration: true') - .to.contain('{{foo/x-foo}}') - .to.contain('{{#foo/x-foo}}'); - } - ); + expect(_file('tests/integration/pods/foo/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('foo/x-foo'") + .to.contain('integration: true') + .to.contain('{{foo/x-foo}}') + .to.contain('{{#foo/x-foo}}'); + }); }); }); }); @@ -514,9 +401,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('src/ui/components/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('src/ui/components/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('src/ui/components/x-foo/component-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -535,9 +420,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('src/ui/components/x-foo/x-bar/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('src/ui/components/x-foo/x-bar/template.hbs')).to.equal('{{yield}}'); expect(_file('src/ui/components/x-foo/x-bar/component-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -564,9 +447,7 @@ describe('Blueprint: component', function() { .to.contain('layout') .to.contain('});'); - expect(_file('addon/templates/components/x-foo.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('addon/templates/components/x-foo.hbs')).to.equal('{{yield}}'); expect(_file('app/components/x-foo.js')).to.contain( "export { default } from 'my-addon/components/x-foo';" @@ -586,16 +467,12 @@ describe('Blueprint: component', function() { return emberGenerateDestroy(['component', 'nested/x-foo'], _file => { expect(_file('addon/components/nested/x-foo.js')) .to.contain("import Component from '@ember/component';") - .to.contain( - "import layout from '../../templates/components/nested/x-foo';" - ) + .to.contain("import layout from '../../templates/components/nested/x-foo';") .to.contain('export default Component.extend({') .to.contain('layout') .to.contain('});'); - expect(_file('addon/templates/components/nested/x-foo.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('addon/templates/components/nested/x-foo.hbs')).to.equal('{{yield}}'); expect(_file('app/components/nested/x-foo.js')).to.contain( "export { default } from 'my-addon/components/nested/x-foo';" @@ -618,9 +495,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect( - _file('tests/dummy/app/templates/components/x-foo.hbs') - ).to.equal('{{yield}}'); + expect(_file('tests/dummy/app/templates/components/x-foo.hbs')).to.equal('{{yield}}'); expect(_file('app/components/x-foo.js')).to.not.exist; @@ -629,24 +504,20 @@ describe('Blueprint: component', function() { }); it('component nested/x-foo --dummy', function() { - return emberGenerateDestroy( - ['component', 'nested/x-foo', '--dummy'], - _file => { - expect(_file('tests/dummy/app/components/nested/x-foo.js')) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'nested/x-foo', '--dummy'], _file => { + expect(_file('tests/dummy/app/components/nested/x-foo.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect( - _file('tests/dummy/app/templates/components/nested/x-foo.hbs') - ).to.equal('{{yield}}'); + expect(_file('tests/dummy/app/templates/components/nested/x-foo.hbs')).to.equal( + '{{yield}}' + ); - expect(_file('app/components/nested/x-foo.js')).to.not.exist; + expect(_file('app/components/nested/x-foo.js')).to.not.exist; - expect(_file('tests/unit/components/nested/x-foo-test.js')).to.not - .exist; - } - ); + expect(_file('tests/unit/components/nested/x-foo-test.js')).to.not.exist; + }); }); it('component x-foo --pod', function() { @@ -658,9 +529,7 @@ describe('Blueprint: component', function() { .to.contain('layout') .to.contain('});'); - expect(_file('addon/components/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('addon/components/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('app/components/x-foo/component.js')).to.contain( "export { default } from 'my-addon/components/x-foo/component';" @@ -686,9 +555,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('src/ui/components/x-foo/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('src/ui/components/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('src/ui/components/x-foo/component-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -708,9 +575,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect(_file('src/ui/components/x-foo/x-bar/template.hbs')).to.equal( - '{{yield}}' - ); + expect(_file('src/ui/components/x-foo/x-bar/template.hbs')).to.equal('{{yield}}'); expect(_file('src/ui/components/x-foo/x-bar/component-test.js')) .to.contain("import { moduleForComponent, test } from 'ember-qunit';") @@ -730,9 +595,7 @@ describe('Blueprint: component', function() { .to.contain('export default Component.extend({') .to.contain('});'); - expect( - _file('tests/dummy/src/ui/components/x-foo/template.hbs') - ).to.equal('{{yield}}'); + expect(_file('tests/dummy/src/ui/components/x-foo/template.hbs')).to.equal('{{yield}}'); expect(_file('src/ui/components/x-foo/component.js')).to.not.exist; @@ -741,27 +604,20 @@ describe('Blueprint: component', function() { }); it('component nested/x-foo --dummy', function() { - return emberGenerateDestroy( - ['component', 'x-foo/x-bar', '--dummy'], - _file => { - expect( - _file('tests/dummy/src/ui/components/x-foo/x-bar/component.js') - ) - .to.contain("import Component from '@ember/component';") - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo/x-bar', '--dummy'], _file => { + expect(_file('tests/dummy/src/ui/components/x-foo/x-bar/component.js')) + .to.contain("import Component from '@ember/component';") + .to.contain('export default Component.extend({') + .to.contain('});'); - expect( - _file('tests/dummy/src/ui/components/x-foo/x-bar/template.hbs') - ).to.equal('{{yield}}'); + expect(_file('tests/dummy/src/ui/components/x-foo/x-bar/template.hbs')).to.equal( + '{{yield}}' + ); - expect(_file('src/ui/components/x-foo/x-bar/component.js')).to.not - .exist; + expect(_file('src/ui/components/x-foo/x-bar/component.js')).to.not.exist; - expect(_file('src/ui/components/x-foo/x-bar/component-test.js')).to - .not.exist; - } - ); + expect(_file('src/ui/components/x-foo/x-bar/component-test.js')).to.not.exist; + }); }); }); @@ -771,35 +627,28 @@ describe('Blueprint: component', function() { }); it('component x-foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/components/x-foo.js')) - .to.contain("import Component from '@ember/component';") - .to.contain("import layout from '../templates/components/x-foo';") - .to.contain('export default Component.extend({') - .to.contain('layout') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/components/x-foo.js')) + .to.contain("import Component from '@ember/component';") + .to.contain("import layout from '../templates/components/x-foo';") + .to.contain('export default Component.extend({') + .to.contain('layout') + .to.contain('});'); - expect( - _file('lib/my-addon/addon/templates/components/x-foo.hbs') - ).to.equal('{{yield}}'); + expect(_file('lib/my-addon/addon/templates/components/x-foo.hbs')).to.equal('{{yield}}'); - expect(_file('lib/my-addon/app/components/x-foo.js')).to.contain( - "export { default } from 'my-addon/components/x-foo';" - ); + expect(_file('lib/my-addon/app/components/x-foo.js')).to.contain( + "export { default } from 'my-addon/components/x-foo';" + ); - expect(_file('tests/integration/components/x-foo-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('x-foo'") - .to.contain('integration: true') - .to.contain('{{x-foo}}') - .to.contain('{{#x-foo}}'); - } - ); + expect(_file('tests/integration/components/x-foo-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('x-foo'") + .to.contain('integration: true') + .to.contain('{{x-foo}}') + .to.contain('{{#x-foo}}'); + }); }); it('component nested/x-foo --in-repo-addon=my-addon', function() { @@ -808,27 +657,21 @@ describe('Blueprint: component', function() { _file => { expect(_file('lib/my-addon/addon/components/nested/x-foo.js')) .to.contain("import Component from '@ember/component';") - .to.contain( - "import layout from '../../templates/components/nested/x-foo';" - ) + .to.contain("import layout from '../../templates/components/nested/x-foo';") .to.contain('export default Component.extend({') .to.contain('layout') .to.contain('});'); - expect( - _file('lib/my-addon/addon/templates/components/nested/x-foo.hbs') - ).to.equal('{{yield}}'); + expect(_file('lib/my-addon/addon/templates/components/nested/x-foo.hbs')).to.equal( + '{{yield}}' + ); - expect( - _file('lib/my-addon/app/components/nested/x-foo.js') - ).to.contain( + expect(_file('lib/my-addon/app/components/nested/x-foo.js')).to.contain( "export { default } from 'my-addon/components/nested/x-foo';" ); expect(_file('tests/integration/components/nested/x-foo-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("import hbs from 'htmlbars-inline-precompile';") .to.contain("moduleForComponent('nested/x-foo'") .to.contain('integration: true'); @@ -847,20 +690,14 @@ describe('Blueprint: component', function() { .to.contain('layout') .to.contain('});'); - expect( - _file('lib/my-addon/addon/components/x-foo/template.hbs') - ).to.equal('{{yield}}'); + expect(_file('lib/my-addon/addon/components/x-foo/template.hbs')).to.equal('{{yield}}'); - expect( - _file('lib/my-addon/app/components/x-foo/component.js') - ).to.contain( + expect(_file('lib/my-addon/app/components/x-foo/component.js')).to.contain( "export { default } from 'my-addon/components/x-foo/component';" ); expect(_file('tests/integration/components/x-foo/component-test.js')) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("moduleForComponent('x-foo'") .to.contain('integration: true'); } @@ -871,31 +708,23 @@ describe('Blueprint: component', function() { return emberGenerateDestroy( ['component', 'nested/x-foo', '--in-repo-addon=my-addon', '--pod'], _file => { - expect( - _file('lib/my-addon/addon/components/nested/x-foo/component.js') - ) + expect(_file('lib/my-addon/addon/components/nested/x-foo/component.js')) .to.contain("import Component from '@ember/component';") .to.contain("import layout from './template';") .to.contain('export default Component.extend({') .to.contain('layout') .to.contain('});'); - expect( - _file('lib/my-addon/addon/components/nested/x-foo/template.hbs') - ).to.equal('{{yield}}'); + expect(_file('lib/my-addon/addon/components/nested/x-foo/template.hbs')).to.equal( + '{{yield}}' + ); - expect( - _file('lib/my-addon/app/components/nested/x-foo/component.js') - ).to.contain( + expect(_file('lib/my-addon/app/components/nested/x-foo/component.js')).to.contain( "export { default } from 'my-addon/components/nested/x-foo/component';" ); - expect( - _file('tests/integration/components/nested/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) + expect(_file('tests/integration/components/nested/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") .to.contain("moduleForComponent('nested/x-foo'") .to.contain('integration: true'); } @@ -905,38 +734,27 @@ describe('Blueprint: component', function() { describe('in in-repo-addon - module unification', function() { beforeEach(function() { - return emberNew({ target: 'in-repo-addon' }).then(() => - fs.ensureDirSync('src') - ); + return emberNew({ target: 'in-repo-addon' }).then(() => fs.ensureDirSync('src')); }); it('component x-foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['component', 'x-foo', '--in-repo-addon=my-addon'], - _file => { - expect( - _file('packages/my-addon/src/ui/components/x-foo/component.js') - ) - .to.contain('export default Component.extend({') - .to.contain('});'); + return emberGenerateDestroy(['component', 'x-foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('packages/my-addon/src/ui/components/x-foo/component.js')) + .to.contain('export default Component.extend({') + .to.contain('});'); - expect( - _file('packages/my-addon/src/ui/components/x-foo/template.hbs') - ).to.equal('{{yield}}'); + expect(_file('packages/my-addon/src/ui/components/x-foo/template.hbs')).to.equal( + '{{yield}}' + ); - expect( - _file('packages/my-addon/src/ui/components/x-foo/component-test.js') - ) - .to.contain( - "import { moduleForComponent, test } from 'ember-qunit';" - ) - .to.contain("import hbs from 'htmlbars-inline-precompile';") - .to.contain("moduleForComponent('my-addon::x-foo'") - .to.contain('integration: true') - .to.contain('{{#my-addon::x-foo}}') - .to.contain('{{my-addon::x-foo}}'); - } - ); + expect(_file('packages/my-addon/src/ui/components/x-foo/component-test.js')) + .to.contain("import { moduleForComponent, test } from 'ember-qunit';") + .to.contain("import hbs from 'htmlbars-inline-precompile';") + .to.contain("moduleForComponent('my-addon::x-foo'") + .to.contain('integration: true') + .to.contain('{{#my-addon::x-foo}}') + .to.contain('{{my-addon::x-foo}}'); + }); }); }); }); diff --git a/node-tests/blueprints/controller-test-test.js b/node-tests/blueprints/controller-test-test.js index e32b9d75e18..ad4f4c73f6b 100644 --- a/node-tests/blueprints/controller-test-test.js +++ b/node-tests/blueprints/controller-test-test.js @@ -46,7 +46,7 @@ describe('Blueprint: controller-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); @@ -64,7 +64,7 @@ describe('Blueprint: controller-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); diff --git a/node-tests/blueprints/controller-test.js b/node-tests/blueprints/controller-test.js index d7474de4cdd..cff787cabbc 100644 --- a/node-tests/blueprints/controller-test.js +++ b/node-tests/blueprints/controller-test.js @@ -83,18 +83,15 @@ describe('Blueprint: controller', function() { }); it('controller foo/bar --pod podModulePrefix', function() { - return emberGenerateDestroy( - ['controller', 'foo/bar', '--pod'], - _file => { - expect(_file('app/pods/foo/bar/controller.js')) - .to.contain("import Controller from '@ember/controller';") - .to.contain('export default Controller.extend({\n});'); - - expect(_file('tests/unit/pods/foo/bar/controller-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('controller:foo/bar'"); - } - ); + return emberGenerateDestroy(['controller', 'foo/bar', '--pod'], _file => { + expect(_file('app/pods/foo/bar/controller.js')) + .to.contain("import Controller from '@ember/controller';") + .to.contain('export default Controller.extend({\n});'); + + expect(_file('tests/unit/pods/foo/bar/controller-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('controller:foo/bar'"); + }); }); }); }); @@ -149,18 +146,15 @@ describe('Blueprint: controller', function() { }); it('controller foo/bar --dummy', function() { - return emberGenerateDestroy( - ['controller', 'foo/bar', '--dummy'], - _file => { - expect(_file('tests/dummy/app/controllers/foo/bar.js')) - .to.contain("import Controller from '@ember/controller';") - .to.contain('export default Controller.extend({\n});'); + return emberGenerateDestroy(['controller', 'foo/bar', '--dummy'], _file => { + expect(_file('tests/dummy/app/controllers/foo/bar.js')) + .to.contain("import Controller from '@ember/controller';") + .to.contain('export default Controller.extend({\n});'); - expect(_file('app/controllers/foo/bar.js')).to.not.exist; + expect(_file('app/controllers/foo/bar.js')).to.not.exist; - expect(_file('tests/unit/controllers/foo/bar-test.js')).to.not.exist; - } - ); + expect(_file('tests/unit/controllers/foo/bar-test.js')).to.not.exist; + }); }); }); @@ -170,41 +164,35 @@ describe('Blueprint: controller', function() { }); it('controller foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['controller', 'foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/controllers/foo.js')) - .to.contain("import Controller from '@ember/controller';") - .to.contain('export default Controller.extend({\n});'); + return emberGenerateDestroy(['controller', 'foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/controllers/foo.js')) + .to.contain("import Controller from '@ember/controller';") + .to.contain('export default Controller.extend({\n});'); - expect(_file('lib/my-addon/app/controllers/foo.js')).to.contain( - "export { default } from 'my-addon/controllers/foo';" - ); + expect(_file('lib/my-addon/app/controllers/foo.js')).to.contain( + "export { default } from 'my-addon/controllers/foo';" + ); - expect(_file('tests/unit/controllers/foo-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('controller:foo'"); - } - ); + expect(_file('tests/unit/controllers/foo-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('controller:foo'"); + }); }); it('controller foo/bar --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['controller', 'foo/bar', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/controllers/foo/bar.js')) - .to.contain("import Controller from '@ember/controller';") - .to.contain('export default Controller.extend({\n});'); + return emberGenerateDestroy(['controller', 'foo/bar', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/controllers/foo/bar.js')) + .to.contain("import Controller from '@ember/controller';") + .to.contain('export default Controller.extend({\n});'); - expect(_file('lib/my-addon/app/controllers/foo/bar.js')).to.contain( - "export { default } from 'my-addon/controllers/foo/bar';" - ); + expect(_file('lib/my-addon/app/controllers/foo/bar.js')).to.contain( + "export { default } from 'my-addon/controllers/foo/bar';" + ); - expect(_file('tests/unit/controllers/foo/bar-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('controller:foo/bar'"); - } - ); + expect(_file('tests/unit/controllers/foo/bar-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('controller:foo/bar'"); + }); }); }); }); diff --git a/node-tests/blueprints/helper-addon-test.js b/node-tests/blueprints/helper-addon-test.js index 4a0b9a13805..9d79ef6e890 100644 --- a/node-tests/blueprints/helper-addon-test.js +++ b/node-tests/blueprints/helper-addon-test.js @@ -20,21 +20,14 @@ describe('Blueprint: helper-addon', function() { it('helper-addon foo/bar-baz', function() { return emberGenerateDestroy(['helper-addon', 'foo/bar-baz'], _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper-addon.js') - ); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper-addon.js')); }); }); it('helper-addon foo/bar-baz --pod', function() { - return emberGenerateDestroy( - ['helper-addon', 'foo/bar-baz', '--pod'], - _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper-addon.js') - ); - } - ); + return emberGenerateDestroy(['helper-addon', 'foo/bar-baz', '--pod'], _file => { + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper-addon.js')); + }); }); }); }); diff --git a/node-tests/blueprints/helper-test-test.js b/node-tests/blueprints/helper-test-test.js index 03c72805142..16a6dc4e6df 100644 --- a/node-tests/blueprints/helper-test-test.js +++ b/node-tests/blueprints/helper-test-test.js @@ -29,14 +29,11 @@ describe('Blueprint: helper-test', function() { }); it('helper-test foo/bar-baz --integration', function() { - return emberGenerateDestroy( - ['helper-test', 'foo/bar-baz', '--integration'], - _file => { - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/integration.js')); - } - ); + return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--integration'], _file => { + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/integration.js') + ); + }); }); describe('with ember-cli-qunit@4.2.0', function() { @@ -46,21 +43,18 @@ describe('Blueprint: helper-test', function() { it('helper-test foo/bar-baz', function() { return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], _file => { - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/rfc232.js')); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/rfc232.js') + ); }); }); it('helper-test foo/bar-baz --unit', function() { - return emberGenerateDestroy( - ['helper-test', 'foo/bar-baz', '--unit'], - _file => { - expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( - fixture('helper-test/rfc232-unit.js') - ); - } - ); + return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], _file => { + expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/rfc232-unit.js') + ); + }); }); }); @@ -68,28 +62,25 @@ describe('Blueprint: helper-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); it('helper-test foo/bar-baz --integration', function() { return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], _file => { - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/mocha.js')); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/mocha.js') + ); }); }); it('helper-test foo/bar-baz --unit', function() { - return emberGenerateDestroy( - ['helper-test', 'foo/bar-baz', '--unit'], - _file => { - expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( - fixture('helper-test/mocha-unit.js') - ); - } - ); + return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], _file => { + expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/mocha-unit.js') + ); + }); }); }); @@ -97,28 +88,25 @@ describe('Blueprint: helper-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); it('helper-test foo/bar-baz for mocha', function() { return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], _file => { - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/mocha-0.12.js')); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/mocha-0.12.js') + ); }); }); it('helper-test foo/bar-baz for mocha --unit', function() { - return emberGenerateDestroy( - ['helper-test', 'foo/bar-baz', '--unit'], - _file => { - expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( - fixture('helper-test/mocha-0.12-unit.js') - ); - } - ); + return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], _file => { + expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/mocha-0.12-unit.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/helper-test.js b/node-tests/blueprints/helper-test.js index ec12fdc6fee..1b020034eed 100644 --- a/node-tests/blueprints/helper-test.js +++ b/node-tests/blueprints/helper-test.js @@ -21,9 +21,7 @@ describe('Blueprint: helper', function() { it('helper foo/bar-baz', function() { return emberGenerateDestroy(['helper', 'foo/bar-baz'], _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( fixture('helper-test/integration.js') ); @@ -31,24 +29,17 @@ describe('Blueprint: helper', function() { }); it('helper foo/bar-baz unit', function() { - return emberGenerateDestroy( - ['helper', '--test-type=unit', 'foo/bar-baz'], - _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( - fixture('helper-test/unit.js') - ); - } - ); + return emberGenerateDestroy(['helper', '--test-type=unit', 'foo/bar-baz'], _file => { + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/unit.js') + ); + }); }); it('helper foo/bar-baz --pod', function() { return emberGenerateDestroy(['helper', 'foo/bar-baz', '--pod'], _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( fixture('helper-test/integration.js') ); @@ -57,9 +48,7 @@ describe('Blueprint: helper', function() { it('helper foo/bar-baz --pod', function() { return emberGenerateDestroy(['helper', 'foo/bar-baz', '--pod'], _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( fixture('helper-test/integration.js') ); @@ -72,31 +61,21 @@ describe('Blueprint: helper', function() { }); it('helper foo/bar-baz --pod', function() { - return emberGenerateDestroy( - ['helper', 'foo/bar-baz', '--pod'], - _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/integration.js')); - } - ); + return emberGenerateDestroy(['helper', 'foo/bar-baz', '--pod'], _file => { + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/integration.js') + ); + }); }); it('helper foo/bar-baz --pod', function() { - return emberGenerateDestroy( - ['helper', 'foo/bar-baz', '--pod'], - _file => { - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/integration.js')); - } - ); + return emberGenerateDestroy(['helper', 'foo/bar-baz', '--pod'], _file => { + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/integration.js') + ); + }); }); }); }); @@ -108,12 +87,8 @@ describe('Blueprint: helper', function() { it('helper foo/bar-baz', function() { return emberGenerateDestroy(['helper', 'foo/bar-baz'], _file => { - expect(_file('addon/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper-addon.js') - ); + expect(_file('addon/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper-addon.js')); expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( fixture('helper-test/integration.js') ); @@ -122,12 +97,8 @@ describe('Blueprint: helper', function() { it('helper foo/bar-baz', function() { return emberGenerateDestroy(['helper', 'foo/bar-baz'], _file => { - expect(_file('addon/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect(_file('app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper-addon.js') - ); + expect(_file('addon/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('app/helpers/foo/bar-baz.js')).to.equal(fixture('helper-addon.js')); expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( fixture('helper-test/integration.js') ); @@ -135,17 +106,11 @@ describe('Blueprint: helper', function() { }); it('helper foo/bar-baz --dummy', function() { - return emberGenerateDestroy( - ['helper', 'foo/bar-baz', '--dummy'], - _file => { - expect(_file('tests/dummy/app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect(_file('app/helpers/foo/bar-baz.js')).to.not.exist; - expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.not - .exist; - } - ); + return emberGenerateDestroy(['helper', 'foo/bar-baz', '--dummy'], _file => { + expect(_file('tests/dummy/app/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('app/helpers/foo/bar-baz.js')).to.not.exist; + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.not.exist; + }); }); }); @@ -155,20 +120,15 @@ describe('Blueprint: helper', function() { }); it('helper foo/bar-baz --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/helpers/foo/bar-baz.js')).to.equal( - fixture('helper.js') - ); - expect(_file('lib/my-addon/app/helpers/foo/bar-baz.js')).to.equal( - fixture('helper-addon.js') - ); - expect( - _file('tests/integration/helpers/foo/bar-baz-test.js') - ).to.equal(fixture('helper-test/integration.js')); - } - ); + return emberGenerateDestroy(['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/helpers/foo/bar-baz.js')).to.equal(fixture('helper.js')); + expect(_file('lib/my-addon/app/helpers/foo/bar-baz.js')).to.equal( + fixture('helper-addon.js') + ); + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/integration.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/initializer-addon-test.js b/node-tests/blueprints/initializer-addon-test.js index 07e1d95c939..5f12c6dff66 100644 --- a/node-tests/blueprints/initializer-addon-test.js +++ b/node-tests/blueprints/initializer-addon-test.js @@ -25,14 +25,11 @@ describe('Blueprint: initializer-addon', function() { }); it('initializer-addon foo --pod', function() { - return emberGenerateDestroy( - ['initializer-addon', 'foo', '--pod'], - _file => { - expect(_file('app/initializers/foo.js')).to.contain( - "export { default, initialize } from 'my-addon/initializers/foo';" - ); - } - ); + return emberGenerateDestroy(['initializer-addon', 'foo', '--pod'], _file => { + expect(_file('app/initializers/foo.js')).to.contain( + "export { default, initialize } from 'my-addon/initializers/foo';" + ); + }); }); }); }); diff --git a/node-tests/blueprints/initializer-test-test.js b/node-tests/blueprints/initializer-test-test.js index bd12e00139a..e718fe2a267 100644 --- a/node-tests/blueprints/initializer-test-test.js +++ b/node-tests/blueprints/initializer-test-test.js @@ -46,7 +46,7 @@ describe('Blueprint: initializer-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); }); diff --git a/node-tests/blueprints/initializer-test.js b/node-tests/blueprints/initializer-test.js index d72afff73d8..70c0170c66b 100644 --- a/node-tests/blueprints/initializer-test.js +++ b/node-tests/blueprints/initializer-test.js @@ -68,20 +68,17 @@ describe('Blueprint: initializer', function() { }); it('initializer foo/bar --pod', function() { - return emberGenerateDestroy( - ['initializer', 'foo/bar', '--pod'], - _file => { - expect(_file('app/initializers/foo/bar.js')).to.contain( - 'export function initialize(/* application */) {\n' + - " // application.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); - } - ); + return emberGenerateDestroy(['initializer', 'foo/bar', '--pod'], _file => { + expect(_file('app/initializers/foo/bar.js')).to.contain( + 'export function initialize(/* application */) {\n' + + " // application.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); + }); }); describe('with podModulePrefix', function() { @@ -104,20 +101,17 @@ describe('Blueprint: initializer', function() { }); it('initializer foo/bar --pod', function() { - return emberGenerateDestroy( - ['initializer', 'foo/bar', '--pod'], - _file => { - expect(_file('app/initializers/foo/bar.js')).to.contain( - 'export function initialize(/* application */) {\n' + - " // application.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); - } - ); + return emberGenerateDestroy(['initializer', 'foo/bar', '--pod'], _file => { + expect(_file('app/initializers/foo/bar.js')).to.contain( + 'export function initialize(/* application */) {\n' + + " // application.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); + }); }); }); }); @@ -186,24 +180,21 @@ describe('Blueprint: initializer', function() { }); it('initializer foo/bar --dummy', function() { - return emberGenerateDestroy( - ['initializer', 'foo/bar', '--dummy'], - _file => { - expect(_file('tests/dummy/app/initializers/foo/bar.js')).to.contain( - 'export function initialize(/* application */) {\n' + - " // application.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['initializer', 'foo/bar', '--dummy'], _file => { + expect(_file('tests/dummy/app/initializers/foo/bar.js')).to.contain( + 'export function initialize(/* application */) {\n' + + " // application.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('app/initializers/foo/bar.js')).to.not.exist; + expect(_file('app/initializers/foo/bar.js')).to.not.exist; - expect(_file('tests/unit/initializers/foo/bar-test.js')).to.not.exist; - } - ); + expect(_file('tests/unit/initializers/foo/bar-test.js')).to.not.exist; + }); }); it('initializer-test foo', function() { @@ -223,51 +214,43 @@ describe('Blueprint: initializer', function() { }); it('initializer foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['initializer', 'foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/initializers/foo.js')).to.contain( - 'export function initialize(/* application */) {\n' + - " // application.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['initializer', 'foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/initializers/foo.js')).to.contain( + 'export function initialize(/* application */) {\n' + + " // application.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('lib/my-addon/app/initializers/foo.js')).to.contain( - "export { default, initialize } from 'my-addon/initializers/foo';" - ); + expect(_file('lib/my-addon/app/initializers/foo.js')).to.contain( + "export { default, initialize } from 'my-addon/initializers/foo';" + ); - expect(_file('tests/unit/initializers/foo-test.js')).to.exist; - } - ); + expect(_file('tests/unit/initializers/foo-test.js')).to.exist; + }); }); it('initializer foo/bar --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['initializer', 'foo/bar', '--in-repo-addon=my-addon'], - _file => { - expect( - _file('lib/my-addon/addon/initializers/foo/bar.js') - ).to.contain( - 'export function initialize(/* application */) {\n' + - " // application.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['initializer', 'foo/bar', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/initializers/foo/bar.js')).to.contain( + 'export function initialize(/* application */) {\n' + + " // application.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('lib/my-addon/app/initializers/foo/bar.js')).to.contain( - "export { default, initialize } from 'my-addon/initializers/foo/bar';" - ); + expect(_file('lib/my-addon/app/initializers/foo/bar.js')).to.contain( + "export { default, initialize } from 'my-addon/initializers/foo/bar';" + ); - expect(_file('tests/unit/initializers/foo/bar-test.js')).to.exist; - } - ); + expect(_file('tests/unit/initializers/foo/bar-test.js')).to.exist; + }); }); }); }); diff --git a/node-tests/blueprints/instance-initializer-addon-test.js b/node-tests/blueprints/instance-initializer-addon-test.js index f32a8484852..0c341ddb92b 100644 --- a/node-tests/blueprints/instance-initializer-addon-test.js +++ b/node-tests/blueprints/instance-initializer-addon-test.js @@ -17,25 +17,19 @@ describe('Blueprint: instance-initializer-addon', function() { }); it('instance-initializer-addon foo', function() { - return emberGenerateDestroy( - ['instance-initializer-addon', 'foo'], - _file => { - expect(_file('app/instance-initializers/foo.js')).to.contain( - "export { default, initialize } from 'my-addon/instance-initializers/foo';" - ); - } - ); + return emberGenerateDestroy(['instance-initializer-addon', 'foo'], _file => { + expect(_file('app/instance-initializers/foo.js')).to.contain( + "export { default, initialize } from 'my-addon/instance-initializers/foo';" + ); + }); }); it('instance-initializer-addon foo --pod', function() { - return emberGenerateDestroy( - ['instance-initializer-addon', 'foo', '--pod'], - _file => { - expect(_file('app/instance-initializers/foo.js')).to.contain( - "export { default, initialize } from 'my-addon/instance-initializers/foo';" - ); - } - ); + return emberGenerateDestroy(['instance-initializer-addon', 'foo', '--pod'], _file => { + expect(_file('app/instance-initializers/foo.js')).to.contain( + "export { default, initialize } from 'my-addon/instance-initializers/foo';" + ); + }); }); }); }); diff --git a/node-tests/blueprints/instance-initializer-test-test.js b/node-tests/blueprints/instance-initializer-test-test.js index da3d5f5d013..72f2f9a1158 100644 --- a/node-tests/blueprints/instance-initializer-test-test.js +++ b/node-tests/blueprints/instance-initializer-test-test.js @@ -21,14 +21,11 @@ describe('Blueprint: instance-initializer-test', function() { }); it('instance-initializer-test foo', function() { - return emberGenerateDestroy( - ['instance-initializer-test', 'foo'], - _file => { - expect( - _file('tests/unit/instance-initializers/foo-test.js') - ).to.equal(fixture('instance-initializer-test/default.js')); - } - ); + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/default.js') + ); + }); }); describe('with ember-cli-qunit@4.2.0', function() { @@ -37,14 +34,11 @@ describe('Blueprint: instance-initializer-test', function() { }); it('instance-initializer-test foo', function() { - return emberGenerateDestroy( - ['instance-initializer-test', 'foo'], - _file => { - expect( - _file('tests/unit/instance-initializers/foo-test.js') - ).to.equal(fixture('instance-initializer-test/rfc232.js')); - } - ); + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/rfc232.js') + ); + }); }); }); @@ -52,19 +46,16 @@ describe('Blueprint: instance-initializer-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); }); it('instance-initializer-test foo for mocha', function() { - return emberGenerateDestroy( - ['instance-initializer-test', 'foo'], - _file => { - expect( - _file('tests/unit/instance-initializers/foo-test.js') - ).to.equal(fixture('instance-initializer-test/mocha.js')); - } - ); + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/mocha.js') + ); + }); }); }); }); @@ -75,14 +66,11 @@ describe('Blueprint: instance-initializer-test', function() { }); it('instance-initializer-test foo', function() { - return emberGenerateDestroy( - ['instance-initializer-test', 'foo'], - _file => { - expect( - _file('tests/unit/instance-initializers/foo-test.js') - ).to.equal(fixture('instance-initializer-test/dummy.js')); - } - ); + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/dummy.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/instance-initializer-test.js b/node-tests/blueprints/instance-initializer-test.js index 44deab80e17..0f19628ff46 100644 --- a/node-tests/blueprints/instance-initializer-test.js +++ b/node-tests/blueprints/instance-initializer-test.js @@ -29,41 +29,65 @@ describe('Blueprint: instance-initializer', function() { '};' ); - expect( - _file('tests/unit/instance-initializers/foo-test.js') - ).to.contain( + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.contain( "import { initialize } from 'my-app/instance-initializers/foo';" ); }); }); it('instance-initializer foo/bar', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo/bar'], - _file => { - expect(_file('app/instance-initializers/foo/bar.js')).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['instance-initializer', 'foo/bar'], _file => { + expect(_file('app/instance-initializers/foo/bar.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect( - _file('tests/unit/instance-initializers/foo/bar-test.js') - ).to.contain( - "import { initialize } from 'my-app/instance-initializers/foo/bar';" - ); - } - ); + expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to.contain( + "import { initialize } from 'my-app/instance-initializers/foo/bar';" + ); + }); }); it('instance-initializer foo --pod', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo', '--pod'], - _file => { + return emberGenerateDestroy(['instance-initializer', 'foo', '--pod'], _file => { + expect(_file('app/instance-initializers/foo.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); + }); + }); + + it('instance-initializer foo/bar --pod', function() { + return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--pod'], _file => { + expect(_file('app/instance-initializers/foo/bar.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); + }); + }); + + describe('with podModulePrefix', function() { + beforeEach(function() { + setupPodConfig({ podModulePrefix: true }); + }); + + it('instance-initializer foo --pod', function() { + return emberGenerateDestroy(['instance-initializer', 'foo', '--pod'], _file => { expect(_file('app/instance-initializers/foo.js')).to.contain( 'export function initialize(/* appInstance */) {\n' + " // appInstance.inject('route', 'foo', 'service:foo');\n" + @@ -73,14 +97,11 @@ describe('Blueprint: instance-initializer', function() { ' initialize\n' + '};' ); - } - ); - }); + }); + }); - it('instance-initializer foo/bar --pod', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo/bar', '--pod'], - _file => { + it('instance-initializer foo/bar --pod', function() { + return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--pod'], _file => { expect(_file('app/instance-initializers/foo/bar.js')).to.contain( 'export function initialize(/* appInstance */) {\n' + " // appInstance.inject('route', 'foo', 'service:foo');\n" + @@ -90,47 +111,7 @@ describe('Blueprint: instance-initializer', function() { ' initialize\n' + '};' ); - } - ); - }); - - describe('with podModulePrefix', function() { - beforeEach(function() { - setupPodConfig({ podModulePrefix: true }); - }); - - it('instance-initializer foo --pod', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo', '--pod'], - _file => { - expect(_file('app/instance-initializers/foo.js')).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); - } - ); - }); - - it('instance-initializer foo/bar --pod', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo/bar', '--pod'], - _file => { - expect(_file('app/instance-initializers/foo/bar.js')).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); - } - ); + }); }); }); }); @@ -161,74 +142,59 @@ describe('Blueprint: instance-initializer', function() { }); it('instance-initializer foo/bar', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo/bar'], - _file => { - expect(_file('addon/instance-initializers/foo/bar.js')).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['instance-initializer', 'foo/bar'], _file => { + expect(_file('addon/instance-initializers/foo/bar.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('app/instance-initializers/foo/bar.js')).to.contain( - "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';" - ); + expect(_file('app/instance-initializers/foo/bar.js')).to.contain( + "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';" + ); - expect(_file('tests/unit/instance-initializers/foo/bar-test.js')); - } - ); + expect(_file('tests/unit/instance-initializers/foo/bar-test.js')); + }); }); it('instance-initializer foo --dummy', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo', '--dummy'], - _file => { - expect( - _file('tests/dummy/app/instance-initializers/foo.js') - ).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['instance-initializer', 'foo', '--dummy'], _file => { + expect(_file('tests/dummy/app/instance-initializers/foo.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('app/instance-initializers/foo.js')).to.not.exist; + expect(_file('app/instance-initializers/foo.js')).to.not.exist; - expect(_file('tests/unit/instance-initializers/foo-test.js')).to.not - .exist; - } - ); + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.not.exist; + }); }); it('instance-initializer foo/bar --dummy', function() { - return emberGenerateDestroy( - ['instance-initializer', 'foo/bar', '--dummy'], - _file => { - expect( - _file('tests/dummy/app/instance-initializers/foo/bar.js') - ).to.contain( - 'export function initialize(/* appInstance */) {\n' + - " // appInstance.inject('route', 'foo', 'service:foo');\n" + - '}\n' + - '\n' + - 'export default {\n' + - ' initialize\n' + - '};' - ); + return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--dummy'], _file => { + expect(_file('tests/dummy/app/instance-initializers/foo/bar.js')).to.contain( + 'export function initialize(/* appInstance */) {\n' + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + '}\n' + + '\n' + + 'export default {\n' + + ' initialize\n' + + '};' + ); - expect(_file('app/instance-initializers/foo/bar.js')).to.not.exist; + expect(_file('app/instance-initializers/foo/bar.js')).to.not.exist; - expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to - .not.exist; - } - ); + expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to.not.exist; + }); }); }); @@ -241,9 +207,7 @@ describe('Blueprint: instance-initializer', function() { return emberGenerateDestroy( ['instance-initializer', 'foo', '--in-repo-addon=my-addon'], _file => { - expect( - _file('lib/my-addon/addon/instance-initializers/foo.js') - ).to.contain( + expect(_file('lib/my-addon/addon/instance-initializers/foo.js')).to.contain( 'export function initialize(/* appInstance */) {\n' + " // appInstance.inject('route', 'foo', 'service:foo');\n" + '}\n' + @@ -253,14 +217,11 @@ describe('Blueprint: instance-initializer', function() { '};' ); - expect( - _file('lib/my-addon/app/instance-initializers/foo.js') - ).to.contain( + expect(_file('lib/my-addon/app/instance-initializers/foo.js')).to.contain( "export { default, initialize } from 'my-addon/instance-initializers/foo';" ); - expect(_file('tests/unit/instance-initializers/foo-test.js')).to - .exist; + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.exist; } ); }); @@ -269,9 +230,7 @@ describe('Blueprint: instance-initializer', function() { return emberGenerateDestroy( ['instance-initializer', 'foo/bar', '--in-repo-addon=my-addon'], _file => { - expect( - _file('lib/my-addon/addon/instance-initializers/foo/bar.js') - ).to.contain( + expect(_file('lib/my-addon/addon/instance-initializers/foo/bar.js')).to.contain( 'export function initialize(/* appInstance */) {\n' + " // appInstance.inject('route', 'foo', 'service:foo');\n" + '}\n' + @@ -281,14 +240,11 @@ describe('Blueprint: instance-initializer', function() { '};' ); - expect( - _file('lib/my-addon/app/instance-initializers/foo/bar.js') - ).to.contain( + expect(_file('lib/my-addon/app/instance-initializers/foo/bar.js')).to.contain( "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';" ); - expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to - .exist; + expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to.exist; } ); }); diff --git a/node-tests/blueprints/mixin-test-test.js b/node-tests/blueprints/mixin-test-test.js index 82dc66f1dcf..f0709126e4d 100644 --- a/node-tests/blueprints/mixin-test-test.js +++ b/node-tests/blueprints/mixin-test-test.js @@ -22,9 +22,7 @@ describe('Blueprint: mixin-test', function() { it('mixin-test foo', function() { return emberGenerateDestroy(['mixin-test', 'foo'], _file => { - expect(_file('tests/unit/mixins/foo-test.js')).to.equal( - fixture('mixin-test/default.js') - ); + expect(_file('tests/unit/mixins/foo-test.js')).to.equal(fixture('mixin-test/default.js')); }); }); @@ -32,15 +30,13 @@ describe('Blueprint: mixin-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); }); it('mixin-test foo', function() { return emberGenerateDestroy(['mixin-test', 'foo'], _file => { - expect(_file('tests/unit/mixins/foo-test.js')).to.equal( - fixture('mixin-test/mocha.js') - ); + expect(_file('tests/unit/mixins/foo-test.js')).to.equal(fixture('mixin-test/mocha.js')); }); }); }); @@ -52,9 +48,7 @@ describe('Blueprint: mixin-test', function() { it('mixin-test foo', function() { return emberGenerateDestroy(['mixin-test', 'foo'], _file => { - expect(_file('tests/unit/mixins/foo-test.js')).to.equal( - fixture('mixin-test/rfc232.js') - ); + expect(_file('tests/unit/mixins/foo-test.js')).to.equal(fixture('mixin-test/rfc232.js')); }); }); }); @@ -67,9 +61,7 @@ describe('Blueprint: mixin-test', function() { it('mixin-test foo', function() { return emberGenerateDestroy(['mixin-test', 'foo'], _file => { - expect(_file('tests/unit/mixins/foo-test.js')).to.equal( - fixture('mixin-test/addon.js') - ); + expect(_file('tests/unit/mixins/foo-test.js')).to.equal(fixture('mixin-test/addon.js')); }); }); }); diff --git a/node-tests/blueprints/mixin-test.js b/node-tests/blueprints/mixin-test.js index 4f5a887d4f8..3ee6e976871 100644 --- a/node-tests/blueprints/mixin-test.js +++ b/node-tests/blueprints/mixin-test.js @@ -166,44 +166,35 @@ describe('Blueprint: mixin', function() { }); it('mixin foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['mixin', 'foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/mixins/foo.js')) - .to.contain("import Mixin from '@ember/object/mixin';") - .to.contain('export default Mixin.create({\n});'); + return emberGenerateDestroy(['mixin', 'foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/mixins/foo.js')) + .to.contain("import Mixin from '@ember/object/mixin';") + .to.contain('export default Mixin.create({\n});'); - expect(_file('tests/unit/mixins/foo-test.js')).to.contain( - "import FooMixin from 'my-addon/mixins/foo';" - ); - } - ); + expect(_file('tests/unit/mixins/foo-test.js')).to.contain( + "import FooMixin from 'my-addon/mixins/foo';" + ); + }); }); it('mixin foo/bar --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['mixin', 'foo/bar', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/mixins/foo/bar.js')) - .to.contain("import Mixin from '@ember/object/mixin';") - .to.contain('export default Mixin.create({\n});'); + return emberGenerateDestroy(['mixin', 'foo/bar', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/mixins/foo/bar.js')) + .to.contain("import Mixin from '@ember/object/mixin';") + .to.contain('export default Mixin.create({\n});'); - expect(_file('tests/unit/mixins/foo/bar-test.js')).to.contain( - "import FooBarMixin from 'my-addon/mixins/foo/bar';" - ); - } - ); + expect(_file('tests/unit/mixins/foo/bar-test.js')).to.contain( + "import FooBarMixin from 'my-addon/mixins/foo/bar';" + ); + }); }); it('mixin foo/bar/baz --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'], - _file => { - expect(_file('tests/unit/mixins/foo/bar/baz-test.js')).to.contain( - "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" - ); - } - ); + return emberGenerateDestroy(['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'], _file => { + expect(_file('tests/unit/mixins/foo/bar/baz-test.js')).to.contain( + "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" + ); + }); }); }); }); diff --git a/node-tests/blueprints/route-test-test.js b/node-tests/blueprints/route-test-test.js index e316ac08c86..85fe41591dd 100644 --- a/node-tests/blueprints/route-test-test.js +++ b/node-tests/blueprints/route-test-test.js @@ -22,9 +22,7 @@ describe('Blueprint: route-test', function() { it('route-test foo', function() { return emberGenerateDestroy(['route-test', 'foo'], _file => { - expect(_file('tests/unit/routes/foo-test.js')).to.equal( - fixture('route-test/default.js') - ); + expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/default.js')); }); }); @@ -35,9 +33,7 @@ describe('Blueprint: route-test', function() { it('route-test foo', function() { return emberGenerateDestroy(['route-test', 'foo'], _file => { - expect(_file('tests/unit/routes/foo-test.js')).to.equal( - fixture('route-test/rfc232.js') - ); + expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/rfc232.js')); }); }); }); @@ -46,16 +42,14 @@ describe('Blueprint: route-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); it('route-test foo', function() { return emberGenerateDestroy(['route-test', 'foo'], _file => { - expect(_file('tests/unit/routes/foo-test.js')).to.equal( - fixture('route-test/mocha.js') - ); + expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/mocha.js')); }); }); }); @@ -64,7 +58,7 @@ describe('Blueprint: route-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); @@ -86,9 +80,7 @@ describe('Blueprint: route-test', function() { it('route-test foo', function() { return emberGenerateDestroy(['route-test', 'foo'], _file => { - expect(_file('tests/unit/routes/foo-test.js')).to.equal( - fixture('route-test/default.js') - ); + expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/default.js')); }); }); }); diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js index e96c2476a90..b999d35227b 100644 --- a/node-tests/blueprints/route-test.js +++ b/node-tests/blueprints/route-test.js @@ -51,25 +51,22 @@ describe('Blueprint: route', function() { }); it('route foo --path=:foo_id/show', function() { - return emberGenerateDestroy( - ['route', 'foo', '--path=:foo_id/show'], - _file => { - expect(_file('app/routes/foo.js')) - .to.contain("import Route from '@ember/routing/route';") - .to.contain('export default Route.extend({\n});'); + return emberGenerateDestroy(['route', 'foo', '--path=:foo_id/show'], _file => { + expect(_file('app/routes/foo.js')) + .to.contain("import Route from '@ember/routing/route';") + .to.contain('export default Route.extend({\n});'); - expect(_file('app/templates/foo.hbs')).to.equal('{{outlet}}'); + expect(_file('app/templates/foo.hbs')).to.equal('{{outlet}}'); - expect(_file('tests/unit/routes/foo-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('route:foo'"); + expect(_file('tests/unit/routes/foo-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('route:foo'"); - expect(file('app/router.js')) - .to.contain("this.route('foo', {") - .to.contain("path: ':foo_id/show'") - .to.contain('});'); - } - ).then(() => { + expect(file('app/router.js')) + .to.contain("this.route('foo', {") + .to.contain("path: ':foo_id/show'") + .to.contain('});'); + }).then(() => { expect(file('app/router.js')) .to.not.contain("this.route('foo'") .to.not.contain("path: ':foo_id/show'"); @@ -77,26 +74,23 @@ describe('Blueprint: route', function() { }); it('route parent/child --reset-namespace', function() { - return emberGenerateDestroy( - ['route', 'parent/child', '--reset-namespace'], - _file => { - expect(_file('app/routes/child.js')) - .to.contain("import Route from '@ember/routing/route';") - .to.contain('export default Route.extend({\n});'); + return emberGenerateDestroy(['route', 'parent/child', '--reset-namespace'], _file => { + expect(_file('app/routes/child.js')) + .to.contain("import Route from '@ember/routing/route';") + .to.contain('export default Route.extend({\n});'); - expect(_file('app/templates/child.hbs')).to.equal('{{outlet}}'); + expect(_file('app/templates/child.hbs')).to.equal('{{outlet}}'); - expect(_file('tests/unit/routes/child-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('route:child'"); + expect(_file('tests/unit/routes/child-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('route:child'"); - expect(file('app/router.js')) - .to.contain("this.route('parent', {") - .to.contain("this.route('child', {") - .to.contain('resetNamespace: true') - .to.contain('});'); - } - ); + expect(file('app/router.js')) + .to.contain("this.route('parent', {") + .to.contain("this.route('child', {") + .to.contain('resetNamespace: true') + .to.contain('});'); + }); }); it('route parent/child --reset-namespace --pod', function() { @@ -136,9 +130,7 @@ describe('Blueprint: route', function() { it('route application', function() { fs.removeSync('app/templates/application.hbs'); return emberGenerate(['route', 'application']).then(() => { - expect(file('app/router.js')).to.not.contain( - "this.route('application')" - ); + expect(file('app/router.js')).to.not.contain("this.route('application')"); }); }); @@ -178,9 +170,7 @@ describe('Blueprint: route', function() { .to.contain('});') ) - .then(() => - emberDestroy(['route', 'foo', '--pod', '--path=:foo_id/show']) - ) + .then(() => emberDestroy(['route', 'foo', '--pod', '--path=:foo_id/show'])) .then(() => expect(file('app/router.js')) .to.not.contain("this.route('foo', {") @@ -198,11 +188,7 @@ describe('Blueprint: route', function() { return emberGenerate(['route', 'application', '--pod']) .then(() => expect(file('app/application/route.js')).to.exist) .then(() => expect(file('app/application/template.hbs')).to.exist) - .then(() => - expect(file('app/router.js')).to.not.contain( - "this.route('application')" - ) - ); + .then(() => expect(file('app/router.js')).to.not.contain("this.route('application')")); }); it('route basic --pod', function() { @@ -262,13 +248,9 @@ describe('Blueprint: route', function() { .to.contain("import { moduleFor, test } from 'ember-qunit';") .to.contain("moduleFor('route:foo'"); - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('foo')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('foo')"); }).then(() => { - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('foo')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('foo')"); }); }); @@ -292,13 +274,9 @@ describe('Blueprint: route', function() { .to.contain("import { moduleFor, test } from 'ember-qunit';") .to.contain("moduleFor('route:foo/bar'"); - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('bar')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('bar')"); }).then(() => { - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('bar')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('bar')"); }); }); @@ -308,21 +286,15 @@ describe('Blueprint: route', function() { .to.contain("import Route from '@ember/routing/route';") .to.contain('export default Route.extend({\n});'); - expect(_file('tests/dummy/app/templates/foo.hbs')).to.equal( - '{{outlet}}' - ); + expect(_file('tests/dummy/app/templates/foo.hbs')).to.equal('{{outlet}}'); expect(_file('app/routes/foo.js')).to.not.exist; expect(_file('app/templates/foo.hbs')).to.not.exist; expect(_file('tests/unit/routes/foo-test.js')).to.not.exist; - expect(file('tests/dummy/app/router.js')).to.contain( - "this.route('foo')" - ); + expect(file('tests/dummy/app/router.js')).to.contain("this.route('foo')"); }).then(() => { - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('foo')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('foo')"); }); }); @@ -332,9 +304,7 @@ describe('Blueprint: route', function() { .to.contain("import Route from '@ember/routing/route';") .to.contain('export default Route.extend({\n});'); - expect(_file('tests/dummy/app/templates/foo/bar.hbs')).to.equal( - '{{outlet}}' - ); + expect(_file('tests/dummy/app/templates/foo/bar.hbs')).to.equal('{{outlet}}'); expect(_file('app/routes/foo/bar.js')).to.not.exist; expect(_file('app/templates/foo/bar.hbs')).to.not.exist; @@ -344,9 +314,7 @@ describe('Blueprint: route', function() { .to.contain("this.route('foo', function() {") .to.contain("this.route('bar')"); }).then(() => { - expect(file('tests/dummy/app/router.js')).to.not.contain( - "this.route('bar')" - ); + expect(file('tests/dummy/app/router.js')).to.not.contain("this.route('bar')"); }); }); @@ -379,57 +347,47 @@ describe('Blueprint: route', function() { }); it('route foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['route', 'foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/routes/foo.js')) - .to.contain("import Route from '@ember/routing/route';") - .to.contain('export default Route.extend({\n});'); + return emberGenerateDestroy(['route', 'foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/routes/foo.js')) + .to.contain("import Route from '@ember/routing/route';") + .to.contain('export default Route.extend({\n});'); - expect(_file('lib/my-addon/addon/templates/foo.hbs')).to.equal( - '{{outlet}}' - ); + expect(_file('lib/my-addon/addon/templates/foo.hbs')).to.equal('{{outlet}}'); - expect(_file('lib/my-addon/app/routes/foo.js')).to.contain( - "export { default } from 'my-addon/routes/foo';" - ); + expect(_file('lib/my-addon/app/routes/foo.js')).to.contain( + "export { default } from 'my-addon/routes/foo';" + ); - expect(_file('lib/my-addon/app/templates/foo.js')).to.contain( - "export { default } from 'my-addon/templates/foo';" - ); + expect(_file('lib/my-addon/app/templates/foo.js')).to.contain( + "export { default } from 'my-addon/templates/foo';" + ); - expect(_file('tests/unit/routes/foo-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('route:foo'"); - } - ); + expect(_file('tests/unit/routes/foo-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('route:foo'"); + }); }); it('route foo/bar --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['route', 'foo/bar', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/routes/foo/bar.js')) - .to.contain("import Route from '@ember/routing/route';") - .to.contain('export default Route.extend({\n});'); + return emberGenerateDestroy(['route', 'foo/bar', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/routes/foo/bar.js')) + .to.contain("import Route from '@ember/routing/route';") + .to.contain('export default Route.extend({\n});'); - expect(_file('lib/my-addon/addon/templates/foo/bar.hbs')).to.equal( - '{{outlet}}' - ); + expect(_file('lib/my-addon/addon/templates/foo/bar.hbs')).to.equal('{{outlet}}'); - expect(_file('lib/my-addon/app/routes/foo/bar.js')).to.contain( - "export { default } from 'my-addon/routes/foo/bar';" - ); + expect(_file('lib/my-addon/app/routes/foo/bar.js')).to.contain( + "export { default } from 'my-addon/routes/foo/bar';" + ); - expect(_file('lib/my-addon/app/templates/foo/bar.js')).to.contain( - "export { default } from 'my-addon/templates/foo/bar';" - ); + expect(_file('lib/my-addon/app/templates/foo/bar.js')).to.contain( + "export { default } from 'my-addon/templates/foo/bar';" + ); - expect(_file('tests/unit/routes/foo/bar-test.js')) - .to.contain("import { moduleFor, test } from 'ember-qunit';") - .to.contain("moduleFor('route:foo/bar'"); - } - ); + expect(_file('tests/unit/routes/foo/bar-test.js')) + .to.contain("import { moduleFor, test } from 'ember-qunit';") + .to.contain("moduleFor('route:foo/bar'"); + }); }); }); }); diff --git a/node-tests/blueprints/service-test-test.js b/node-tests/blueprints/service-test-test.js index 8f8386ebabd..333d6647959 100644 --- a/node-tests/blueprints/service-test-test.js +++ b/node-tests/blueprints/service-test-test.js @@ -32,7 +32,7 @@ describe('Blueprint: service-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.11.0'); }); @@ -58,7 +58,7 @@ describe('Blueprint: service-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); generateFakePackageManifest('ember-cli-mocha', '0.12.0'); }); diff --git a/node-tests/blueprints/template-test.js b/node-tests/blueprints/template-test.js index 4bc62023bcc..35bd971efec 100644 --- a/node-tests/blueprints/template-test.js +++ b/node-tests/blueprints/template-test.js @@ -51,7 +51,7 @@ describe('Blueprint: template', function() { beforeEach(function() { setupPodConfig({ usePods: true, - podModulePrefix: true + podModulePrefix: true, }); }); @@ -105,23 +105,15 @@ describe('Blueprint: template', function() { }); it('template foo --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['template', 'foo', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/templates/foo.hbs')).to.equal(''); - } - ); + return emberGenerateDestroy(['template', 'foo', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/templates/foo.hbs')).to.equal(''); + }); }); it('template foo/bar --in-repo-addon=my-addon', function() { - return emberGenerateDestroy( - ['template', 'foo/bar', '--in-repo-addon=my-addon'], - _file => { - expect(_file('lib/my-addon/addon/templates/foo/bar.hbs')).to.equal( - '' - ); - } - ); + return emberGenerateDestroy(['template', 'foo/bar', '--in-repo-addon=my-addon'], _file => { + expect(_file('lib/my-addon/addon/templates/foo/bar.hbs')).to.equal(''); + }); }); }); }); diff --git a/node-tests/blueprints/util-test-test.js b/node-tests/blueprints/util-test-test.js index 538e1a5fe90..d29f7a04eb3 100644 --- a/node-tests/blueprints/util-test-test.js +++ b/node-tests/blueprints/util-test-test.js @@ -22,9 +22,7 @@ describe('Blueprint: util-test', function() { it('util-test foo-bar', function() { return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { - expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal( - fixture('util-test/default.js') - ); + expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js')); }); }); @@ -46,15 +44,13 @@ describe('Blueprint: util-test', function() { beforeEach(function() { modifyPackages([ { name: 'ember-cli-qunit', delete: true }, - { name: 'ember-cli-mocha', dev: true } + { name: 'ember-cli-mocha', dev: true }, ]); }); it('util-test foo-bar', function() { return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { - expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal( - fixture('util-test/mocha.js') - ); + expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/mocha.js')); }); }); }); @@ -67,9 +63,7 @@ describe('Blueprint: util-test', function() { it('util-test foo-bar', function() { return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { - expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal( - fixture('util-test/dummy.js') - ); + expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js')); }); }); }); diff --git a/node-tests/helpers/generate-fake-package-manifest.js b/node-tests/helpers/generate-fake-package-manifest.js index 5705ecfb96d..ca16d36cc44 100644 --- a/node-tests/helpers/generate-fake-package-manifest.js +++ b/node-tests/helpers/generate-fake-package-manifest.js @@ -10,7 +10,7 @@ module.exports = function generateFakePackageManifest(name, version) { fs.writeFileSync( 'node_modules/' + name + '/package.json', JSON.stringify({ - version: version + version: version, }) ); }; diff --git a/node-tests/nodetest-runner.js b/node-tests/nodetest-runner.js index c005afc929c..1b4031b49d8 100644 --- a/node-tests/nodetest-runner.js +++ b/node-tests/nodetest-runner.js @@ -5,7 +5,7 @@ var Mocha = require('mocha'); var mocha = new Mocha({ timeout: 5000, - reporter: 'spec' + reporter: 'spec', }); mocha.files = glob.sync('node-tests/{blueprints,acceptance,unit}/**/*-test.js'); diff --git a/packages/container/lib/container.js b/packages/container/lib/container.js index e09276931db..ca1afa36a31 100644 --- a/packages/container/lib/container.js +++ b/packages/container/lib/container.js @@ -2,13 +2,7 @@ import { assert } from 'ember-debug'; import { EMBER_MODULE_UNIFICATION } from 'ember/features'; import { DEBUG } from 'ember-env-flags'; -import { - dictionary, - setOwner, - OWNER, - assign, - HAS_NATIVE_PROXY -} from 'ember-utils'; +import { dictionary, setOwner, OWNER, assign, HAS_NATIVE_PROXY } from 'ember-utils'; /** A container used to instantiate and cache objects. @@ -88,10 +82,7 @@ export default class Container { @return {any} */ lookup(fullName, options) { - assert( - 'fullName must be a proper full name', - this.registry.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.registry.isValidFullName(fullName)); return lookup(this, this.registry.normalize(fullName), options); } @@ -147,10 +138,7 @@ export default class Container { factoryFor(fullName, options = {}) { let normalizedName = this.registry.normalize(fullName); - assert( - 'fullName must be a proper full name', - this.registry.isValidFullName(normalizedName) - ); + assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName)); assert( 'EMBER_MODULE_UNIFICATION must be enabled to pass a namespace option to factoryFor', EMBER_MODULE_UNIFICATION || !options.namespace @@ -177,7 +165,7 @@ function wrapManagerInDeprecationProxy(manager) { throw new Error( `You attempted to set "${prop}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.` ); - } + }, }; // Note: @@ -188,7 +176,7 @@ function wrapManagerInDeprecationProxy(manager) { class: m.class, create(props) { return m.create(props); - } + }, }; let proxy = new Proxy(proxiedManager, validator); @@ -248,12 +236,7 @@ function factoryFor(container, normalizedName, fullName) { factory._onLookup(fullName); // What should this pass? fullname or the normalized key? } - let manager = new FactoryManager( - container, - factory, - fullName, - normalizedName - ); + let manager = new FactoryManager(container, factory, fullName, normalizedName); if (DEBUG) { manager = wrapManagerInDeprecationProxy(manager); @@ -354,7 +337,7 @@ function processInjections(container, injections, result) { function buildInjections(container, typeInjections, injections) { let result = { injections: undefined, - isDyanmic: false + isDyanmic: false, }; if (typeInjections !== undefined) { @@ -427,10 +410,7 @@ class FactoryManager { toString() { if (this.madeToString === undefined) { - this.madeToString = this.container.registry.makeToString( - this.class, - this.fullName - ); + this.madeToString = this.container.registry.makeToString(this.class, this.fullName); } return this.madeToString; @@ -439,10 +419,7 @@ class FactoryManager { create(options) { let injectionsCache = this.injections; if (injectionsCache === undefined) { - let { injections, isDynamic } = injectionsFor( - this.container, - this.normalizedName - ); + let { injections, isDynamic } = injectionsFor(this.container, this.normalizedName); injectionsCache = injections; if (!isDynamic) { this.injections = injections; @@ -464,9 +441,7 @@ class FactoryManager { typeof this.class._lazyInjections === 'function' ) { lazyInjections = this.class._lazyInjections(); - lazyInjections = this.container.registry.normalizeInjectionsHash( - lazyInjections - ); + lazyInjections = this.container.registry.normalizeInjectionsHash(lazyInjections); this.container.registry.validateInjections(lazyInjections); } @@ -478,8 +453,7 @@ class FactoryManager { throw new Error( `Failed to create an instance of '${ this.normalizedName - }'. Most likely an improperly defined class or` + - ` an invalid module export.` + }'. Most likely an improperly defined class or` + ` an invalid module export.` ); } diff --git a/packages/container/lib/registry.js b/packages/container/lib/registry.js index cff11459cb0..b3fcb033f6a 100644 --- a/packages/container/lib/registry.js +++ b/packages/container/lib/registry.js @@ -27,16 +27,10 @@ export default class Registry { this.resolver = options.resolver || null; if (ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT !== true) { - assert( - missingResolverFunctionsDeprecation, - typeof this.resolver !== 'function' - ); + assert(missingResolverFunctionsDeprecation, typeof this.resolver !== 'function'); } - if ( - typeof this.resolver === 'function' && - ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT === true - ) { + if (typeof this.resolver === 'function' && ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT === true) { deprecateResolverFunction(this); } @@ -150,14 +144,8 @@ export default class Registry { @param {Object} options */ register(fullName, factory, options = {}) { - assert( - 'fullName must be a proper full name', - this.isValidFullName(fullName) - ); - assert( - `Attempting to register an unknown factory: '${fullName}'`, - factory !== undefined - ); + assert('fullName must be a proper full name', this.isValidFullName(fullName)); + assert(`Attempting to register an unknown factory: '${fullName}'`, factory !== undefined); let normalizedName = this.normalize(fullName); assert( @@ -188,10 +176,7 @@ export default class Registry { @param {String} fullName */ unregister(fullName) { - assert( - 'fullName must be a proper full name', - this.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.isValidFullName(fullName)); let normalizedName = this.normalize(fullName); @@ -458,19 +443,12 @@ export default class Registry { @param {String} fullName */ typeInjection(type, property, fullName) { - assert( - 'fullName must be a proper full name', - this.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.isValidFullName(fullName)); let fullNameType = fullName.split(':')[0]; - assert( - `Cannot inject a '${fullName}' on other ${type}(s).`, - fullNameType !== type - ); + assert(`Cannot inject a '${fullName}' on other ${type}(s).`, fullNameType !== type); - let injections = - this._typeInjections[type] || (this._typeInjections[type] = []); + let injections = this._typeInjections[type] || (this._typeInjections[type] = []); injections.push({ property, specifier: fullName }); } @@ -533,15 +511,10 @@ export default class Registry { return this.typeInjection(fullName, property, normalizedInjectionName); } - assert( - 'fullName must be a proper full name', - this.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.isValidFullName(fullName)); let normalizedName = this.normalize(fullName); - let injections = - this._injections[normalizedName] || - (this._injections[normalizedName] = []); + let injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); injections.push({ property, specifier: normalizedInjectionName }); } @@ -586,9 +559,7 @@ export default class Registry { if (fallbackInjections !== undefined) { injections = - injections === undefined - ? fallbackInjections - : injections.concat(fallbackInjections); + injections === undefined ? fallbackInjections : injections.concat(fallbackInjections); } } @@ -602,9 +573,7 @@ export default class Registry { if (fallbackInjections !== undefined) { injections = - injections === undefined - ? fallbackInjections - : injections.concat(fallbackInjections); + injections === undefined ? fallbackInjections : injections.concat(fallbackInjections); } } @@ -631,10 +600,7 @@ export default class Registry { */ expandLocalLookup(fullName, options) { if (this.resolver !== null && this.resolver.expandLocalLookup) { - assert( - 'fullName must be a proper full name', - this.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.isValidFullName(fullName)); assert( 'options.source must be a proper full name', !options.source || this.isValidFullName(options.source) @@ -643,12 +609,7 @@ export default class Registry { let normalizedFullName = this.normalize(fullName); let normalizedSource = this.normalize(options.source); - return expandLocalLookup( - this, - normalizedFullName, - normalizedSource, - options.namespace - ); + return expandLocalLookup(this, normalizedFullName, normalizedSource, options.namespace); } else if (this.fallback !== null) { return this.fallback.expandLocalLookup(fullName, options); } else { @@ -661,8 +622,7 @@ function deprecateResolverFunction(registry) { deprecate(missingResolverFunctionsDeprecation, false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' + url: 'https://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function', }); registry.resolver = { resolve: registry.resolver }; } @@ -683,7 +643,7 @@ if (DEBUG) { property: key, specifier, source, - namespace + namespace, }); } } @@ -707,12 +667,7 @@ if (DEBUG) { }; } -function expandLocalLookup( - registry, - normalizedName, - normalizedSource, - namespace -) { +function expandLocalLookup(registry, normalizedName, normalizedSource, namespace) { let cache = registry._localLookupCache; let normalizedNameCache = cache[normalizedName]; @@ -728,11 +683,7 @@ function expandLocalLookup( return cached; } - let expanded = registry.resolver.expandLocalLookup( - normalizedName, - normalizedSource, - namespace - ); + let expanded = registry.resolver.expandLocalLookup(normalizedName, normalizedSource, namespace); return (normalizedNameCache[cacheKey] = expanded); } @@ -789,7 +740,5 @@ export function privatize([fullName]) { } let [type, rawName] = fullName.split(':'); - return (privateNames[fullName] = intern( - `${type}:${rawName}-${privateSuffix}` - )); + return (privateNames[fullName] = intern(`${type}:${rawName}-${privateSuffix}`)); } diff --git a/packages/container/tests/container_test.js b/packages/container/tests/container_test.js index 9c8aa332255..d85d87d0bb1 100644 --- a/packages/container/tests/container_test.js +++ b/packages/container/tests/container_test.js @@ -54,10 +54,10 @@ moduleFor( let postController1 = container.lookup('controller:post'); let postController2 = container.lookup('controller:post', { - singleton: false + singleton: false, }); let postController3 = container.lookup('controller:post', { - singleton: false + singleton: false, }); let postController4 = container.lookup('controller:post'); @@ -119,9 +119,7 @@ moduleFor( assert.equal(postController.store, store); } - ['@test An individual factory with a registered injection receives the injection']( - assert - ) { + ['@test An individual factory with a registered injection receives the injection'](assert) { let registry = new Registry(); let container = registry.container(); let PostController = factory(); @@ -135,11 +133,7 @@ moduleFor( let postController = container.lookup('controller:post'); let store = container.lookup('store:main'); - assert.equal( - postController.store, - store, - 'has the correct store injected' - ); + assert.equal(postController.store, store, 'has the correct store injected'); } ['@test A factory with both type and individual injections'](assert) { @@ -217,7 +211,7 @@ moduleFor( }, extend() { return fooFactory; - } + }, }; registry.register('model:foo', Foo); @@ -235,30 +229,18 @@ moduleFor( registry.register('controller:application', ApplicationController); registry.register('user:current', null, { instantiate: false }); - registry.injection( - 'controller:application', - 'currentUser', - 'user:current' - ); + registry.injection('controller:application', 'currentUser', 'user:current'); - assert.strictEqual( - container.lookup('controller:application').currentUser, - null - ); + assert.strictEqual(container.lookup('controller:application').currentUser, null); } - ['@test The container returns same value each time even if the value is falsy']( - assert - ) { + ['@test The container returns same value each time even if the value is falsy'](assert) { let registry = new Registry(); let container = registry.container(); registry.register('falsy:value', null, { instantiate: false }); - assert.strictEqual( - container.lookup('falsy:value'), - container.lookup('falsy:value') - ); + assert.strictEqual(container.lookup('falsy:value'), container.lookup('falsy:value')); } ['@test Destroying the container destroys any cached singletons'](assert) { @@ -285,9 +267,7 @@ moduleFor( assert.ok(!postView.isDestroyed, 'Non-singletons are not destroyed'); } - ['@test The container can use a registry hook to resolve factories lazily']( - assert - ) { + ['@test The container can use a registry hook to resolve factories lazily'](assert) { let registry = new Registry(); let container = registry.container(); let PostController = factory(); @@ -297,15 +277,12 @@ moduleFor( if (fullName === 'controller:post') { return PostController; } - } + }, }; let postController = container.lookup('controller:post'); - assert.ok( - postController instanceof PostController, - 'The correct factory was provided' - ); + assert.ok(postController instanceof PostController, 'The correct factory was provided'); } ['@test The container normalizes names before resolving'](assert) { @@ -320,10 +297,7 @@ moduleFor( registry.register('controller:post', PostController); let postController = container.lookup('controller:normalized'); - assert.ok( - postController instanceof PostController, - 'Normalizes the name before resolving' - ); + assert.ok(postController instanceof PostController, 'Normalizes the name before resolving'); } ['@test The container normalizes names when looking factory up'](assert) { @@ -342,9 +316,7 @@ moduleFor( assert.ok(factInstance instanceof PostController, 'Normalizes the name'); } - ['@test Options can be registered that should be applied to a given factory']( - assert - ) { + ['@test Options can be registered that should be applied to a given factory'](assert) { let registry = new Registry(); let container = registry.container(); let PostView = factory(); @@ -354,7 +326,7 @@ moduleFor( if (fullName === 'view:post') { return PostView; } - } + }, }; registry.options('view:post', { instantiate: true, singleton: false }); @@ -362,14 +334,8 @@ moduleFor( let postView1 = container.lookup('view:post'); let postView2 = container.lookup('view:post'); - assert.ok( - postView1 instanceof PostView, - 'The correct factory was provided' - ); - assert.ok( - postView2 instanceof PostView, - 'The correct factory was provided' - ); + assert.ok(postView1 instanceof PostView, 'The correct factory was provided'); + assert.ok(postView2 instanceof PostView, 'The correct factory was provided'); assert.ok(postView1 !== postView2, 'The two lookups are different'); } @@ -386,7 +352,7 @@ moduleFor( if (fullName === 'view:post') { return PostView; } - } + }, }; registry.optionsForType('view', { singleton: false }); @@ -394,14 +360,8 @@ moduleFor( let postView1 = container.lookup('view:post'); let postView2 = container.lookup('view:post'); - assert.ok( - postView1 instanceof PostView, - 'The correct factory was provided' - ); - assert.ok( - postView2 instanceof PostView, - 'The correct factory was provided' - ); + assert.ok(postView1 instanceof PostView, 'The correct factory was provided'); + assert.ok(postView2 instanceof PostView, 'The correct factory was provided'); assert.ok(postView1 !== postView2, 'The two lookups are different'); } @@ -414,7 +374,7 @@ moduleFor( registry.register('view:post', PostView, { singleton: false }); registry.register('view_helper:post', PostViewHelper, { - singleton: false + singleton: false, }); registry.injection('view:post', 'viewHelper', 'view_helper:post'); @@ -482,9 +442,7 @@ moduleFor( assert.deepEqual(resolveWasCalled, ['foo:post']); } - [`@test A factory's lazy injections are validated when first instantiated`]( - assert - ) { + [`@test A factory's lazy injections are validated when first instantiated`](assert) { let registry = new Registry(); let container = registry.container(); let Apple = factory(); @@ -493,7 +451,7 @@ moduleFor( Apple.reopenClass({ _lazyInjections() { return [{ specifier: 'orange:main' }, { specifier: 'banana:main' }]; - } + }, }); registry.register('apple:main', Apple); @@ -516,7 +474,7 @@ moduleFor( _lazyInjections: () => { assert.ok(true, 'should call lazy injection method'); return [{ specifier: 'orange:main' }]; - } + }, }); registry.register('apple:main', Apple); @@ -526,9 +484,7 @@ moduleFor( container.lookup('apple:main'); } - ['@test An object with its owner pre-set should be returned from ownerInjection']( - assert - ) { + ['@test An object with its owner pre-set should be returned from ownerInjection'](assert) { let owner = {}; let registry = new Registry(); let container = registry.container({ owner }); @@ -553,7 +509,7 @@ moduleFor( }; let PostControllerLookupResult = container.lookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.ok(PostControllerLookupResult instanceof PostController); @@ -590,9 +546,7 @@ moduleFor( assert.ok(factoryManager.class); } - ['@test #factoryFor returns a cached factory manager for the same type']( - assert - ) { + ['@test #factoryFor returns a cached factory manager for the same type'](assert) { let registry = new Registry(); let container = registry.container(); @@ -659,9 +613,7 @@ moduleFor( assert.notEqual(factory1, factory3); } - ['@test #factoryFor created instances come with instance injections']( - assert - ) { + ['@test #factoryFor created instances come with instance injections'](assert) { let registry = new Registry(); let container = registry.container(); @@ -720,9 +672,7 @@ moduleFor( // this is skipped until templates and the glimmer environment do not require `OWNER` to be // passed in as constructor args - ['@skip #factoryFor does not add properties to the object being instantiated']( - assert - ) { + ['@skip #factoryFor does not add properties to the object being instantiated'](assert) { let registry = new Registry(); let container = registry.container(); @@ -749,9 +699,7 @@ if (EMBER_MODULE_UNIFICATION) { moduleFor( 'Container module unification', class extends AbstractTestCase { - ['@test The container can expand and resolve a source to factoryFor']( - assert - ) { + ['@test The container can expand and resolve a source to factoryFor'](assert) { let PrivateComponent = factory(); let lookup = 'component:my-input'; let expectedSource = 'template:routes/application'; @@ -760,11 +708,7 @@ if (EMBER_MODULE_UNIFICATION) { let expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = (specifier, options) => { this.assert.strictEqual(specifier, lookup, 'specifier is expanded'); - this.assert.strictEqual( - options.source, - expectedSource, - 'source is expanded' - ); + this.assert.strictEqual(options.source, expectedSource, 'source is expanded'); return expandedKey; }; registry.resolve = function(fullName) { @@ -801,11 +745,7 @@ if (EMBER_MODULE_UNIFICATION) { let expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = (specifier, options) => { this.assert.strictEqual(specifier, lookup, 'specifier is expanded'); - this.assert.strictEqual( - options.source, - expectedSource, - 'source is expanded' - ); + this.assert.strictEqual(options.source, expectedSource, 'source is expanded'); return expandedKey; }; registry.resolve = function(fullName) { @@ -817,10 +757,7 @@ if (EMBER_MODULE_UNIFICATION) { let container = registry.container(); let result = container.lookup(lookup, { source: expectedSource }); - this.assert.ok( - result instanceof PrivateComponent, - 'The correct factory was provided' - ); + this.assert.ok(result instanceof PrivateComponent, 'The correct factory was provided'); this.assert.ok( container.cache[expandedKey] instanceof PrivateComponent, @@ -828,9 +765,7 @@ if (EMBER_MODULE_UNIFICATION) { ); } - ['@test The container can expand and resolve a namespace to factoryFor']( - assert - ) { + ['@test The container can expand and resolve a namespace to factoryFor'](assert) { let PrivateComponent = factory(); let lookup = 'component:my-input'; let expectedNamespace = 'my-addon'; @@ -839,11 +774,7 @@ if (EMBER_MODULE_UNIFICATION) { let expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = (specifier, options) => { this.assert.strictEqual(specifier, lookup, 'specifier is expanded'); - this.assert.strictEqual( - options.namespace, - expectedNamespace, - 'namespace is expanded' - ); + this.assert.strictEqual(options.namespace, expectedNamespace, 'namespace is expanded'); return expandedKey; }; registry.resolve = function(fullName) { @@ -880,11 +811,7 @@ if (EMBER_MODULE_UNIFICATION) { let expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = (specifier, options) => { this.assert.strictEqual(specifier, lookup, 'specifier is expanded'); - this.assert.strictEqual( - options.namespace, - expectedNamespace, - 'namespace is expanded' - ); + this.assert.strictEqual(options.namespace, expectedNamespace, 'namespace is expanded'); return expandedKey; }; registry.resolve = function(fullName) { @@ -896,10 +823,7 @@ if (EMBER_MODULE_UNIFICATION) { let container = registry.container(); let result = container.lookup(lookup, { namespace: expectedNamespace }); - this.assert.ok( - result instanceof PrivateComponent, - 'The correct factory was provided' - ); + this.assert.ok(result instanceof PrivateComponent, 'The correct factory was provided'); this.assert.ok( container.cache[expandedKey] instanceof PrivateComponent, diff --git a/packages/container/tests/owner_test.js b/packages/container/tests/owner_test.js index 903d81792e9..2f6dd88c5c2 100644 --- a/packages/container/tests/owner_test.js +++ b/packages/container/tests/owner_test.js @@ -4,9 +4,7 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'Owner', class extends AbstractTestCase { - ['@test An owner can be set with `setOwner` and retrieved with `getOwner`']( - assert - ) { + ['@test An owner can be set with `setOwner` and retrieved with `getOwner`'](assert) { let owner = {}; let obj = {}; @@ -16,11 +14,7 @@ moduleFor( assert.strictEqual(getOwner(obj), owner, 'owner has been set'); - assert.strictEqual( - obj[OWNER], - owner, - 'owner has been set to the OWNER symbol' - ); + assert.strictEqual(obj[OWNER], owner, 'owner has been set to the OWNER symbol'); } } ); diff --git a/packages/container/tests/registry_test.js b/packages/container/tests/registry_test.js index f7859ce19f9..cda8c4263e4 100644 --- a/packages/container/tests/registry_test.js +++ b/packages/container/tests/registry_test.js @@ -3,7 +3,7 @@ import { factory, moduleFor, AbstractTestCase, - ModuleBasedTestResolver + ModuleBasedTestResolver, } from 'internal-test-helpers'; import { EMBER_MODULE_UNIFICATION } from 'ember/features'; import { ENV } from 'ember-environment'; @@ -14,8 +14,7 @@ moduleFor( constructor() { super(); - this.originalResolverFunctionSupport = - ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT; + this.originalResolverFunctionSupport = ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT; ENV._ENABLE_RESOLVER_FUNCTION_SUPPORT = true; } @@ -38,9 +37,7 @@ moduleFor( ); } - ['@test The registered factory returned from resolve is the same factory each time']( - assert - ) { + ['@test The registered factory returned from resolve is the same factory each time'](assert) { let registry = new Registry(); let PostController = factory(); @@ -75,16 +72,14 @@ moduleFor( if (fullName === 'falsy:value') { return null; } - } + }, }; let registry = new Registry({ resolver }); assert.strictEqual(registry.resolve('falsy:value'), null); } - ['@test A registered factory returns true for `has` if an item is registered']( - assert - ) { + ['@test A registered factory returns true for `has` if an item is registered'](assert) { let registry = new Registry(); let PostController = factory(); @@ -120,7 +115,7 @@ moduleFor( if (fullName === 'controller:post') { return PostController; } - } + }, }; let registry = new Registry({ resolver }); @@ -138,14 +133,11 @@ moduleFor( if (fullName === 'controller:post') { return PostController; } - } + }, }; let registry = new Registry({ resolver }); - assert.ok( - registry.has('controller:post'), - 'the `has` method uses the resolver hook' - ); + assert.ok(registry.has('controller:post'), 'the `has` method uses the resolver hook'); } ['@test The registry normalizes names when resolving'](assert) { @@ -159,23 +151,15 @@ moduleFor( registry.register('controller:post', PostController); let type = registry.resolve('controller:normalized'); - assert.strictEqual( - type, - PostController, - 'Normalizes the name when resolving' - ); + assert.strictEqual(type, PostController, 'Normalizes the name when resolving'); } - ['@test The registry normalizes names when checking if the factory is registered']( - assert - ) { + ['@test The registry normalizes names when checking if the factory is registered'](assert) { let registry = new Registry(); let PostController = factory(); registry.normalizeFullName = function(fullName) { - return fullName === 'controller:normalized' - ? 'controller:post' - : fullName; + return fullName === 'controller:normalized' ? 'controller:post' : fullName; }; registry.register('controller:post', PostController); @@ -224,9 +208,7 @@ moduleFor( registry.register('controller:apple', FirstApple); registry.register('controller:apple', SecondApple); - assert.ok( - registry.resolve('controller:apple').create() instanceof SecondApple - ); + assert.ok(registry.resolve('controller:apple').create() instanceof SecondApple); } ['@test cannot re-register a factory if it has been resolved'](assert) { @@ -262,11 +244,7 @@ moduleFor( registry.register('controller:apple', FirstApple); registry.register('controller:second-apple', SecondApple); - registry.injection( - 'controller:apple', - 'badApple', - 'controller:second-apple' - ); + registry.injection('controller:apple', 'badApple', 'controller:second-apple'); assert.ok(registry.has('controller:apple')); } @@ -283,7 +261,7 @@ moduleFor( registry.resolver = { resolve() { return 'bar'; - } + }, }; let Bar = registry.resolve('models:bar'); @@ -291,7 +269,7 @@ moduleFor( registry.resolver = { resolve() { return 'not bar'; - } + }, }; assert.equal(registry.resolve('models:bar'), Bar); @@ -306,7 +284,7 @@ moduleFor( resolve(fullName) { resolveWasCalled.push(fullName); return PostController; - } + }, }; assert.deepEqual(resolveWasCalled, []); @@ -326,7 +304,7 @@ moduleFor( resolve(fullName) { resolveWasCalled.push(fullName); return PostController; - } + }, }; assert.deepEqual(resolveWasCalled, []); @@ -346,7 +324,7 @@ moduleFor( resolve(fullName) { resolveWasCalled.push(fullName); return PostController; - } + }, }; assert.deepEqual(resolveWasCalled, []); @@ -377,13 +355,13 @@ moduleFor( let fallback = { describe(fullName) { return `${fullName}-fallback`; - } + }, }; let resolver = { lookupDescription(fullName) { return `${fullName}-resolver`; - } + }, }; let registry = new Registry({ fallback, resolver }); @@ -417,13 +395,13 @@ moduleFor( let fallback = { normalizeFullName(fullName) { return `${fullName}-fallback`; - } + }, }; let resolver = { normalize(fullName) { return `${fullName}-resolver`; - } + }, }; let registry = new Registry({ fallback, resolver }); @@ -457,13 +435,13 @@ moduleFor( let fallback = { makeToString(fullName) { return `${fullName}-fallback`; - } + }, }; let resolver = { makeToString(fullName) { return `${fullName}-resolver`; - } + }, }; let registry = new Registry({ fallback, resolver }); @@ -523,9 +501,7 @@ moduleFor( ); } - ['@test `getInjections` includes injections from a fallback registry']( - assert - ) { + ['@test `getInjections` includes injections from a fallback registry'](assert) { let fallback = new Registry(); let registry = new Registry({ fallback: fallback }); @@ -544,9 +520,7 @@ moduleFor( ); } - ['@test `getTypeInjections` includes type injections from a fallback registry']( - assert - ) { + ['@test `getTypeInjections` includes type injections from a fallback registry'](assert) { let fallback = new Registry(); let registry = new Registry({ fallback: fallback }); @@ -565,9 +539,7 @@ moduleFor( ); } - ['@test `knownForType` contains keys for each item of a given type']( - assert - ) { + ['@test `knownForType` contains keys for each item of a given type'](assert) { let registry = new Registry(); registry.register('foo:bar-baz', 'baz'); @@ -577,7 +549,7 @@ moduleFor( assert.deepEqual(found, { 'foo:bar-baz': true, - 'foo:qux-fez': true + 'foo:qux-fez': true, }); } @@ -594,7 +566,7 @@ moduleFor( assert.deepEqual(found, { 'foo:bar-baz': true, 'foo:qux-fez': true, - 'foo:zurp-zorp': true + 'foo:zurp-zorp': true, }); } @@ -607,11 +579,11 @@ moduleFor( assert.equal(type, 'foo', 'the type was passed through'); return { 'foo:yorp': true }; - } + }, }; let registry = new Registry({ - resolver + resolver, }); registry.register('foo:bar-baz', 'baz'); @@ -619,7 +591,7 @@ moduleFor( assert.deepEqual(found, { 'foo:yorp': true, - 'foo:bar-baz': true + 'foo:bar-baz': true, }); } @@ -636,7 +608,7 @@ moduleFor( registry = new Registry({ resolver(fullName) { return `${fullName}-resolved`; - } + }, }); }, 'Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.'); @@ -658,18 +630,18 @@ moduleFor( new Registry({ resolver(fullName) { return `${fullName}-resolved`; - } + }, }); }, /Passing a \`resolver\` function into a Registry is deprecated\. Please pass in a Resolver object with a \`resolve\` method\./); } ['@test resolver.expandLocalLookup is not required'](assert) { let registry = new Registry({ - resolver: {} + resolver: {}, }); let result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, null); @@ -681,27 +653,19 @@ moduleFor( let resolver = { expandLocalLookup: (targetFullName, sourceFullName) => { assert.ok(true, 'expandLocalLookup is called on the resolver'); - assert.equal( - targetFullName, - 'foo:bar', - 'the targetFullName was passed through' - ); - assert.equal( - sourceFullName, - 'baz:qux', - 'the sourceFullName was passed through' - ); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); return 'foo:qux/bar'; - } + }, }; let registry = new Registry({ - resolver + resolver, }); let result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar'); @@ -714,54 +678,35 @@ moduleFor( let fallbackResolver = { expandLocalLookup: (targetFullName, sourceFullName) => { - assert.ok( - true, - 'expandLocalLookup is called on the fallback resolver' - ); - assert.equal( - targetFullName, - 'foo:bar', - 'the targetFullName was passed through' - ); - assert.equal( - sourceFullName, - 'baz:qux', - 'the sourceFullName was passed through' - ); + assert.ok(true, 'expandLocalLookup is called on the fallback resolver'); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); return 'foo:qux/bar-fallback'; - } + }, }; let resolver = { expandLocalLookup: (targetFullName, sourceFullName) => { assert.ok(true, 'expandLocalLookup is called on the resolver'); - assert.equal( - targetFullName, - 'foo:bar', - 'the targetFullName was passed through' - ); - assert.equal( - sourceFullName, - 'baz:qux', - 'the sourceFullName was passed through' - ); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); return 'foo:qux/bar-resolver'; - } + }, }; let fallbackRegistry = new Registry({ - resolver: fallbackResolver + resolver: fallbackResolver, }); let registry = new Registry({ fallback: fallbackRegistry, - resolver + resolver, }); let result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar-resolver', 'handled by the resolver'); @@ -769,19 +714,15 @@ moduleFor( registry.resolver = null; result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); - assert.equal( - result, - 'foo:qux/bar-fallback', - 'handled by the fallback registry' - ); + assert.equal(result, 'foo:qux/bar-fallback', 'handled by the fallback registry'); registry.fallback = null; result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal( @@ -800,29 +741,27 @@ moduleFor( assert.ok(true, 'expandLocalLookup is called on the resolver'); return 'foo:qux/bar'; - } + }, }; let registry = new Registry({ - resolver + resolver, }); result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar'); result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar'); } - ['@test resolver.expandLocalLookup cache is busted when any unregister is called']( - assert - ) { + ['@test resolver.expandLocalLookup cache is busted when any unregister is called'](assert) { assert.expect(4); let result; @@ -831,15 +770,15 @@ moduleFor( assert.ok(true, 'expandLocalLookup is called on the resolver'); return 'foo:qux/bar'; - } + }, }; let registry = new Registry({ - resolver + resolver, }); result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar'); @@ -847,42 +786,32 @@ moduleFor( registry.unregister('foo:bar'); result = registry.expandLocalLookup('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.equal(result, 'foo:qux/bar'); } - ['@test resolve calls expandLocallookup when it receives options.source']( - assert - ) { + ['@test resolve calls expandLocallookup when it receives options.source'](assert) { assert.expect(3); let resolver = { resolve() {}, expandLocalLookup: (targetFullName, sourceFullName) => { assert.ok(true, 'expandLocalLookup is called on the resolver'); - assert.equal( - targetFullName, - 'foo:bar', - 'the targetFullName was passed through' - ); - assert.equal( - sourceFullName, - 'baz:qux', - 'the sourceFullName was passed through' - ); + assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through'); + assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through'); return 'foo:qux/bar'; - } + }, }; let registry = new Registry({ - resolver + resolver, }); registry.resolve('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); } @@ -905,21 +834,21 @@ moduleFor( } else { return null; } - } + }, }; let registry = new Registry({ - resolver + resolver, }); result = registry.has('foo:bar', { - source: 'baz:qux' + source: 'baz:qux', }); assert.ok(result, 'found foo:bar/qux'); result = registry.has('foo:baz', { - source: 'baz:qux' + source: 'baz:qux', }); assert.ok(!result, 'foo:baz/qux not found'); diff --git a/packages/ember-application/lib/system/application-instance.js b/packages/ember-application/lib/system/application-instance.js index cbdc054b1e3..de6d9038b81 100644 --- a/packages/ember-application/lib/system/application-instance.js +++ b/packages/ember-application/lib/system/application-instance.js @@ -204,11 +204,7 @@ const ApplicationInstance = EngineInstance.extend({ let applicationCustomEvents = get(this.application, 'customEvents'); let instanceCustomEvents = get(this, 'customEvents'); - let customEvents = assign( - {}, - applicationCustomEvents, - instanceCustomEvents - ); + let customEvents = assign({}, applicationCustomEvents, instanceCustomEvents); dispatcher.setup(customEvents, this.rootElement); return dispatcher; @@ -259,10 +255,7 @@ const ApplicationInstance = EngineInstance.extend({ let handleTransitionReject = error => { if (error.error) { throw error.error; - } else if ( - error.name === 'TransitionAborted' && - router._routerMicrolib.activeTransition - ) { + } else if (error.name === 'TransitionAborted' && router._routerMicrolib.activeTransition) { return router._routerMicrolib.activeTransition.then( handleTransitionResolve, handleTransitionReject @@ -288,7 +281,7 @@ const ApplicationInstance = EngineInstance.extend({ willDestroy() { this._super(...arguments); this.application._unwatchInstance(this); - } + }, }); ApplicationInstance.reopenClass({ @@ -304,14 +297,14 @@ ApplicationInstance.reopenClass({ } registry.register('-environment:main', options.toEnvironment(), { - instantiate: false + instantiate: false, }); registry.register('service:-document', options.document, { - instantiate: false + instantiate: false, }); this._super(registry, options); - } + }, }); /** diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index 9a88eb476d5..73b4f610d86 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -13,7 +13,7 @@ import { bind, once, processAllNamespaces, - setNamespaceSearchDisabled + setNamespaceSearchDisabled, } from 'ember-metal'; import { runLoadHooks, _loaded, RSVP } from 'ember-runtime'; import { EventDispatcher, jQuery, jQueryDisabled } from 'ember-views'; @@ -24,7 +24,7 @@ import { HistoryLocation, AutoLocation, NoneLocation, - BucketCache + BucketCache, } from 'ember-routing'; import ApplicationInstance from './application-instance'; import { privatize as P } from 'container'; @@ -1063,7 +1063,7 @@ const Application = Engine.extend({ throw error; }); }); - } + }, }); Application.reopenClass({ @@ -1101,7 +1101,7 @@ Application.reopenClass({ setupApplicationRegistry(registry); return registry; - } + }, }); function commonSetupRegistry(registry) { @@ -1109,7 +1109,7 @@ function commonSetupRegistry(registry) { registry.register('-view-registry:main', { create() { return dictionary(null); - } + }, }); registry.register('route:basic', Route); @@ -1125,7 +1125,7 @@ function commonSetupRegistry(registry) { registry.register(P`-bucket-cache:main`, { create() { return new BucketCache(); - } + }, }); if (EMBER_ROUTING_ROUTER_SERVICE) { diff --git a/packages/ember-application/lib/system/engine-instance.js b/packages/ember-application/lib/system/engine-instance.js index 3db5418da15..1287a1b0877 100644 --- a/packages/ember-application/lib/system/engine-instance.js +++ b/packages/ember-application/lib/system/engine-instance.js @@ -7,7 +7,7 @@ import { Object as EmberObject, ContainerProxyMixin, RegistryProxyMixin, - RSVP + RSVP, } from 'ember-runtime'; import { assert, Error as EmberError } from 'ember-debug'; import { Registry, privatize as P } from 'container'; @@ -24,43 +24,40 @@ import { getEngineParent, setEngineParent } from './engine-parent'; @uses ContainerProxyMixin */ -const EngineInstance = EmberObject.extend( - RegistryProxyMixin, - ContainerProxyMixin, - { - /** +const EngineInstance = EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin, { + /** The base `Engine` for which this is an instance. @property {Engine} engine @private */ - base: null, + base: null, - init() { - this._super(...arguments); + init() { + this._super(...arguments); - guidFor(this); + guidFor(this); - let base = this.base; + let base = this.base; - if (!base) { - base = this.application; - this.base = base; - } + if (!base) { + base = this.application; + this.base = base; + } - // Create a per-instance registry that will use the application's registry - // as a fallback for resolving registrations. - let registry = (this.__registry__ = new Registry({ - fallback: base.__registry__ - })); + // Create a per-instance registry that will use the application's registry + // as a fallback for resolving registrations. + let registry = (this.__registry__ = new Registry({ + fallback: base.__registry__, + })); - // Create a per-instance container from the instance's registry - this.__container__ = registry.container({ owner: this }); + // Create a per-instance container from the instance's registry + this.__container__ = registry.container({ owner: this }); - this._booted = false; - }, + this._booted = false; + }, - /** + /** Initialize the `EngineInstance` and return a promise that resolves with the instance itself when the boot process is complete. @@ -73,19 +70,17 @@ const EngineInstance = EmberObject.extend( @param options {Object} @return {Promise} */ - boot(options) { - if (this._bootPromise) { - return this._bootPromise; - } + boot(options) { + if (this._bootPromise) { + return this._bootPromise; + } - this._bootPromise = new RSVP.Promise(resolve => - resolve(this._bootSync(options)) - ); + this._bootPromise = new RSVP.Promise(resolve => resolve(this._bootSync(options))); - return this._bootPromise; - }, + return this._bootPromise; + }, - /** + /** Unfortunately, a lot of existing code assumes booting an instance is synchronous – specifically, a lot of tests assume the last call to `app.advanceReadiness()` or `app.reset()` will result in a new instance @@ -99,32 +94,32 @@ const EngineInstance = EmberObject.extend( @private */ - _bootSync(options) { - if (this._booted) { - return this; - } - - assert( - "An engine instance's parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.", - getEngineParent(this) - ); + _bootSync(options) { + if (this._booted) { + return this; + } - this.cloneParentDependencies(); + assert( + "An engine instance's parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.", + getEngineParent(this) + ); - this.setupRegistry(options); + this.cloneParentDependencies(); - this.base.runInstanceInitializers(this); + this.setupRegistry(options); - this._booted = true; + this.base.runInstanceInitializers(this); - return this; - }, + this._booted = true; + + return this; + }, - setupRegistry(options = this.__container__.lookup('-environment:main')) { - this.constructor.setupRegistry(this.__registry__, options); - }, + setupRegistry(options = this.__container__.lookup('-environment:main')) { + this.constructor.setupRegistry(this.__registry__, options); + }, - /** + /** Unregister a factory. Overrides `RegistryProxy#unregister` in order to clear any cached instances @@ -134,12 +129,12 @@ const EngineInstance = EmberObject.extend( @method unregister @param {String} fullName */ - unregister(fullName) { - this.__container__.reset(fullName); - this._super(...arguments); - }, + unregister(fullName) { + this.__container__.reset(fullName); + this._super(...arguments); + }, - /** + /** Build a new `EngineInstance` that's a child of this instance. Engines must be registered by name with their parent engine @@ -151,66 +146,57 @@ const EngineInstance = EmberObject.extend( @param options {Object} options provided to the engine instance. @return {EngineInstance,Error} */ - buildChildEngineInstance(name, options = {}) { - let Engine = this.lookup(`engine:${name}`); + buildChildEngineInstance(name, options = {}) { + let Engine = this.lookup(`engine:${name}`); - if (!Engine) { - throw new EmberError( - `You attempted to mount the engine '${name}', but it is not registered with its parent.` - ); - } + if (!Engine) { + throw new EmberError( + `You attempted to mount the engine '${name}', but it is not registered with its parent.` + ); + } - let engineInstance = Engine.buildInstance(options); + let engineInstance = Engine.buildInstance(options); - setEngineParent(engineInstance, this); + setEngineParent(engineInstance, this); - return engineInstance; - }, + return engineInstance; + }, - /** + /** Clone dependencies shared between an engine instance and its parent. @private @method cloneParentDependencies */ - cloneParentDependencies() { - let parent = getEngineParent(this); + cloneParentDependencies() { + let parent = getEngineParent(this); - let registrations = [ - 'route:basic', - 'service:-routing', - 'service:-glimmer-environment' - ]; + let registrations = ['route:basic', 'service:-routing', 'service:-glimmer-environment']; - registrations.forEach(key => - this.register(key, parent.resolveRegistration(key)) - ); + registrations.forEach(key => this.register(key, parent.resolveRegistration(key))); - let env = parent.lookup('-environment:main'); - this.register('-environment:main', env, { instantiate: false }); + let env = parent.lookup('-environment:main'); + this.register('-environment:main', env, { instantiate: false }); - let singletons = [ - 'router:main', - P`-bucket-cache:main`, - '-view-registry:main', - `renderer:-${env.isInteractive ? 'dom' : 'inert'}`, - 'service:-document', - P`template-compiler:main` - ]; + let singletons = [ + 'router:main', + P`-bucket-cache:main`, + '-view-registry:main', + `renderer:-${env.isInteractive ? 'dom' : 'inert'}`, + 'service:-document', + P`template-compiler:main`, + ]; - if (env.isInteractive) { - singletons.push('event_dispatcher:main'); - } + if (env.isInteractive) { + singletons.push('event_dispatcher:main'); + } - singletons.forEach(key => - this.register(key, parent.lookup(key), { instantiate: false }) - ); + singletons.forEach(key => this.register(key, parent.lookup(key), { instantiate: false })); - this.inject('view', '_environment', '-environment:main'); - this.inject('route', '_environment', '-environment:main'); - } - } -); + this.inject('view', '_environment', '-environment:main'); + this.inject('route', '_environment', '-environment:main'); + }, +}); EngineInstance.reopenClass({ /** @@ -235,7 +221,7 @@ EngineInstance.reopenClass({ registry.injection('view', 'renderer', 'renderer:-inert'); registry.injection('component', 'renderer', 'renderer:-inert'); } - } + }, }); export default EngineInstance; diff --git a/packages/ember-application/lib/system/engine.js b/packages/ember-application/lib/system/engine.js index 89c07fb2005..ffd508859cc 100644 --- a/packages/ember-application/lib/system/engine.js +++ b/packages/ember-application/lib/system/engine.js @@ -141,16 +141,11 @@ const Engine = Namespace.extend(RegistryProxyMixin, { for (let i = 0; i < initializers.length; i++) { initializer = initializersByName[initializers[i]]; - graph.add( - initializer.name, - initializer, - initializer.before, - initializer.after - ); + graph.add(initializer.name, initializer, initializer.before, initializer.after); } graph.topsort(cb); - } + }, }); Engine.reopenClass({ @@ -376,10 +371,7 @@ Engine.reopenClass({ @param instanceInitializer @public */ - instanceInitializer: buildInitializerMethod( - 'instanceInitializers', - 'instance initializer' - ), + instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer'), /** This creates a registry with the default Ember naming conventions. @@ -408,7 +400,7 @@ Engine.reopenClass({ */ buildRegistry(namespace) { let registry = new Registry({ - resolver: resolverFor(namespace) + resolver: resolverFor(namespace), }); registry.set = set; @@ -436,7 +428,7 @@ Engine.reopenClass({ @property resolver @public */ - Resolver: null + Resolver: null, }); /** @@ -459,7 +451,7 @@ function resolverFor(namespace) { let ResolverClass = namespace.get('Resolver') || DefaultResolver; return ResolverClass.create({ - namespace + namespace, }); } @@ -503,11 +495,7 @@ function commonSetupRegistry(registry) { registry.injection('view', '_viewRegistry', '-view-registry:main'); registry.injection('renderer', '_viewRegistry', '-view-registry:main'); - registry.injection( - 'event_dispatcher:main', - '_viewRegistry', - '-view-registry:main' - ); + registry.injection('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); @@ -528,18 +516,10 @@ function commonSetupRegistry(registry) { // DEBUGGING registry.register('resolver-for-debugging:main', registry.resolver, { - instantiate: false + instantiate: false, }); - registry.injection( - 'container-debug-adapter:main', - 'resolver', - 'resolver-for-debugging:main' - ); - registry.injection( - 'data-adapter:main', - 'containerDebugAdapter', - 'container-debug-adapter:main' - ); + registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); + registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); // Custom resolver authors may want to register their own ContainerDebugAdapter with this key registry.register('container-debug-adapter:main', ContainerDebugAdapter); diff --git a/packages/ember-application/lib/system/resolver.js b/packages/ember-application/lib/system/resolver.js index 51315acc53d..97f5c0e50f6 100644 --- a/packages/ember-application/lib/system/resolver.js +++ b/packages/ember-application/lib/system/resolver.js @@ -24,7 +24,7 @@ export const Resolver = EmberObject.extend({ lookupDescription: null, // required makeToString: null, // required resolveOther: null, // required - _logLookup: null // required + _logLookup: null, // required }); /** @@ -175,8 +175,7 @@ const DefaultResolver = EmberObject.extend({ parseName(fullName) { return ( - this._parseNameCache[fullName] || - (this._parseNameCache[fullName] = this._parseName(fullName)) + this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)) ); }, @@ -201,13 +200,10 @@ const DefaultResolver = EmberObject.extend({ ); } - let resolveMethodName = - fullNameWithoutType === 'main' ? 'Main' : StringUtils.classify(type); + let resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : StringUtils.classify(type); if (!(name && type)) { - throw new TypeError( - `Invalid fullName: \`${fullName}\`, must be of the form \`type:name\` ` - ); + throw new TypeError(`Invalid fullName: \`${fullName}\`, must be of the form \`type:name\` `); } return { @@ -217,7 +213,7 @@ const DefaultResolver = EmberObject.extend({ dirname, name, root, - resolveMethodName: `resolve${resolveMethodName}` + resolveMethodName: `resolve${resolveMethodName}`, }; }, @@ -236,15 +232,10 @@ const DefaultResolver = EmberObject.extend({ let description; if (parsedName.type === 'template') { - return `template at ${parsedName.fullNameWithoutType.replace( - /\./g, - '/' - )}`; + return `template at ${parsedName.fullNameWithoutType.replace(/\./g, '/')}`; } - description = `${parsedName.root}.${StringUtils.classify( - parsedName.name - ).replace(/\./g, '')}`; + description = `${parsedName.root}.${StringUtils.classify(parsedName.name).replace(/\./g, '')}`; if (parsedName.type !== 'model') { description += StringUtils.classify(parsedName.type); @@ -284,10 +275,7 @@ const DefaultResolver = EmberObject.extend({ resolveTemplate(parsedName) { let templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); - return ( - getTemplate(templateName) || - getTemplate(StringUtils.decamelize(templateName)) - ); + return getTemplate(templateName) || getTemplate(StringUtils.decamelize(templateName)); }, /** @@ -364,9 +352,7 @@ const DefaultResolver = EmberObject.extend({ @protected */ resolveOther(parsedName) { - let className = - StringUtils.classify(parsedName.name) + - StringUtils.classify(parsedName.type); + let className = StringUtils.classify(parsedName.name) + StringUtils.classify(parsedName.type); let factory = get(parsedName.root, className); return factory; }, @@ -422,7 +408,7 @@ const DefaultResolver = EmberObject.extend({ let dasherizedName = StringUtils.dasherize(namePrefix); return `${type}:${dasherizedName}`; - } + }, }); export default DefaultResolver; @@ -445,12 +431,7 @@ if (DEBUG) { padding = new Array(60 - parsedName.fullName.length).join('.'); } - info( - symbol, - parsedName.fullName, - padding, - this.lookupDescription(parsedName.fullName) - ); - } + info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); + }, }); } diff --git a/packages/ember-application/lib/utils/validate-type.js b/packages/ember-application/lib/utils/validate-type.js index 6425a0c26c7..91de65df221 100644 --- a/packages/ember-application/lib/utils/validate-type.js +++ b/packages/ember-application/lib/utils/validate-type.js @@ -4,7 +4,7 @@ const VALIDATED_TYPES = { route: ['assert', 'isRouteFactory', 'Ember.Route'], component: ['deprecate', 'isComponentFactory', 'Ember.Component'], view: ['deprecate', 'isViewFactory', 'Ember.View'], - service: ['deprecate', 'isServiceFactory', 'Ember.Service'] + service: ['deprecate', 'isServiceFactory', 'Ember.Service'], }; export default function validateType(resolvedType, parsedName) { diff --git a/packages/ember-application/tests/system/application_instance_test.js b/packages/ember-application/tests/system/application_instance_test.js index 3eaae5dd94c..4cd387ed698 100644 --- a/packages/ember-application/tests/system/application_instance_test.js +++ b/packages/ember-application/tests/system/application_instance_test.js @@ -23,9 +23,7 @@ moduleFor( document.getElementById('qunit-fixture').innerHTML = `
HI
HI
`; - application = run(() => - Application.create({ rootElement: '#one', router: null }) - ); + application = run(() => Application.create({ rootElement: '#one', router: null })); } teardown() { @@ -41,29 +39,21 @@ moduleFor( document.getElementById('qunit-fixture').innerHTML = ''; } - ['@test an application instance can be created based upon an application']( - assert - ) { + ['@test an application instance can be created based upon an application'](assert) { appInstance = run(() => ApplicationInstance.create({ application })); assert.ok(appInstance, 'instance should be created'); - assert.equal( - appInstance.application, - application, - 'application should be set to parent' - ); + assert.equal(appInstance.application, application, 'application should be set to parent'); } - ['@test customEvents added to the application before setupEventDispatcher']( - assert - ) { + ['@test customEvents added to the application before setupEventDispatcher'](assert) { assert.expect(1); appInstance = run(() => ApplicationInstance.create({ application })); appInstance.setupRegistry(); application.customEvents = { - awesome: 'sauce' + awesome: 'sauce', }; let eventDispatcher = appInstance.lookup('event_dispatcher:main'); @@ -74,16 +64,14 @@ moduleFor( appInstance.setupEventDispatcher(); } - ['@test customEvents added to the application before setupEventDispatcher']( - assert - ) { + ['@test customEvents added to the application before setupEventDispatcher'](assert) { assert.expect(1); appInstance = run(() => ApplicationInstance.create({ application })); appInstance.setupRegistry(); application.customEvents = { - awesome: 'sauce' + awesome: 'sauce', }; let eventDispatcher = appInstance.lookup('event_dispatcher:main'); @@ -94,16 +82,14 @@ moduleFor( appInstance.setupEventDispatcher(); } - ['@test customEvents added to the application instance before setupEventDispatcher']( - assert - ) { + ['@test customEvents added to the application instance before setupEventDispatcher'](assert) { assert.expect(1); appInstance = run(() => ApplicationInstance.create({ application })); appInstance.setupRegistry(); appInstance.customEvents = { - awesome: 'sauce' + awesome: 'sauce', }; let eventDispatcher = appInstance.lookup('event_dispatcher:main'); @@ -114,9 +100,7 @@ moduleFor( appInstance.setupEventDispatcher(); } - ['@test unregistering a factory clears all cached instances of that factory']( - assert - ) { + ['@test unregistering a factory clears all cached instances of that factory'](assert) { assert.expect(5); appInstance = run(() => ApplicationInstance.create({ application })); @@ -128,10 +112,7 @@ moduleFor( let postController1 = appInstance.lookup('controller:post'); let postController1Factory = appInstance.factoryFor('controller:post'); - assert.ok( - postController1 instanceof PostController1, - 'precond - lookup creates instance' - ); + assert.ok(postController1 instanceof PostController1, 'precond - lookup creates instance'); assert.equal( PostController1, postController1Factory.class, @@ -143,15 +124,8 @@ moduleFor( let postController2 = appInstance.lookup('controller:post'); let postController2Factory = appInstance.factoryFor('controller:post'); - assert.ok( - postController2 instanceof PostController2, - 'lookup creates instance' - ); - assert.equal( - PostController2, - postController2Factory.class, - 'factoryFor().class matches' - ); + assert.ok(postController2 instanceof PostController2, 'lookup creates instance'); + assert.equal(PostController2, postController2Factory.class, 'factoryFor().class matches'); assert.notStrictEqual( postController1, @@ -160,9 +134,7 @@ moduleFor( ); } - ['@skip unregistering a factory clears caches with source of that factory']( - assert - ) { + ['@skip unregistering a factory clears caches with source of that factory'](assert) { assert.expect(1); appInstance = run(() => ApplicationInstance.create({ application })); @@ -173,10 +145,9 @@ moduleFor( appInstance.register('controller:post', PostController1); appInstance.lookup('controller:post'); - let postControllerLookupWithSource = appInstance.lookup( - 'controller:post', - { source: 'doesnt-even-matter' } - ); + let postControllerLookupWithSource = appInstance.lookup('controller:post', { + source: 'doesnt-even-matter', + }); appInstance.unregister('controller:post'); appInstance.register('controller:post', PostController2); @@ -185,7 +156,7 @@ moduleFor( assert.ok( postControllerLookupWithSource !== appInstance.lookup('controller:post', { - source: 'doesnt-even-matter' + source: 'doesnt-even-matter', }), 'lookup with source creates a new instance' ); @@ -208,11 +179,7 @@ moduleFor( return chatEngineInstance.boot().then(() => { assert.ok(true, 'boot successful'); - let registrations = [ - 'route:basic', - 'service:-routing', - 'service:-glimmer-environment' - ]; + let registrations = ['route:basic', 'service:-routing', 'service:-glimmer-environment']; registrations.forEach(key => { assert.strictEqual( @@ -228,13 +195,11 @@ moduleFor( '-view-registry:main', '-environment:main', 'service:-document', - 'event_dispatcher:main' + 'event_dispatcher:main', ]; let env = appInstance.lookup('-environment:main'); - singletons.push( - env.isInteractive ? 'renderer:-dom' : 'renderer:-inert' - ); + singletons.push(env.isInteractive ? 'renderer:-dom' : 'renderer:-inert'); singletons.forEach(key => { assert.strictEqual( @@ -250,7 +215,7 @@ moduleFor( assert ) { let namespace = EmberObject.create({ - Resolver: { create: function() {} } + Resolver: { create: function() {} }, }); let registry = Application.buildRegistry(namespace); diff --git a/packages/ember-application/tests/system/application_test.js b/packages/ember-application/tests/system/application_test.js index 1382b915977..15d795605c1 100644 --- a/packages/ember-application/tests/system/application_test.js +++ b/packages/ember-application/tests/system/application_test.js @@ -9,17 +9,14 @@ import { jQuery } from 'ember-views'; import { Controller, Object as EmberObject, _loaded } from 'ember-runtime'; import { setTemplates } from 'ember-glimmer'; import { privatize as P } from 'container'; -import { - verifyInjection, - verifyRegistration -} from '../test-helpers/registry-check'; +import { verifyInjection, verifyRegistration } from '../test-helpers/registry-check'; import { assign } from 'ember-utils'; import { moduleFor, ApplicationTestCase, AbstractTestCase, AutobootApplicationTestCase, - DefaultResolverApplicationTestCase + DefaultResolverApplicationTestCase, } from 'internal-test-helpers'; import { run } from 'ember-metal'; @@ -39,7 +36,7 @@ moduleFor( return assign(super.applicationOptions, { rootElement: '#one', router: null, - autoboot: true + autoboot: true, }); } @@ -56,12 +53,10 @@ moduleFor( } } - [`@test you can make a new application in a non-overlapping element`]( - assert - ) { + [`@test you can make a new application in a non-overlapping element`](assert) { let app = this.runTask(() => this.createSecondApplication({ - rootElement: '#two' + rootElement: '#two', }) ); @@ -73,7 +68,7 @@ moduleFor( expectAssertion(() => { this.runTask(() => this.createSecondApplication({ - rootElement: this.applicationOptions.rootElement + rootElement: this.applicationOptions.rootElement, }) ); }); @@ -83,7 +78,7 @@ moduleFor( expectAssertion(() => { this.runTask(() => this.createSecondApplication({ - rootElement: '#one-child' + rootElement: '#one-child', }) ); }); @@ -93,7 +88,7 @@ moduleFor( expectAssertion(() => { this.runTask(() => this.createSecondApplication({ - rootElement: '#one' + rootElement: '#one', }) ); }); @@ -130,72 +125,24 @@ moduleFor( verifyRegistration(assert, application, 'controller:basic'); verifyRegistration(assert, application, '-view-registry:main'); - verifyInjection( - assert, - application, - 'view', - '_viewRegistry', - '-view-registry:main' - ); - verifyInjection( - assert, - application, - 'route', - '_topLevelViewTemplate', - 'template:-outlet' - ); + verifyInjection(assert, application, 'view', '_viewRegistry', '-view-registry:main'); + verifyInjection(assert, application, 'route', '_topLevelViewTemplate', 'template:-outlet'); verifyRegistration(assert, application, 'route:basic'); verifyRegistration(assert, application, 'event_dispatcher:main'); - verifyInjection( - assert, - application, - 'router:main', - 'namespace', - 'application:main' - ); - verifyInjection( - assert, - application, - 'view:-outlet', - 'namespace', - 'application:main' - ); + verifyInjection(assert, application, 'router:main', 'namespace', 'application:main'); + verifyInjection(assert, application, 'view:-outlet', 'namespace', 'application:main'); verifyRegistration(assert, application, 'location:auto'); verifyRegistration(assert, application, 'location:hash'); verifyRegistration(assert, application, 'location:history'); verifyRegistration(assert, application, 'location:none'); - verifyInjection( - assert, - application, - 'controller', - 'target', - 'router:main' - ); - verifyInjection( - assert, - application, - 'controller', - 'namespace', - 'application:main' - ); + verifyInjection(assert, application, 'controller', 'target', 'router:main'); + verifyInjection(assert, application, 'controller', 'namespace', 'application:main'); verifyRegistration(assert, application, P`-bucket-cache:main`); - verifyInjection( - assert, - application, - 'router', - '_bucketCache', - P`-bucket-cache:main` - ); - verifyInjection( - assert, - application, - 'route', - '_bucketCache', - P`-bucket-cache:main` - ); + verifyInjection(assert, application, 'router', '_bucketCache', P`-bucket-cache:main`); + verifyInjection(assert, application, 'route', '_bucketCache', P`-bucket-cache:main`); verifyInjection(assert, application, 'route', '_router', 'router:main'); @@ -205,13 +152,7 @@ moduleFor( verifyRegistration(assert, application, 'component:link-to'); verifyRegistration(assert, application, 'service:-routing'); - verifyInjection( - assert, - application, - 'service:-routing', - 'router', - 'router:main' - ); + verifyInjection(assert, application, 'service:-routing', 'router', 'router:main'); // DEBUGGING verifyRegistration(assert, application, 'resolver-for-debugging:main'); @@ -249,32 +190,14 @@ moduleFor( 'updateOperations', 'service:-dom-changes' ); - verifyInjection( - assert, - application, - 'renderer', - 'env', - 'service:-glimmer-environment' - ); + verifyInjection(assert, application, 'renderer', 'env', 'service:-glimmer-environment'); verifyRegistration(assert, application, 'view:-outlet'); verifyRegistration(assert, application, 'renderer:-dom'); verifyRegistration(assert, application, 'renderer:-inert'); verifyRegistration(assert, application, P`template:components/-default`); verifyRegistration(assert, application, 'template:-outlet'); - verifyInjection( - assert, - application, - 'view:-outlet', - 'template', - 'template:-outlet' - ); - verifyInjection( - assert, - application, - 'template', - 'compiler', - P`template-compiler:main` - ); + verifyInjection(assert, application, 'view:-outlet', 'template', 'template:-outlet'); + verifyInjection(assert, application, 'template', 'compiler', P`template-compiler:main`); assert.deepEqual( application.registeredOptionsForType('helper'), @@ -301,7 +224,7 @@ moduleFor( get applicationOptions() { return assign(super.applicationOptions, { - autoboot: true + autoboot: true, }); } @@ -312,11 +235,7 @@ moduleFor( setNamespaceSearchDisabled(false); let Foo = (this.application.Foo = EmberObject.extend()); - assert.equal( - Foo.toString(), - 'TestApp.Foo', - 'Classes pick up their parent namespace' - ); + assert.equal(Foo.toString(), 'TestApp.Foo', 'Classes pick up their parent namespace'); } [`@test can specify custom router`](assert) { @@ -327,16 +246,13 @@ moduleFor( }); assert.ok( - this.application.__deprecatedInstance__.lookup('router:main') instanceof - MyRouter, + this.application.__deprecatedInstance__.lookup('router:main') instanceof MyRouter, 'application resolved the correct router' ); } [`@test Minimal Application initialized with just an application template`]() { - this.setupFixture( - '' - ); + this.setupFixture(''); this.runTask(() => this.createApplication()); this.assertInnerHTML('Hello World'); } @@ -376,7 +292,7 @@ moduleFor( this.runTask(() => { function registerRoute(application, name, callback) { let route = EmberRoute.extend({ - activate: callback + activate: callback, }); application.register('route:' + name, route); @@ -387,14 +303,12 @@ moduleFor( registerRoute(this, 'index', () => { assert.ok(true, 'last-minute route is activated'); }); - } + }, }); let app = this.createApplication({}, MyApplication); - registerRoute(app, 'application', () => - assert.ok(true, 'normal route is activated') - ); + registerRoute(app, 'application', () => assert.ok(true, 'normal route is activated')); }); } @@ -403,11 +317,7 @@ moduleFor( // This is not a public way to access the container; we just // need to make some assertions about the created router let router = this.applicationInstance.lookup('router:main'); - assert.equal( - router instanceof Router, - true, - 'Router was set from initialize call' - ); + assert.equal(router instanceof Router, true, 'Router was set from initialize call'); assert.equal( router.location instanceof NoneLocation, true, @@ -424,14 +334,8 @@ moduleFor( }); // This is not a public way to access the container; we just // need to make some assertions about the created router - let router = this.application.__deprecatedInstance__.lookup( - 'router:main' - ); - assert.equal( - router instanceof Router, - true, - 'Router was set from initialize call' - ); + let router = this.application.__deprecatedInstance__.lookup('router:main'); + assert.equal(router instanceof Router, true, 'Router was set from initialize call'); this.assertText('Hello!'); } @@ -442,7 +346,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - greeting: 'Hello!' + greeting: 'Hello!', }) ); }); @@ -497,8 +401,7 @@ moduleFor( }); assert.ok( - this.application.__deprecatedInstance__.lookup('router:main') instanceof - CustomRouter, + this.application.__deprecatedInstance__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router' ); } @@ -515,7 +418,7 @@ moduleFor( assert ) { let namespace = EmberObject.create({ - Resolver: { create: function() {} } + Resolver: { create: function() {} }, }); let registry = Application.buildRegistry(namespace); @@ -532,7 +435,7 @@ moduleFor( assert ) { let namespace = EmberObject.create({ - Resolver: { create() {} } + Resolver: { create() {} }, }); let registry = Application.buildRegistry(namespace); diff --git a/packages/ember-application/tests/system/bootstrap-test.js b/packages/ember-application/tests/system/bootstrap-test.js index d37705487d1..b799506cada 100644 --- a/packages/ember-application/tests/system/bootstrap-test.js +++ b/packages/ember-application/tests/system/bootstrap-test.js @@ -1,8 +1,5 @@ import { assign } from 'ember-utils'; -import { - moduleFor, - DefaultResolverApplicationTestCase -} from 'internal-test-helpers'; +import { moduleFor, DefaultResolverApplicationTestCase } from 'internal-test-helpers'; moduleFor( 'Application with default resolver and autoboot', @@ -19,13 +16,11 @@ moduleFor( get applicationOptions() { return assign(super.applicationOptions, { autoboot: true, - rootElement: '#app' + rootElement: '#app', }); } - ['@test templates in script tags are extracted at application creation']( - assert - ) { + ['@test templates in script tags are extracted at application creation'](assert) { this.runTask(() => this.createApplication()); assert.equal(document.getElementById('app').textContent, 'Hello World!'); } diff --git a/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js b/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js index 54cd2402611..9cf675282c1 100644 --- a/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js +++ b/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js @@ -1,9 +1,6 @@ import DefaultResolver from '../../../system/resolver'; import { assign } from 'ember-utils'; -import { - moduleFor, - DefaultResolverApplicationTestCase -} from 'internal-test-helpers'; +import { moduleFor, DefaultResolverApplicationTestCase } from 'internal-test-helpers'; moduleFor( 'Application with extended default resolver and autoboot', @@ -18,12 +15,12 @@ moduleFor( } else { return this._super(resolvable); } - } + }, }); return assign(super.applicationOptions, { Resolver, - autoboot: true + autoboot: true, }); } diff --git a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js index d527c37adb0..d91ef43f543 100644 --- a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js +++ b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js @@ -1,16 +1,8 @@ /* globals EmberDev */ -import { - moduleFor, - DefaultResolverApplicationTestCase -} from 'internal-test-helpers'; +import { moduleFor, DefaultResolverApplicationTestCase } from 'internal-test-helpers'; import { context } from 'ember-environment'; -import { - Controller, - Service, - Object as EmberObject, - Namespace -} from 'ember-runtime'; +import { Controller, Service, Object as EmberObject, Namespace } from 'ember-runtime'; import { Route } from 'ember-routing'; import { Component, Helper, helper as makeHelper } from 'ember-glimmer'; import { getDebugFunction, setDebugFunction } from 'ember-debug'; @@ -32,15 +24,10 @@ moduleFor( * applicationInstance API. */ - [`@test the default resolver looks up templates in Ember.TEMPLATES`]( - assert - ) { + [`@test the default resolver looks up templates in Ember.TEMPLATES`](assert) { let fooTemplate = this.addTemplate('foo', `foo template`); let fooBarTemplate = this.addTemplate('fooBar', `fooBar template`); - let fooBarBazTemplate = this.addTemplate( - 'fooBar/baz', - `fooBar/baz template` - ); + let fooBarBazTemplate = this.addTemplate('fooBar/baz', `fooBar/baz template`); assert.equal( this.applicationInstance.factoryFor('template:foo').class, @@ -61,15 +48,10 @@ moduleFor( [`@test the default resolver looks up basic name as no prefix`](assert) { let instance = this.applicationInstance.lookup('controller:basic'); - assert.ok( - Controller.detect(instance), - 'locator looks up correct controller' - ); + assert.ok(Controller.detect(instance), 'locator looks up correct controller'); } - [`@test the default resolver looks up arbitrary types on the namespace`]( - assert - ) { + [`@test the default resolver looks up arbitrary types on the namespace`](assert) { let Class = (this.application.FooManager = EmberObject.extend()); let resolvedClass = this.application.resolveRegistration('manager:foo'); assert.equal(Class, resolvedClass, 'looks up FooManager on application'); @@ -77,69 +59,45 @@ moduleFor( [`@test the default resolver resolves models on the namespace`](assert) { let Class = (this.application.Post = EmberObject.extend()); - let factoryClass = this.applicationInstance.factoryFor('model:post') - .class; + let factoryClass = this.applicationInstance.factoryFor('model:post').class; assert.equal(Class, factoryClass, 'looks up Post model on application'); } [`@test the default resolver resolves *:main on the namespace`](assert) { let Class = (this.application.FooBar = EmberObject.extend()); - let factoryClass = this.applicationInstance.factoryFor('foo-bar:main') - .class; - assert.equal( - Class, - factoryClass, - 'looks up FooBar type without name on application' - ); + let factoryClass = this.applicationInstance.factoryFor('foo-bar:main').class; + assert.equal(Class, factoryClass, 'looks up FooBar type without name on application'); } - [`@test the default resolver resolves container-registered helpers`]( - assert - ) { + [`@test the default resolver resolves container-registered helpers`](assert) { let shorthandHelper = makeHelper(() => {}); let helper = Helper.extend(); this.application.register('helper:shorthand', shorthandHelper); this.application.register('helper:complete', helper); - let lookedUpShorthandHelper = this.applicationInstance.factoryFor( - 'helper:shorthand' - ).class; + let lookedUpShorthandHelper = this.applicationInstance.factoryFor('helper:shorthand').class; - assert.ok( - lookedUpShorthandHelper.isHelperFactory, - 'shorthand helper isHelper' - ); + assert.ok(lookedUpShorthandHelper.isHelperFactory, 'shorthand helper isHelper'); - let lookedUpHelper = this.applicationInstance.factoryFor( - 'helper:complete' - ).class; + let lookedUpHelper = this.applicationInstance.factoryFor('helper:complete').class; assert.ok(lookedUpHelper.isHelperFactory, 'complete helper is factory'); assert.ok(helper.detect(lookedUpHelper), 'looked up complete helper'); } - [`@test the default resolver resolves container-registered helpers via lookupFor`]( - assert - ) { + [`@test the default resolver resolves container-registered helpers via lookupFor`](assert) { let shorthandHelper = makeHelper(() => {}); let helper = Helper.extend(); this.application.register('helper:shorthand', shorthandHelper); this.application.register('helper:complete', helper); - let lookedUpShorthandHelper = this.applicationInstance.factoryFor( - 'helper:shorthand' - ).class; + let lookedUpShorthandHelper = this.applicationInstance.factoryFor('helper:shorthand').class; - assert.ok( - lookedUpShorthandHelper.isHelperFactory, - 'shorthand helper isHelper' - ); + assert.ok(lookedUpShorthandHelper.isHelperFactory, 'shorthand helper isHelper'); - let lookedUpHelper = this.applicationInstance.factoryFor( - 'helper:complete' - ).class; + let lookedUpHelper = this.applicationInstance.factoryFor('helper:complete').class; assert.ok(lookedUpHelper.isHelperFactory, 'complete helper is factory'); assert.ok(helper.detect(lookedUpHelper), 'looked up complete helper'); @@ -152,28 +110,18 @@ moduleFor( this.application.ShorthandHelper = ShorthandHelper; this.application.CompleteHelper = CompleteHelper; - let resolvedShorthand = this.application.resolveRegistration( - 'helper:shorthand' - ); - let resolvedComplete = this.application.resolveRegistration( - 'helper:complete' - ); + let resolvedShorthand = this.application.resolveRegistration('helper:shorthand'); + let resolvedComplete = this.application.resolveRegistration('helper:complete'); assert.equal( resolvedShorthand, ShorthandHelper, 'resolve fetches the shorthand helper factory' ); - assert.equal( - resolvedComplete, - CompleteHelper, - 'resolve fetches the complete helper factory' - ); + assert.equal(resolvedComplete, CompleteHelper, 'resolve fetches the complete helper factory'); } - [`@test the default resolver resolves to the same instance, no matter the notation `]( - assert - ) { + [`@test the default resolver resolves to the same instance, no matter the notation `](assert) { this.application.NestedPostController = Controller.extend({}); assert.equal( @@ -259,9 +207,7 @@ moduleFor( }, /Expected service:foo to resolve to an Ember.Service but instead it was \.FooService\./); } - [`@test no deprecation warning for service factories that extend from Service`]( - assert - ) { + [`@test no deprecation warning for service factories that extend from Service`](assert) { assert.expect(0); this.application.FooService = Service.extend(); this.privateRegistry.resolve('service:foo'); @@ -288,13 +234,11 @@ moduleFor( assert.deepEqual(found, { 'helper:foo-bar': true, - 'helper:baz-qux': true + 'helper:baz-qux': true, }); } - [`@test knownForType is not required to be present on the resolver`]( - assert - ) { + [`@test knownForType is not required to be present on the resolver`](assert) { delete this.privateRegistry.resolver.knownForType; this.privateRegistry.resolver.knownForType('helper', () => {}); @@ -323,14 +267,10 @@ moduleFor( super.teardown(); } - [`@test the default resolver can look things up in other namespaces`]( - assert - ) { + [`@test the default resolver can look things up in other namespaces`](assert) { this.UserInterface.NavigationController = Controller.extend(); - let nav = this.applicationInstance.lookup( - 'controller:userInterface/navigation' - ); + let nav = this.applicationInstance.lookup('controller:userInterface/navigation'); assert.ok( nav instanceof this.UserInterface.NavigationController, @@ -372,17 +312,8 @@ moduleFor( this.application.ScoobyDoo = EmberObject.extend(); this.application.toString = () => 'App'; - setDebugFunction('info', function( - symbol, - name, - padding, - lookupDescription - ) { - assert.equal( - symbol, - '[✓]', - 'proper symbol is printed when a module is found' - ); + setDebugFunction('info', function(symbol, name, padding, lookupDescription) { + assert.equal(symbol, '[✓]', 'proper symbol is printed when a module is found'); assert.equal(name, 'doo:scooby', 'proper lookup value is logged'); assert.equal(lookupDescription, 'App.ScoobyDoo'); }); @@ -390,9 +321,7 @@ moduleFor( this.applicationInstance.resolveRegistration('doo:scooby'); } - [`@test the default resolver logs misses if 'LOG_RESOLVER' is set`]( - assert - ) { + [`@test the default resolver logs misses if 'LOG_RESOLVER' is set`](assert) { if (EmberDev && EmberDev.runningProdBuild) { assert.ok(true, 'Logging does not occur in production builds'); return; @@ -403,17 +332,8 @@ moduleFor( this.application.LOG_RESOLVER = true; this.application.toString = () => 'App'; - setDebugFunction('info', function( - symbol, - name, - padding, - lookupDescription - ) { - assert.equal( - symbol, - '[ ]', - 'proper symbol is printed when a module is not found' - ); + setDebugFunction('info', function(symbol, name, padding, lookupDescription) { + assert.equal(symbol, '[ ]', 'proper symbol is printed when a module is not found'); assert.equal(name, 'doo:scooby', 'proper lookup value is logged'); assert.equal(lookupDescription, 'App.ScoobyDoo'); }); @@ -435,11 +355,7 @@ moduleFor( this.applicationInstance.resolveRegistration('doo:scooby'); this.applicationInstance.resolveRegistration('doo:scrappy'); - assert.equal( - infoCount, - 0, - 'console.info should not be called if LOG_RESOLVER is not set' - ); + assert.equal(infoCount, 0, 'console.info should not be called if LOG_RESOLVER is not set'); } } ); diff --git a/packages/ember-application/tests/system/dependency_injection/normalization_test.js b/packages/ember-application/tests/system/dependency_injection/normalization_test.js index e5c4c75ec0a..12698a65c3a 100644 --- a/packages/ember-application/tests/system/dependency_injection/normalization_test.js +++ b/packages/ember-application/tests/system/dependency_injection/normalization_test.js @@ -24,50 +24,17 @@ moduleFor( assert.equal(registry.normalize('foo:bar'), 'foo:bar'); assert.equal(registry.normalize('controller:posts'), 'controller:posts'); - assert.equal( - registry.normalize('controller:posts_index'), - 'controller:postsIndex' - ); - assert.equal( - registry.normalize('controller:posts.index'), - 'controller:postsIndex' - ); - assert.equal( - registry.normalize('controller:posts-index'), - 'controller:postsIndex' - ); - assert.equal( - registry.normalize('controller:posts.post.index'), - 'controller:postsPostIndex' - ); - assert.equal( - registry.normalize('controller:posts_post.index'), - 'controller:postsPostIndex' - ); - assert.equal( - registry.normalize('controller:posts.post_index'), - 'controller:postsPostIndex' - ); - assert.equal( - registry.normalize('controller:posts.post-index'), - 'controller:postsPostIndex' - ); - assert.equal( - registry.normalize('controller:postsIndex'), - 'controller:postsIndex' - ); - assert.equal( - registry.normalize('controller:blogPosts.index'), - 'controller:blogPostsIndex' - ); - assert.equal( - registry.normalize('controller:blog/posts.index'), - 'controller:blog/postsIndex' - ); - assert.equal( - registry.normalize('controller:blog/posts-index'), - 'controller:blog/postsIndex' - ); + assert.equal(registry.normalize('controller:posts_index'), 'controller:postsIndex'); + assert.equal(registry.normalize('controller:posts.index'), 'controller:postsIndex'); + assert.equal(registry.normalize('controller:posts-index'), 'controller:postsIndex'); + assert.equal(registry.normalize('controller:posts.post.index'), 'controller:postsPostIndex'); + assert.equal(registry.normalize('controller:posts_post.index'), 'controller:postsPostIndex'); + assert.equal(registry.normalize('controller:posts.post_index'), 'controller:postsPostIndex'); + assert.equal(registry.normalize('controller:posts.post-index'), 'controller:postsPostIndex'); + assert.equal(registry.normalize('controller:postsIndex'), 'controller:postsIndex'); + assert.equal(registry.normalize('controller:blogPosts.index'), 'controller:blogPostsIndex'); + assert.equal(registry.normalize('controller:blog/posts.index'), 'controller:blog/postsIndex'); + assert.equal(registry.normalize('controller:blog/posts-index'), 'controller:blog/postsIndex'); assert.equal( registry.normalize('controller:blog/posts.post.index'), 'controller:blog/postsPostIndex' @@ -81,10 +48,7 @@ moduleFor( 'controller:blog/postsPostIndex' ); - assert.equal( - registry.normalize('template:blog/posts_index'), - 'template:blog/posts_index' - ); + assert.equal(registry.normalize('template:blog/posts_index'), 'template:blog/posts_index'); } ['@test normalization is indempotent'](assert) { @@ -92,14 +56,11 @@ moduleFor( 'controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', - 'template:foo_bar' + 'template:foo_bar', ]; examples.forEach(example => { - assert.equal( - registry.normalize(registry.normalize(example)), - registry.normalize(example) - ); + assert.equal(registry.normalize(registry.normalize(example)), registry.normalize(example)); }); } } diff --git a/packages/ember-application/tests/system/dependency_injection/to_string_test.js b/packages/ember-application/tests/system/dependency_injection/to_string_test.js index 3a8d744c51e..14b75623bc9 100644 --- a/packages/ember-application/tests/system/dependency_injection/to_string_test.js +++ b/packages/ember-application/tests/system/dependency_injection/to_string_test.js @@ -4,7 +4,7 @@ import { moduleFor, ApplicationTestCase, ModuleBasedTestResolver, - DefaultResolverApplicationTestCase + DefaultResolverApplicationTestCase, } from 'internal-test-helpers'; moduleFor( @@ -22,22 +22,14 @@ moduleFor( ['@test factories'](assert) { let PostFactory = this.applicationInstance.factoryFor('model:post').class; - assert.equal( - PostFactory.toString(), - '.Post', - 'expecting the model to be post' - ); + assert.equal(PostFactory.toString(), '.Post', 'expecting the model to be post'); } ['@test instances'](assert) { let post = this.applicationInstance.lookup('model:post'); let guid = guidFor(post); - assert.equal( - post.toString(), - '<.Post:' + guid + '>', - 'expecting the model to be post' - ); + assert.equal(post.toString(), '<.Post:' + guid + '>', 'expecting the model to be post'); } } ); @@ -55,7 +47,7 @@ moduleFor( makeToString(_, fullName) { return fullName; } - } + }, }); } diff --git a/packages/ember-application/tests/system/dependency_injection_test.js b/packages/ember-application/tests/system/dependency_injection_test.js index 0103bb84d58..dde4ccf4d8b 100644 --- a/packages/ember-application/tests/system/dependency_injection_test.js +++ b/packages/ember-application/tests/system/dependency_injection_test.js @@ -24,20 +24,18 @@ moduleFor( application.PostIndexController = EmberObject.extend({}); application.register('model:person', application.Person, { - singleton: false + singleton: false, }); application.register('model:user', application.User, { - singleton: false + singleton: false, }); application.register('fruit:favorite', application.Orange); application.register('communication:main', application.Email, { - singleton: false + singleton: false, + }); + application.register('controller:postIndex', application.PostIndexController, { + singleton: true, }); - application.register( - 'controller:postIndex', - application.PostIndexController, - { singleton: true } - ); registry = application.__registry__; locator = application.__container__; @@ -55,9 +53,7 @@ moduleFor( let dotNotationController = locator.lookup('controller:post.index'); let camelCaseController = locator.lookup('controller:postIndex'); - assert.ok( - dotNotationController instanceof application.PostIndexController - ); + assert.ok(dotNotationController instanceof application.PostIndexController); assert.ok(camelCaseController instanceof application.PostIndexController); assert.equal(dotNotationController, camelCaseController); @@ -68,10 +64,7 @@ moduleFor( assert.equal(registry.resolve('model:user'), application.User); assert.equal(registry.resolve('fruit:favorite'), application.Orange); assert.equal(registry.resolve('communication:main'), application.Email); - assert.equal( - registry.resolve('controller:postIndex'), - application.PostIndexController - ); + assert.equal(registry.resolve('controller:postIndex'), application.PostIndexController); assert.equal( locator.lookup('fruit:favorite'), diff --git a/packages/ember-application/tests/system/engine_initializers_test.js b/packages/ember-application/tests/system/engine_initializers_test.js index ebcbebcc04a..99a819442c0 100644 --- a/packages/ember-application/tests/system/engine_initializers_test.js +++ b/packages/ember-application/tests/system/engine_initializers_test.js @@ -42,7 +42,7 @@ moduleFor( name: 'initializer', initialize(engine) { assert.ok(engine instanceof Engine, 'initialize is passed an Engine'); - } + }, }); myEngine = MyEngine.create(); @@ -58,7 +58,7 @@ moduleFor( after: 'third', initialize() { order.push('fourth'); - } + }, }); MyEngine.initializer({ @@ -67,7 +67,7 @@ moduleFor( before: 'third', initialize() { order.push('second'); - } + }, }); MyEngine.initializer({ @@ -76,7 +76,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyEngine.initializer({ @@ -84,39 +84,30 @@ moduleFor( before: 'second', initialize() { order.push('first'); - } + }, }); MyEngine.initializer({ name: 'third', initialize() { order.push('third'); - } + }, }); MyEngine.initializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); myEngine = MyEngine.create(); myEngineInstance = myEngine.buildInstance(); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } - ['@test initializers can be registered in a specified order as an array']( - assert - ) { + ['@test initializers can be registered in a specified order as an array'](assert) { let order = []; MyEngine = Engine.extend(); @@ -125,7 +116,7 @@ moduleFor( name: 'third', initialize() { order.push('third'); - } + }, }); MyEngine.initializer({ @@ -134,7 +125,7 @@ moduleFor( before: ['third', 'fourth'], initialize() { order.push('second'); - } + }, }); MyEngine.initializer({ @@ -142,7 +133,7 @@ moduleFor( after: ['second', 'third'], initialize() { order.push('fourth'); - } + }, }); MyEngine.initializer({ @@ -151,7 +142,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyEngine.initializer({ @@ -159,27 +150,20 @@ moduleFor( before: ['second'], initialize() { order.push('first'); - } + }, }); MyEngine.initializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); myEngine = MyEngine.create(); myEngineInstance = myEngine.buildInstance(); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } ['@test initializers can have multiple dependencies'](assert) { @@ -192,34 +176,34 @@ moduleFor( before: 'b', initialize() { order.push('a'); - } + }, }; let b = { name: 'b', initialize() { order.push('b'); - } + }, }; let c = { name: 'c', after: 'b', initialize() { order.push('c'); - } + }, }; let afterB = { name: 'after b', after: 'b', initialize() { order.push('after b'); - } + }, }; let afterC = { name: 'after c', after: 'c', initialize() { order.push('after c'); - } + }, }; MyEngine.initializer(b); @@ -233,19 +217,11 @@ moduleFor( assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); - assert.ok( - order.indexOf(b.name) < order.indexOf(afterB.name), - 'b < afterB' - ); - assert.ok( - order.indexOf(c.name) < order.indexOf(afterC.name), - 'c < afterC' - ); + assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); } - ['@test initializers set on Engine subclasses are not shared between engines']( - assert - ) { + ['@test initializers set on Engine subclasses are not shared between engines'](assert) { let firstInitializerRunCount = 0; let secondInitializerRunCount = 0; let FirstEngine = Engine.extend(); @@ -254,7 +230,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondEngine = Engine.extend(); @@ -263,36 +239,20 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); let firstEngine = FirstEngine.create(); let firstEngineInstance = firstEngine.buildInstance(); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 0, - 'first initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer only was run'); + assert.equal(secondInitializerRunCount, 0, 'first initializer only was run'); let secondEngine = SecondEngine.create(); let secondEngineInstance = secondEngine.buildInstance(); - assert.equal( - firstInitializerRunCount, - 1, - 'second initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 1, - 'second initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'second initializer only was run'); + assert.equal(secondInitializerRunCount, 1, 'second initializer only was run'); run(function() { firstEngineInstance.destroy(); @@ -312,7 +272,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondEngine = FirstEngine.extend(); @@ -321,7 +281,7 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); let firstEngine = FirstEngine.create(); @@ -342,11 +302,7 @@ moduleFor( let secondEngine = SecondEngine.create(); let secondEngineInstance = secondEngine.buildInstance(); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer was run when subclass created' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); assert.equal( secondInitializerRunCount, 1, @@ -369,20 +325,20 @@ moduleFor( FirstEngine.initializer({ name: 'abc', - initialize() {} + initialize() {}, }); expectAssertion(function() { FirstEngine.initializer({ name: 'abc', - initialize() {} + initialize() {}, }); }); let SecondEngine = Engine.extend(); SecondEngine.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); assert.ok(true, 'Two engines can have initializers named the same.'); @@ -397,12 +353,8 @@ moduleFor( name: 'coolInitializer', myProperty: 'cool', initialize() { - assert.equal( - this.myProperty, - 'cool', - 'should have access to its own context' - ); - } + assert.equal(this.myProperty, 'cool', 'should have access to its own context'); + }, }); myEngine = MyEngine.create(); diff --git a/packages/ember-application/tests/system/engine_instance_initializers_test.js b/packages/ember-application/tests/system/engine_instance_initializers_test.js index e85cdef15d6..1efc2a34ef6 100644 --- a/packages/ember-application/tests/system/engine_instance_initializers_test.js +++ b/packages/ember-application/tests/system/engine_instance_initializers_test.js @@ -14,7 +14,7 @@ function buildEngineInstance(EngineClass) { }, resolveRegistration() { return {}; - } + }, }); return engineInstance; } @@ -56,11 +56,8 @@ moduleFor( MyEngine.instanceInitializer({ name: 'initializer', initialize(instance) { - assert.ok( - instance instanceof EngineInstance, - 'initialize is passed an engine instance' - ); - } + assert.ok(instance instanceof EngineInstance, 'initialize is passed an engine instance'); + }, }); myEngine = MyEngine.create(); @@ -78,7 +75,7 @@ moduleFor( after: 'third', initialize() { order.push('fourth'); - } + }, }); MyEngine.instanceInitializer({ @@ -87,7 +84,7 @@ moduleFor( before: 'third', initialize() { order.push('second'); - } + }, }); MyEngine.instanceInitializer({ @@ -96,7 +93,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyEngine.instanceInitializer({ @@ -104,41 +101,32 @@ moduleFor( before: 'second', initialize() { order.push('first'); - } + }, }); MyEngine.instanceInitializer({ name: 'third', initialize() { order.push('third'); - } + }, }); MyEngine.instanceInitializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); myEngine = MyEngine.create(); myEngineInstance = buildEngineInstance(myEngine); return myEngineInstance.boot().then(() => { - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); }); } - ['@test initializers can be registered in a specified order as an array']( - assert - ) { + ['@test initializers can be registered in a specified order as an array'](assert) { let order = []; MyEngine = Engine.extend(); @@ -146,7 +134,7 @@ moduleFor( name: 'third', initialize() { order.push('third'); - } + }, }); MyEngine.instanceInitializer({ @@ -155,7 +143,7 @@ moduleFor( before: ['third', 'fourth'], initialize() { order.push('second'); - } + }, }); MyEngine.instanceInitializer({ @@ -163,7 +151,7 @@ moduleFor( after: ['second', 'third'], initialize() { order.push('fourth'); - } + }, }); MyEngine.instanceInitializer({ @@ -172,7 +160,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyEngine.instanceInitializer({ @@ -180,28 +168,21 @@ moduleFor( before: ['second'], initialize() { order.push('first'); - } + }, }); MyEngine.instanceInitializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); myEngine = MyEngine.create(); myEngineInstance = buildEngineInstance(myEngine); return myEngineInstance.boot().then(() => { - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); }); } @@ -215,34 +196,34 @@ moduleFor( before: 'b', initialize() { order.push('a'); - } + }, }; let b = { name: 'b', initialize() { order.push('b'); - } + }, }; let c = { name: 'c', after: 'b', initialize() { order.push('c'); - } + }, }; let afterB = { name: 'after b', after: 'b', initialize() { order.push('after b'); - } + }, }; let afterC = { name: 'after c', after: 'c', initialize() { order.push('after c'); - } + }, }; MyEngine.instanceInitializer(b); @@ -257,20 +238,12 @@ moduleFor( return myEngineInstance.boot().then(() => { assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); - assert.ok( - order.indexOf(b.name) < order.indexOf(afterB.name), - 'b < afterB' - ); - assert.ok( - order.indexOf(c.name) < order.indexOf(afterC.name), - 'c < afterC' - ); + assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); }); } - ['@test initializers set on Engine subclasses should not be shared between engines']( - assert - ) { + ['@test initializers set on Engine subclasses should not be shared between engines'](assert) { let firstInitializerRunCount = 0; let secondInitializerRunCount = 0; let FirstEngine = Engine.extend(); @@ -280,7 +253,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondEngine = Engine.extend(); @@ -290,7 +263,7 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); firstEngine = FirstEngine.create(); @@ -299,32 +272,16 @@ moduleFor( return firstEngineInstance .boot() .then(() => { - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 0, - 'first initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer only was run'); + assert.equal(secondInitializerRunCount, 0, 'first initializer only was run'); secondEngine = SecondEngine.create(); secondEngineInstance = buildEngineInstance(secondEngine); return secondEngineInstance.boot(); }) .then(() => { - assert.equal( - firstInitializerRunCount, - 1, - 'second initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 1, - 'second initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'second initializer only was run'); + assert.equal(secondInitializerRunCount, 1, 'second initializer only was run'); run(() => { firstEngineInstance.destroy(); @@ -345,7 +302,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondEngine = FirstEngine.extend(); @@ -354,7 +311,7 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); let firstEngine = FirstEngine.create(); @@ -410,20 +367,20 @@ moduleFor( FirstEngine.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); expectAssertion(() => { FirstEngine.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); }); let SecondEngine = Engine.extend(); SecondEngine.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); assert.ok(true, 'Two engines can have initializers named the same.'); @@ -438,12 +395,8 @@ moduleFor( name: 'coolInitializer', myProperty: 'cool', initialize() { - assert.equal( - this.myProperty, - 'cool', - 'should have access to its own context' - ); - } + assert.equal(this.myProperty, 'cool', 'should have access to its own context'); + }, }); myEngine = MyEngine.create(); diff --git a/packages/ember-application/tests/system/engine_instance_test.js b/packages/ember-application/tests/system/engine_instance_test.js index 0ff200670a7..cb427dba261 100644 --- a/packages/ember-application/tests/system/engine_instance_test.js +++ b/packages/ember-application/tests/system/engine_instance_test.js @@ -28,9 +28,7 @@ moduleFor( } } - ['@test an engine instance can be created based upon a base engine']( - assert - ) { + ['@test an engine instance can be created based upon a base engine'](assert) { run(() => { engineInstance = EngineInstance.create({ base: engine }); }); @@ -39,9 +37,7 @@ moduleFor( assert.equal(engineInstance.base, engine, 'base should be set to engine'); } - ['@test unregistering a factory clears all cached instances of that factory']( - assert - ) { + ['@test unregistering a factory clears all cached instances of that factory'](assert) { assert.expect(3); engineInstance = run(() => EngineInstance.create({ base: engine })); @@ -106,10 +102,7 @@ moduleFor( chatEngineInstance = engineInstance.buildChildEngineInstance('chat'); }); - assert.ok( - chatEngineInstance, - 'child engine instance successfully created' - ); + assert.ok(chatEngineInstance, 'child engine instance successfully created'); assert.strictEqual( getEngineParent(chatEngineInstance), diff --git a/packages/ember-application/tests/system/engine_parent_test.js b/packages/ember-application/tests/system/engine_parent_test.js index c977a16f2e4..6d2869d59dd 100644 --- a/packages/ember-application/tests/system/engine_parent_test.js +++ b/packages/ember-application/tests/system/engine_parent_test.js @@ -1,8 +1,4 @@ -import { - getEngineParent, - setEngineParent, - ENGINE_PARENT -} from '../../system/engine-parent'; +import { getEngineParent, setEngineParent, ENGINE_PARENT } from '../../system/engine-parent'; import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers'; moduleFor( @@ -14,19 +10,11 @@ moduleFor( let engine = {}; let parent = {}; - assert.strictEqual( - getEngineParent(engine), - undefined, - 'parent has not been set' - ); + assert.strictEqual(getEngineParent(engine), undefined, 'parent has not been set'); setEngineParent(engine, parent); - assert.strictEqual( - getEngineParent(engine), - parent, - 'parent has been set' - ); + assert.strictEqual(getEngineParent(engine), parent, 'parent has been set'); assert.strictEqual( engine[ENGINE_PARENT], parent, diff --git a/packages/ember-application/tests/system/engine_test.js b/packages/ember-application/tests/system/engine_test.js index 0d9315d8722..d10f1582642 100644 --- a/packages/ember-application/tests/system/engine_test.js +++ b/packages/ember-application/tests/system/engine_test.js @@ -3,10 +3,7 @@ import { run } from 'ember-metal'; import Engine from '../../system/engine'; import { Object as EmberObject } from 'ember-runtime'; import { privatize as P } from 'container'; -import { - verifyInjection, - verifyRegistration -} from '../test-helpers/registry-check'; +import { verifyInjection, verifyRegistration } from '../test-helpers/registry-check'; import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers'; let engine; @@ -58,51 +55,15 @@ moduleFor( `optionsForType 'view'` ); verifyRegistration(assert, engine, 'controller:basic'); - verifyInjection( - assert, - engine, - 'view', - '_viewRegistry', - '-view-registry:main' - ); - verifyInjection( - assert, - engine, - 'route', - '_topLevelViewTemplate', - 'template:-outlet' - ); - verifyInjection( - assert, - engine, - 'view:-outlet', - 'namespace', - 'application:main' - ); + verifyInjection(assert, engine, 'view', '_viewRegistry', '-view-registry:main'); + verifyInjection(assert, engine, 'route', '_topLevelViewTemplate', 'template:-outlet'); + verifyInjection(assert, engine, 'view:-outlet', 'namespace', 'application:main'); verifyInjection(assert, engine, 'controller', 'target', 'router:main'); - verifyInjection( - assert, - engine, - 'controller', - 'namespace', - 'application:main' - ); + verifyInjection(assert, engine, 'controller', 'namespace', 'application:main'); - verifyInjection( - assert, - engine, - 'router', - '_bucketCache', - P`-bucket-cache:main` - ); - verifyInjection( - assert, - engine, - 'route', - '_bucketCache', - P`-bucket-cache:main` - ); + verifyInjection(assert, engine, 'router', '_bucketCache', P`-bucket-cache:main`); + verifyInjection(assert, engine, 'route', '_bucketCache', P`-bucket-cache:main`); verifyInjection(assert, engine, 'route', '_router', 'router:main'); @@ -112,13 +73,7 @@ moduleFor( verifyRegistration(assert, engine, 'component:link-to'); verifyRegistration(assert, engine, 'service:-routing'); - verifyInjection( - assert, - engine, - 'service:-routing', - 'router', - 'router:main' - ); + verifyInjection(assert, engine, 'service:-routing', 'router', 'router:main'); // DEBUGGING verifyRegistration(assert, engine, 'resolver-for-debugging:main'); @@ -139,13 +94,7 @@ moduleFor( verifyRegistration(assert, engine, 'container-debug-adapter:main'); verifyRegistration(assert, engine, 'component-lookup:main'); - verifyInjection( - assert, - engine, - 'service:-dom-changes', - 'document', - 'service:-document' - ); + verifyInjection(assert, engine, 'service:-dom-changes', 'document', 'service:-document'); verifyInjection( assert, engine, @@ -156,20 +105,8 @@ moduleFor( verifyRegistration(assert, engine, 'view:-outlet'); verifyRegistration(assert, engine, P`template:components/-default`); verifyRegistration(assert, engine, 'template:-outlet'); - verifyInjection( - assert, - engine, - 'view:-outlet', - 'template', - 'template:-outlet' - ); - verifyInjection( - assert, - engine, - 'template', - 'compiler', - P`template-compiler:main` - ); + verifyInjection(assert, engine, 'view:-outlet', 'template', 'template:-outlet'); + verifyInjection(assert, engine, 'template', 'compiler', P`template-compiler:main`); assert.deepEqual( engine.registeredOptionsForType('helper'), { instantiate: false }, diff --git a/packages/ember-application/tests/system/initializers_test.js b/packages/ember-application/tests/system/initializers_test.js index 96c24d1b565..ee37179fc88 100644 --- a/packages/ember-application/tests/system/initializers_test.js +++ b/packages/ember-application/tests/system/initializers_test.js @@ -13,7 +13,7 @@ moduleFor( get applicationOptions() { return assign(super.applicationOptions, { - rootElement: '#one' + rootElement: '#one', }); } @@ -21,7 +21,7 @@ moduleFor( let myOptions = assign( this.applicationOptions, { - rootElement: '#two' + rootElement: '#two', }, options ); @@ -60,13 +60,13 @@ moduleFor( name: 'initializer', initialize() { throw new Error('boot failure'); - } + }, }); this.runTask(() => { this.createApplication( { - autoboot: false + autoboot: false, }, MyApplication ); @@ -78,16 +78,10 @@ moduleFor( this.runTask(() => { app.boot().then( () => { - assert.ok( - false, - 'The boot promise should not resolve when there is a boot error' - ); + assert.ok(false, 'The boot promise should not resolve when there is a boot error'); }, error => { - assert.ok( - error instanceof Error, - 'The boot promise should reject with an error' - ); + assert.ok(error instanceof Error, 'The boot promise should reject with an error'); assert.equal(error.message, 'boot failure'); } ); @@ -104,11 +98,8 @@ moduleFor( MyApplication.initializer({ name: 'initializer', initialize(App) { - assert.ok( - App instanceof Application, - 'initialize is passed an Application' - ); - } + assert.ok(App instanceof Application, 'initialize is passed an Application'); + }, }); this.runTask(() => this.createApplication({}, MyApplication)); @@ -123,7 +114,7 @@ moduleFor( after: 'third', initialize() { order.push('fourth'); - } + }, }); MyApplication.initializer({ @@ -132,7 +123,7 @@ moduleFor( before: 'third', initialize() { order.push('second'); - } + }, }); MyApplication.initializer({ @@ -141,7 +132,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyApplication.initializer({ @@ -149,38 +140,29 @@ moduleFor( before: 'second', initialize() { order.push('first'); - } + }, }); MyApplication.initializer({ name: 'third', initialize() { order.push('third'); - } + }, }); MyApplication.initializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } - [`@test initializers can be registered in a specified order as an array`]( - assert - ) { + [`@test initializers can be registered in a specified order as an array`](assert) { let order = []; let MyApplication = Application.extend(); @@ -188,7 +170,7 @@ moduleFor( name: 'third', initialize() { order.push('third'); - } + }, }); MyApplication.initializer({ @@ -197,7 +179,7 @@ moduleFor( before: ['third', 'fourth'], initialize() { order.push('second'); - } + }, }); MyApplication.initializer({ @@ -205,7 +187,7 @@ moduleFor( after: ['second', 'third'], initialize() { order.push('fourth'); - } + }, }); MyApplication.initializer({ @@ -214,7 +196,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyApplication.initializer({ @@ -222,26 +204,19 @@ moduleFor( before: ['second'], initialize() { order.push('first'); - } + }, }); MyApplication.initializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } [`@test initializers can have multiple dependencies`](assert) { @@ -252,34 +227,34 @@ moduleFor( before: 'b', initialize() { order.push('a'); - } + }, }; let b = { name: 'b', initialize() { order.push('b'); - } + }, }; let c = { name: 'c', after: 'b', initialize() { order.push('c'); - } + }, }; let afterB = { name: 'after b', after: 'b', initialize() { order.push('after b'); - } + }, }; let afterC = { name: 'after c', after: 'c', initialize() { order.push('after c'); - } + }, }; MyApplication.initializer(b); @@ -292,19 +267,11 @@ moduleFor( assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); - assert.ok( - order.indexOf(b.name) < order.indexOf(afterB.name), - 'b < afterB' - ); - assert.ok( - order.indexOf(c.name) < order.indexOf(afterC.name), - 'c < afterC' - ); + assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); } - [`@test initializers set on Application subclasses are not shared between apps`]( - assert - ) { + [`@test initializers set on Application subclasses are not shared between apps`](assert) { let firstInitializerRunCount = 0; let secondInitializerRunCount = 0; let FirstApp = Application.extend(); @@ -313,7 +280,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondApp = Application.extend(); @@ -322,34 +289,18 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); this.runTask(() => this.createApplication({}, FirstApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 0, - 'first initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer only was run'); + assert.equal(secondInitializerRunCount, 0, 'first initializer only was run'); this.runTask(() => this.createSecondApplication({}, SecondApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'second initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 1, - 'second initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'second initializer only was run'); + assert.equal(secondInitializerRunCount, 1, 'second initializer only was run'); } [`@test initializers are concatenated`](assert) { @@ -361,7 +312,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondApp = FirstApp.extend(); @@ -369,7 +320,7 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); this.runTask(() => this.createApplication({}, FirstApp)); @@ -388,11 +339,7 @@ moduleFor( firstInitializerRunCount = 0; this.runTask(() => this.createSecondApplication({}, SecondApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer was run when subclass created' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); assert.equal( secondInitializerRunCount, 1, @@ -407,20 +354,20 @@ moduleFor( FirstApp.initializer({ name: 'abc', - initialize() {} + initialize() {}, }); expectAssertion(() => { FirstApp.initializer({ name: 'abc', - initialize() {} + initialize() {}, }); }); let SecondApp = Application.extend(); SecondApp.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); assert.ok(true, 'Two apps can have initializers named the same.'); @@ -434,12 +381,8 @@ moduleFor( name: 'coolInitializer', myProperty: 'cool', initialize() { - assert.equal( - this.myProperty, - 'cool', - 'should have access to its own context' - ); - } + assert.equal(this.myProperty, 'cool', 'should have access to its own context'); + }, }); this.runTask(() => this.createApplication({}, MyApplication)); diff --git a/packages/ember-application/tests/system/instance_initializers_test.js b/packages/ember-application/tests/system/instance_initializers_test.js index 5e8e5e1f9d7..3b165a9dde0 100644 --- a/packages/ember-application/tests/system/instance_initializers_test.js +++ b/packages/ember-application/tests/system/instance_initializers_test.js @@ -13,7 +13,7 @@ moduleFor( get applicationOptions() { return assign(super.applicationOptions, { - rootElement: '#one' + rootElement: '#one', }); } @@ -21,7 +21,7 @@ moduleFor( let myOptions = assign( this.applicationOptions, { - rootElement: '#two' + rootElement: '#two', }, options ); @@ -61,7 +61,7 @@ moduleFor( instance instanceof ApplicationInstance, 'initialize is passed an application instance' ); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); @@ -76,7 +76,7 @@ moduleFor( after: 'third', initialize() { order.push('fourth'); - } + }, }); MyApplication.instanceInitializer({ @@ -85,7 +85,7 @@ moduleFor( before: 'third', initialize() { order.push('second'); - } + }, }); MyApplication.instanceInitializer({ @@ -94,7 +94,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyApplication.instanceInitializer({ @@ -102,38 +102,29 @@ moduleFor( before: 'second', initialize() { order.push('first'); - } + }, }); MyApplication.instanceInitializer({ name: 'third', initialize() { order.push('third'); - } + }, }); MyApplication.instanceInitializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } - [`@test initializers can be registered in a specified order as an array`]( - assert - ) { + [`@test initializers can be registered in a specified order as an array`](assert) { let order = []; let MyApplication = Application.extend(); @@ -141,7 +132,7 @@ moduleFor( name: 'third', initialize() { order.push('third'); - } + }, }); MyApplication.instanceInitializer({ @@ -150,7 +141,7 @@ moduleFor( before: ['third', 'fourth'], initialize() { order.push('second'); - } + }, }); MyApplication.instanceInitializer({ @@ -158,7 +149,7 @@ moduleFor( after: ['second', 'third'], initialize() { order.push('fourth'); - } + }, }); MyApplication.instanceInitializer({ @@ -167,7 +158,7 @@ moduleFor( before: 'sixth', initialize() { order.push('fifth'); - } + }, }); MyApplication.instanceInitializer({ @@ -175,26 +166,19 @@ moduleFor( before: ['second'], initialize() { order.push('first'); - } + }, }); MyApplication.instanceInitializer({ name: 'sixth', initialize() { order.push('sixth'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); - assert.deepEqual(order, [ - 'first', - 'second', - 'third', - 'fourth', - 'fifth', - 'sixth' - ]); + assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']); } [`@test initializers can have multiple dependencies`](assert) { @@ -205,34 +189,34 @@ moduleFor( before: 'b', initialize() { order.push('a'); - } + }, }; let b = { name: 'b', initialize() { order.push('b'); - } + }, }; let c = { name: 'c', after: 'b', initialize() { order.push('c'); - } + }, }; let afterB = { name: 'after b', after: 'b', initialize() { order.push('after b'); - } + }, }; let afterC = { name: 'after c', after: 'c', initialize() { order.push('after c'); - } + }, }; MyApplication.instanceInitializer(b); @@ -245,19 +229,11 @@ moduleFor( assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b'); assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c'); - assert.ok( - order.indexOf(b.name) < order.indexOf(afterB.name), - 'b < afterB' - ); - assert.ok( - order.indexOf(c.name) < order.indexOf(afterC.name), - 'c < afterC' - ); + assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB'); + assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC'); } - [`@test initializers set on Application subclasses should not be shared between apps`]( - assert - ) { + [`@test initializers set on Application subclasses should not be shared between apps`](assert) { let firstInitializerRunCount = 0; let secondInitializerRunCount = 0; let FirstApp = Application.extend(); @@ -266,7 +242,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondApp = Application.extend(); @@ -274,34 +250,18 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); this.runTask(() => this.createApplication({}, FirstApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 0, - 'first initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer only was run'); + assert.equal(secondInitializerRunCount, 0, 'first initializer only was run'); this.runTask(() => this.createSecondApplication({}, SecondApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'second initializer only was run' - ); - assert.equal( - secondInitializerRunCount, - 1, - 'second initializer only was run' - ); + assert.equal(firstInitializerRunCount, 1, 'second initializer only was run'); + assert.equal(secondInitializerRunCount, 1, 'second initializer only was run'); } [`@test initializers are concatenated`](assert) { @@ -313,7 +273,7 @@ moduleFor( name: 'first', initialize() { firstInitializerRunCount++; - } + }, }); let SecondApp = FirstApp.extend(); @@ -321,7 +281,7 @@ moduleFor( name: 'second', initialize() { secondInitializerRunCount++; - } + }, }); this.runTask(() => this.createApplication({}, FirstApp)); @@ -340,11 +300,7 @@ moduleFor( firstInitializerRunCount = 0; this.runTask(() => this.createSecondApplication({}, SecondApp)); - assert.equal( - firstInitializerRunCount, - 1, - 'first initializer was run when subclass created' - ); + assert.equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); assert.equal( secondInitializerRunCount, 1, @@ -358,13 +314,13 @@ moduleFor( let FirstApp = Application.extend(); FirstApp.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); expectAssertion(function() { FirstApp.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); }); @@ -373,7 +329,7 @@ moduleFor( let SecondApp = Application.extend(); SecondApp.instanceInitializer({ name: 'abc', - initialize() {} + initialize() {}, }); this.runTask(() => this.createSecondApplication({}, SecondApp)); @@ -388,7 +344,7 @@ moduleFor( ready() { assert.ok(true, 'ready is called'); readyWasCalled = false; - } + }, }); let readyWasCalled = false; @@ -396,7 +352,7 @@ moduleFor( name: 'initializer', initialize() { assert.ok(!readyWasCalled, 'ready is not yet called'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); @@ -411,12 +367,8 @@ moduleFor( name: 'coolInitializer', myProperty: 'cool', initialize() { - assert.equal( - this.myProperty, - 'cool', - 'should have access to its own context' - ); - } + assert.equal(this.myProperty, 'cool', 'should have access to its own context'); + }, }); this.runTask(() => this.createApplication({}, MyApplication)); @@ -431,7 +383,7 @@ moduleFor( name: 'giveMeAnInstance', initialize(instance) { assert.ok(!!instance, 'Initializer got an instance'); - } + }, }); this.runTask(() => this.createApplication({}, MyApplication)); diff --git a/packages/ember-application/tests/system/logging_test.js b/packages/ember-application/tests/system/logging_test.js index d23f0d91d49..3e00f1c3e46 100644 --- a/packages/ember-application/tests/system/logging_test.js +++ b/packages/ember-application/tests/system/logging_test.js @@ -41,7 +41,7 @@ moduleFor( class extends LoggingApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { - LOG_ACTIVE_GENERATION: true + LOG_ACTIVE_GENERATION: true, }); } @@ -68,22 +68,10 @@ moduleFor( 1, 'expected: ApplicationController was generated' ); - assert.equal( - this.logs['controller:posts'], - 1, - 'expected: PostsController was generated' - ); + assert.equal(this.logs['controller:posts'], 1, 'expected: PostsController was generated'); - assert.equal( - this.logs['route:application'], - 1, - 'expected: ApplicationRoute was generated' - ); - assert.equal( - this.logs['route:posts'], - 1, - 'expected: PostsRoute was generated' - ); + assert.equal(this.logs['route:application'], 1, 'expected: ApplicationRoute was generated'); + assert.equal(this.logs['route:posts'], 1, 'expected: PostsRoute was generated'); }); } @@ -98,19 +86,13 @@ moduleFor( !this.logs['controller:application'], 'did not expect: ApplicationController was generated' ); - assert.ok( - !this.logs['controller:posts'], - 'did not expect: PostsController was generated' - ); + assert.ok(!this.logs['controller:posts'], 'did not expect: PostsController was generated'); assert.ok( !this.logs['route:application'], 'did not expect: ApplicationRoute was generated' ); - assert.ok( - !this.logs['route:posts'], - 'did not expect: PostsRoute was generated' - ); + assert.ok(!this.logs['route:posts'], 'did not expect: PostsRoute was generated'); }); } } @@ -121,7 +103,7 @@ moduleFor( class extends LoggingApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { - LOG_ACTIVE_GENERATION: false + LOG_ACTIVE_GENERATION: false, }); } @@ -138,13 +120,11 @@ moduleFor( class extends LoggingApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { - LOG_VIEW_LOOKUPS: true + LOG_VIEW_LOOKUPS: true, }); } - [`@test log when template and view are missing when flag is active`]( - assert - ) { + [`@test log when template and view are missing when flag is active`](assert) { if (EmberDev && EmberDev.runningProdBuild) { assert.ok(true, 'Logging does not occur in production builds'); return; @@ -180,21 +160,17 @@ moduleFor( class extends LoggingApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { - LOG_VIEW_LOOKUPS: false + LOG_VIEW_LOOKUPS: false, }); } - [`@test do not log when template and view are missing when flag is not true`]( - assert - ) { + [`@test do not log when template and view are missing when flag is not true`](assert) { return this.visit('/posts').then(() => { assert.equal(Object.keys(this.logs).length, 0, 'expected no logs'); }); } - [`@test do not log which views are used with templates when flag is not true`]( - assert - ) { + [`@test do not log which views are used with templates when flag is not true`](assert) { return this.visit('/posts').then(() => { assert.equal(Object.keys(this.logs).length, 0, 'expected no logs'); }); diff --git a/packages/ember-application/tests/system/readiness_test.js b/packages/ember-application/tests/system/readiness_test.js index 67f25b24a3f..74898f8f253 100644 --- a/packages/ember-application/tests/system/readiness_test.js +++ b/packages/ember-application/tests/system/readiness_test.js @@ -24,7 +24,7 @@ moduleFor( if (jQuery.isReady) { domReady(); } - } + }, }; jQuery = function() { @@ -48,7 +48,7 @@ moduleFor( ready() { readyWasCalled++; - } + }, }); } @@ -62,9 +62,7 @@ moduleFor( // synchronously during the application's initialization, we get the same behavior as if // it was triggered after initialization. - ["@test Application's ready event is called right away if jQuery is already ready"]( - assert - ) { + ["@test Application's ready event is called right away if jQuery is already ready"](assert) { jQuery.isReady = true; run(() => { @@ -77,16 +75,10 @@ moduleFor( domReady(); - assert.equal( - readyWasCalled, - 1, - "application's ready was not called again" - ); + assert.equal(readyWasCalled, 1, "application's ready was not called again"); } - ["@test Application's ready event is called after the document becomes ready"]( - assert - ) { + ["@test Application's ready event is called after the document becomes ready"](assert) { run(() => { application = Application.create({ router: false }); }); @@ -98,9 +90,7 @@ moduleFor( assert.equal(readyWasCalled, 1, 'ready was called now that DOM is ready'); } - ["@test Application's ready event can be deferred by other components"]( - assert - ) { + ["@test Application's ready event can be deferred by other components"](assert) { run(() => { application = Application.create({ router: false }); application.deferReadiness(); @@ -117,16 +107,10 @@ moduleFor( assert.equal(readyWasCalled, 0); }); - assert.equal( - readyWasCalled, - 1, - 'ready was called now all readiness deferrals are advanced' - ); + assert.equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced'); } - ["@test Application's ready event can be deferred by other components"]( - assert - ) { + ["@test Application's ready event can be deferred by other components"](assert) { jQuery.isReady = false; run(() => { @@ -143,11 +127,7 @@ moduleFor( application.advanceReadiness(); }); - assert.equal( - readyWasCalled, - 1, - 'ready was called now all readiness deferrals are advanced' - ); + assert.equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced'); expectAssertion(() => { application.deferReadiness(); diff --git a/packages/ember-application/tests/system/reset_test.js b/packages/ember-application/tests/system/reset_test.js index 8d23916c5f1..c89b2da1412 100644 --- a/packages/ember-application/tests/system/reset_test.js +++ b/packages/ember-application/tests/system/reset_test.js @@ -12,9 +12,7 @@ moduleFor( this.application.reset(); } - ['@test Does not bring its own run loop if one is already provided']( - assert - ) { + ['@test Does not bring its own run loop if one is already provided'](assert) { assert.expect(3); let didBecomeReady = false; @@ -37,26 +35,18 @@ moduleFor( assert.ok(didBecomeReady, 'app is ready'); } - ['@test When an application is reset, new instances of controllers are generated']( - assert - ) { + ['@test When an application is reset, new instances of controllers are generated'](assert) { run(() => { this.createApplication(); this.add('controller:academic', Controller.extend()); }); - let firstController = this.applicationInstance.lookup( - 'controller:academic' - ); - let secondController = this.applicationInstance.lookup( - 'controller:academic' - ); + let firstController = this.applicationInstance.lookup('controller:academic'); + let secondController = this.applicationInstance.lookup('controller:academic'); this.application.reset(); - let thirdController = this.applicationInstance.lookup( - 'controller:academic' - ); + let thirdController = this.applicationInstance.lookup('controller:academic'); assert.strictEqual( firstController, @@ -76,9 +66,7 @@ moduleFor( ); } - ['@test When an application is reset, the eventDispatcher is destroyed and recreated']( - assert - ) { + ['@test When an application is reset, the eventDispatcher is destroyed and recreated'](assert) { let eventDispatcherWasSetup = 0; let eventDispatcherWasDestroyed = 0; @@ -88,13 +76,13 @@ moduleFor( }, destroy() { eventDispatcherWasDestroyed++; - } + }, }; run(() => { this.createApplication(); this.add('event_dispatcher:main', { - create: () => mockEventDispatcher + create: () => mockEventDispatcher, }); assert.equal(eventDispatcherWasSetup, 0); @@ -110,16 +98,14 @@ moduleFor( assert.equal(eventDispatcherWasSetup, 2, 'setup called after reset'); } - ['@test When an application is reset, the router URL is reset to `/`']( - assert - ) { + ['@test When an application is reset, the router URL is reset to `/`'](assert) { run(() => { this.createApplication(); this.add( 'router:main', Router.extend({ - location: 'none' + location: 'none', }) ); @@ -132,9 +118,7 @@ moduleFor( let initialRouter, initialApplicationController; return this.visit('/one') .then(() => { - initialApplicationController = this.applicationInstance.lookup( - 'controller:application' - ); + initialApplicationController = this.applicationInstance.lookup('controller:application'); initialRouter = this.applicationInstance.lookup('router:main'); let location = initialRouter.get('location'); @@ -146,9 +130,7 @@ moduleFor( return this.application._bootPromise; }) .then(() => { - let applicationController = this.applicationInstance.lookup( - 'controller:application' - ); + let applicationController = this.applicationInstance.lookup('controller:application'); assert.strictEqual( applicationController, undefined, @@ -158,17 +140,11 @@ moduleFor( return this.visit('/one'); }) .then(() => { - let applicationController = this.applicationInstance.lookup( - 'controller:application' - ); + let applicationController = this.applicationInstance.lookup('controller:application'); let router = this.applicationInstance.lookup('router:main'); let location = router.get('location'); - assert.notEqual( - initialRouter, - router, - 'a different router instance was created' - ); + assert.notEqual(initialRouter, router, 'a different router instance was created'); assert.notEqual( initialApplicationController, applicationController, @@ -189,7 +165,7 @@ moduleFor( this.createApplication({ ready() { readyCallCount++; - } + }, }); this.application.deferReadiness(); diff --git a/packages/ember-application/tests/system/visit_test.js b/packages/ember-application/tests/system/visit_test.js index 5225a126e1b..2f1240ce775 100644 --- a/packages/ember-application/tests/system/visit_test.js +++ b/packages/ember-application/tests/system/visit_test.js @@ -1,10 +1,5 @@ import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; -import { - Object as EmberObject, - inject, - RSVP, - onerrorDefault -} from 'ember-runtime'; +import { Object as EmberObject, inject, RSVP, onerrorDefault } from 'ember-runtime'; import { later } from 'ember-metal'; import Application from '../../system/application'; import ApplicationInstance from '../../system/application-instance'; @@ -46,7 +41,7 @@ moduleFor( let bootOptions = { isBrowser: false, - rootElement + rootElement, }; ENV._APPLICATION_TEMPLATE_WRAPPER = false; @@ -69,7 +64,7 @@ moduleFor( let bootOptions = { isBrowser: false, rootElement, - _renderMode: 'serialize' + _renderMode: 'serialize', }; ENV._APPLICATION_TEMPLATE_WRAPPER = false; @@ -91,7 +86,7 @@ moduleFor( bootOptions = { isBrowser: false, rootElement, - _renderMode: 'rehydrate' + _renderMode: 'rehydrate', }; this.application.visit('/', bootOptions).then(instance => { @@ -122,14 +117,14 @@ moduleFor( name: 'assert-no-autoboot', initialize() { appBooted++; - } + }, }); this.application.instanceInitializer({ name: 'assert-no-autoboot', initialize() { instanceBooted++; - } + }, }); assert.ok(!this.applicationInstance, 'precond - no instance'); @@ -140,18 +135,12 @@ moduleFor( return delay(500) .then(() => { assert.ok(appBooted === 0, '500ms elapsed without app being booted'); - assert.ok( - instanceBooted === 0, - '500ms elapsed without instances being booted' - ); + assert.ok(instanceBooted === 0, '500ms elapsed without instances being booted'); return this.runTask(() => this.application.boot()); }) .then(() => { - assert.ok( - appBooted === 1, - 'app should boot when manually calling `app.boot()`' - ); + assert.ok(appBooted === 1, 'app should boot when manually calling `app.boot()`'); assert.ok( instanceBooted === 0, 'no instances should be booted automatically when manually calling `app.boot()' @@ -159,9 +148,7 @@ moduleFor( }); } - [`@test calling visit() on an app without first calling boot() should boot the app`]( - assert - ) { + [`@test calling visit() on an app without first calling boot() should boot the app`](assert) { let appBooted = 0; let instanceBooted = 0; @@ -169,14 +156,14 @@ moduleFor( name: 'assert-no-autoboot', initialize() { appBooted++; - } + }, }); this.application.instanceInitializer({ name: 'assert-no-autoboot', initialize() { instanceBooted++; - } + }, }); return this.visit('/').then(() => { @@ -185,9 +172,7 @@ moduleFor( }); } - [`@test calling visit() on an already booted app should not boot it again`]( - assert - ) { + [`@test calling visit() on an already booted app should not boot it again`](assert) { let appBooted = 0; let instanceBooted = 0; @@ -195,14 +180,14 @@ moduleFor( name: 'assert-no-autoboot', initialize() { appBooted++; - } + }, }); this.application.instanceInitializer({ name: 'assert-no-autoboot', initialize() { instanceBooted++; - } + }, }); return this.runTask(() => this.application.boot()) @@ -244,7 +229,7 @@ moduleFor( name: 'error', initialize() { throw new Error('boot failure'); - } + }, }); expectAsyncError(); @@ -254,10 +239,7 @@ moduleFor( assert.ok(false, 'It should not resolve the promise'); }, error => { - assert.ok( - error instanceof Error, - 'It should reject the promise with the boot error' - ); + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); assert.equal(error.message, 'boot failure'); } ); @@ -268,7 +250,7 @@ moduleFor( name: 'error', initialize() { throw new Error('boot failure'); - } + }, }); expectAsyncError(); @@ -278,10 +260,7 @@ moduleFor( assert.ok(false, 'It should not resolve the promise'); }, error => { - assert.ok( - error instanceof Error, - 'It should reject the promise with the boot error' - ); + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); assert.equal(error.message, 'boot failure'); } ); @@ -299,7 +278,7 @@ moduleFor( Route.extend({ afterModel() { this.replaceWith('b', 'zomg'); - } + }, }) ); @@ -308,7 +287,7 @@ moduleFor( Route.extend({ afterModel(params) { this.transitionTo('c', params.b); - } + }, }) ); @@ -321,11 +300,7 @@ moduleFor( instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance' ); - assert.equal( - instance.getURL(), - '/c/zomg', - 'It should follow all redirects' - ); + assert.equal(instance.getURL(), '/c/zomg', 'It should follow all redirects'); }); } @@ -341,7 +316,7 @@ moduleFor( Route.extend({ afterModel() { this.replaceWith('b', 'zomg'); - } + }, }) ); @@ -350,7 +325,7 @@ moduleFor( Route.extend({ afterModel(params) { this.transitionTo('c', params.b); - } + }, }) ); @@ -359,7 +334,7 @@ moduleFor( Route.extend({ afterModel() { throw new Error('transition failure'); - } + }, }) ); @@ -370,10 +345,7 @@ moduleFor( assert.ok(false, 'It should not resolve the promise'); }, error => { - assert.ok( - error instanceof Error, - 'It should reject the promise with the boot error' - ); + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); assert.equal(error.message, 'transition failure'); } ); @@ -423,9 +395,7 @@ moduleFor( }); } - [`@test visit() returns a promise that resolves when the view has rendered`]( - assert - ) { + [`@test visit() returns a promise that resolves when the view has rendered`](assert) { this.addTemplate('application', `

Hello world

`); this.assertEmptyFixture(); @@ -462,9 +432,7 @@ moduleFor( }); } - [`@test visit() renders a template when shouldRender is set to true`]( - assert - ) { + [`@test visit() renders a template when shouldRender is set to true`](assert) { assert.expect(3); this.addTemplate('application', '

Hello world

'); @@ -528,7 +496,7 @@ moduleFor( this.add('event_dispatcher:main', { create() { throw new Error('should not happen!'); - } + }, }); // Register engine @@ -543,7 +511,7 @@ moduleFor( `) ); this.register('component:cache-money', Component.extend({})); - } + }, }); this.add('engine:blog', BlogEngine); @@ -585,7 +553,7 @@ moduleFor( `) ); this.register('component:cache-money', Component.extend({})); - } + }, }); this.add('engine:blog', BlogEngine); @@ -622,7 +590,7 @@ moduleFor( return 'turnt up'; }) ); - } + }, }); this.add('engine:blog', BlogEngine); @@ -633,11 +601,7 @@ moduleFor( this.assertEmptyFixture(); return this.visit('/blog', { shouldRender: true }).then(() => { - assert.strictEqual( - this.element.textContent, - 'turnt up', - 'Engine component is resolved' - ); + assert.strictEqual(this.element.textContent, 'turnt up', 'Engine component is resolved'); }); } @@ -656,15 +620,15 @@ moduleFor( 'route:show', Route.extend({ queryParams: { - data: { refreshModel: true } + data: { refreshModel: true }, }, model(params) { return { componentName: params.component_name, - componentData: params.data ? JSON.parse(params.data) : undefined + componentData: params.data ? JSON.parse(params.data) : undefined, }; - } + }, }) ); @@ -673,19 +637,16 @@ moduleFor( increment() { this.incrementProperty('value'); - } + }, }); this.add('service:isolatedCounter', Counter); this.add('service:sharedCounter', Counter.create()); this.application.registerOptions('service:sharedCounter', { - instantiate: false + instantiate: false, }); - this.addTemplate( - 'show', - '{{component model.componentName model=model.componentData}}' - ); + this.addTemplate('show', '{{component model.componentName model=model.componentData}}'); this.addTemplate( 'components/x-foo', @@ -715,7 +676,7 @@ moduleFor( click() { this.get('isolatedCounter').increment(); this.get('sharedCounter').increment(); - } + }, }) ); @@ -735,7 +696,7 @@ moduleFor( actions: { incrementCounter() { this.get('counter').increment(); - } + }, }, init() { @@ -745,7 +706,7 @@ moduleFor( didInsertElement() { xBarDidInsertElementCalled = true; - } + }, }) ); @@ -761,12 +722,12 @@ moduleFor( return RSVP.all([ this.runTask(() => { return this.application.visit(`/x-foo?data=${data}`, { - rootElement: foo + rootElement: foo, }); }), this.runTask(() => { return this.application.visit('/x-bar', { rootElement: bar }); - }) + }), ]) .then(_instances => { instances = _instances; @@ -785,10 +746,7 @@ moduleFor( assert.ok(foo.textContent.indexOf('X-Bar') === -1); assert.equal(bar.querySelector('h1').textContent, 'X-Bar'); - assert.equal( - bar.querySelector('button').textContent, - 'Join 0 others in clicking me!' - ); + assert.equal(bar.querySelector('button').textContent, 'Join 0 others in clicking me!'); assert.ok(bar.textContent.indexOf('X-Foo') === -1); this.runTask(() => { @@ -799,10 +757,7 @@ moduleFor( foo.querySelector('p').textContent, 'Hello Godfrey, I have been clicked 1 times (1 times combined)!' ); - assert.equal( - bar.querySelector('button').textContent, - 'Join 1 others in clicking me!' - ); + assert.equal(bar.querySelector('button').textContent, 'Join 1 others in clicking me!'); this.runTask(() => { this.click(bar.querySelector('button')); @@ -813,10 +768,7 @@ moduleFor( foo.querySelector('p').textContent, 'Hello Godfrey, I have been clicked 1 times (3 times combined)!' ); - assert.equal( - bar.querySelector('button').textContent, - 'Join 3 others in clicking me!' - ); + assert.equal(bar.querySelector('button').textContent, 'Join 3 others in clicking me!'); }) .finally(() => { this.runTask(() => { diff --git a/packages/ember-application/tests/test-helpers/registry-check.js b/packages/ember-application/tests/test-helpers/registry-check.js index 2255a661bbf..dd75bf7c65a 100644 --- a/packages/ember-application/tests/test-helpers/registry-check.js +++ b/packages/ember-application/tests/test-helpers/registry-check.js @@ -1,17 +1,8 @@ export function verifyRegistration(assert, owner, fullName) { - assert.ok( - owner.resolveRegistration(fullName), - `has registration: ${fullName}` - ); + assert.ok(owner.resolveRegistration(fullName), `has registration: ${fullName}`); } -export function verifyInjection( - assert, - owner, - fullName, - property, - injectionName -) { +export function verifyInjection(assert, owner, fullName, property, injectionName) { let registry = owner.__registry__; let injections; @@ -27,17 +18,11 @@ export function verifyInjection( for (let i = 0, l = injections.length; i < l; i++) { injection = injections[i]; - if ( - injection.property === property && - injection.specifier === normalizedName - ) { + if (injection.property === property && injection.specifier === normalizedName) { hasInjection = true; break; } } - assert.ok( - hasInjection, - `has injection: ${fullName}.${property} = ${injectionName}` - ); + assert.ok(hasInjection, `has injection: ${fullName}.${property} = ${injectionName}`); } diff --git a/packages/ember-console/lib/index.js b/packages/ember-console/lib/index.js index cbd757fe508..f8a6c2441a9 100644 --- a/packages/ember-console/lib/index.js +++ b/packages/ember-console/lib/index.js @@ -2,8 +2,7 @@ import { deprecate } from 'ember-debug'; // Deliver message that the function is deprecated -const DEPRECATION_MESSAGE = - 'Use of Ember.Logger is deprecated. Please use `console` for logging.'; +const DEPRECATION_MESSAGE = 'Use of Ember.Logger is deprecated. Please use `console` for logging.'; const DEPRECATION_ID = 'ember-console.deprecate-logger'; const DEPRECATION_URL = 'https://emberjs.com/deprecations/v3.x#toc_use-console-rather-than-ember-logger'; @@ -40,7 +39,7 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); return console.log(...arguments); // eslint-disable-line no-console }, @@ -63,7 +62,7 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); return console.warn(...arguments); // eslint-disable-line no-console }, @@ -86,7 +85,7 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); return console.error(...arguments); // eslint-disable-line no-console }, @@ -110,7 +109,7 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); return console.info(...arguments); // eslint-disable-line no-console }, @@ -134,7 +133,7 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); /* eslint-disable no-console */ if (console.debug) { @@ -163,8 +162,8 @@ export default { deprecate(DEPRECATION_MESSAGE, false, { id: DEPRECATION_ID, until: '4.0.0', - url: DEPRECATION_URL + url: DEPRECATION_URL, }); return console.assert(...arguments); // eslint-disable-line no-console - } + }, }; diff --git a/packages/ember-debug/lib/deprecate.js b/packages/ember-debug/lib/deprecate.js index 46a3c91dc99..7724dd23790 100644 --- a/packages/ember-debug/lib/deprecate.js +++ b/packages/ember-debug/lib/deprecate.js @@ -141,10 +141,8 @@ if (DEBUG) { 'When calling `deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; - missingOptionsIdDeprecation = - 'When calling `deprecate` you must provide `id` in options.'; - missingOptionsUntilDeprecation = - 'When calling `deprecate` you must provide `until` in options.'; + missingOptionsIdDeprecation = 'When calling `deprecate` you must provide `id` in options.'; + missingOptionsUntilDeprecation = 'When calling `deprecate` you must provide `until` in options.'; /** @module @ember/application @public @@ -175,10 +173,7 @@ if (DEBUG) { */ deprecate = function deprecate(message, test, options) { if (ENV._ENABLE_DEPRECATION_OPTIONS_SUPPORT !== true) { - assert( - missingOptionsDeprecation, - options && (options.id || options.until) - ); + assert(missingOptionsDeprecation, options && (options.id || options.until)); assert(missingOptionsIdDeprecation, options.id); assert(missingOptionsUntilDeprecation, options.until); } @@ -190,34 +185,23 @@ if (DEBUG) { deprecate(missingOptionsDeprecation, false, { id: 'ember-debug.deprecate-options-missing', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options', }); } - if ( - options && - !options.id && - ENV._ENABLE_DEPRECATION_OPTIONS_SUPPORT === true - ) { + if (options && !options.id && ENV._ENABLE_DEPRECATION_OPTIONS_SUPPORT === true) { deprecate(missingOptionsIdDeprecation, false, { id: 'ember-debug.deprecate-id-missing', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options', }); } - if ( - options && - !options.until && - ENV._ENABLE_DEPRECATION_OPTIONS_SUPPORT === true - ) { + if (options && !options.until && ENV._ENABLE_DEPRECATION_OPTIONS_SUPPORT === true) { deprecate(missingOptionsUntilDeprecation, options && options.until, { id: 'ember-debug.deprecate-until-missing', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options', }); } @@ -231,5 +215,5 @@ export { registerHandler, missingOptionsDeprecation, missingOptionsIdDeprecation, - missingOptionsUntilDeprecation + missingOptionsUntilDeprecation, }; diff --git a/packages/ember-debug/lib/features.js b/packages/ember-debug/lib/features.js index fbc2c40ec57..771d82f3058 100644 --- a/packages/ember-debug/lib/features.js +++ b/packages/ember-debug/lib/features.js @@ -41,11 +41,7 @@ let { FEATURES } = FLAGS; export default function isEnabled(feature) { let featureValue = FEATURES[feature]; - if ( - featureValue === true || - featureValue === false || - featureValue === undefined - ) { + if (featureValue === true || featureValue === false || featureValue === undefined) { return featureValue; } else if (ENV.ENABLE_OPTIONAL_FEATURES) { return true; diff --git a/packages/ember-debug/lib/index.js b/packages/ember-debug/lib/index.js index d51b1d43a76..2f5eada295f 100644 --- a/packages/ember-debug/lib/index.js +++ b/packages/ember-debug/lib/index.js @@ -312,21 +312,13 @@ if (DEBUG && !isTesting()) { } delete FEATURES['features-stripped-test']; - _warnIfUsingStrippedFeatureFlags( - ENV.FEATURES, - DEFAULT_FEATURES, - featuresWereStripped - ); + _warnIfUsingStrippedFeatureFlags(ENV.FEATURES, DEFAULT_FEATURES, featuresWereStripped); // Inform the developer about the Ember Inspector if not installed. let isFirefox = environment.isFirefox; let isChrome = environment.isChrome; - if ( - typeof window !== 'undefined' && - (isFirefox || isChrome) && - window.addEventListener - ) { + if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { window.addEventListener( 'load', () => { @@ -341,13 +333,10 @@ if (DEBUG && !isTesting()) { downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; } else if (isFirefox) { - downloadURL = - 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; + downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; } - debug( - `For more advanced debugging, install the Ember Inspector from ${downloadURL}` - ); + debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`); } }, false @@ -367,5 +356,5 @@ export { deprecateFunc, setDebugFunction, getDebugFunction, - _warnIfUsingStrippedFeatureFlags + _warnIfUsingStrippedFeatureFlags, }; diff --git a/packages/ember-debug/lib/warn.js b/packages/ember-debug/lib/warn.js index fccbf0fc5c6..fee4c028c8b 100644 --- a/packages/ember-debug/lib/warn.js +++ b/packages/ember-debug/lib/warn.js @@ -62,8 +62,7 @@ if (DEBUG) { 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; - missingOptionsIdDeprecation = - 'When calling `warn` you must provide `id` in options.'; + missingOptionsIdDeprecation = 'When calling `warn` you must provide `id` in options.'; /** Display a warning with the provided message. @@ -99,8 +98,7 @@ if (DEBUG) { deprecate(missingOptionsDeprecation, false, { id: 'ember-debug.warn-options-missing', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options', }); } @@ -108,8 +106,7 @@ if (DEBUG) { deprecate(missingOptionsIdDeprecation, false, { id: 'ember-debug.warn-id-missing', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options', }); } @@ -118,8 +115,4 @@ if (DEBUG) { } export default warn; -export { - registerHandler, - missingOptionsIdDeprecation, - missingOptionsDeprecation -}; +export { registerHandler, missingOptionsIdDeprecation, missingOptionsDeprecation }; diff --git a/packages/ember-debug/tests/handlers-test.js b/packages/ember-debug/tests/handlers-test.js index 672560597ee..6fe58808ad3 100644 --- a/packages/ember-debug/tests/handlers-test.js +++ b/packages/ember-debug/tests/handlers-test.js @@ -33,9 +33,7 @@ moduleFor( invoke('blarz', 'Foo bar', true); } - ['@test calling `invoke` without handlers does not throw an error']( - assert - ) { + ['@test calling `invoke` without handlers does not throw an error'](assert) { assert.expect(0); invoke('blarz', 'Foo bar', false); @@ -59,9 +57,7 @@ moduleFor( invoke('blarz', 'Foo', false); } - ['@test invoking `next` when no other handlers exists does not error']( - assert - ) { + ['@test invoking `next` when no other handlers exists does not error'](assert) { assert.expect(1); function handler(message, options, next) { @@ -85,16 +81,8 @@ moduleFor( function generateHandler(item) { return function(message, options, next) { - assert.equal( - message, - expectedMessage, - `message supplied to ${item} handler is correct` - ); - assert.equal( - options, - expectedOptions, - `options supplied to ${item} handler is correct` - ); + assert.equal(message, expectedMessage, `message supplied to ${item} handler is correct`); + assert.equal(options, expectedOptions, `options supplied to ${item} handler is correct`); actualCalls.push(item); @@ -106,16 +94,10 @@ moduleFor( invoke('blarz', expectedMessage, false, expectedOptions); - assert.deepEqual( - actualCalls, - expected.reverse(), - 'handlers were called in proper order' - ); + assert.deepEqual(actualCalls, expected.reverse(), 'handlers were called in proper order'); } - ['@test not invoking `next` prevents further handlers from being called']( - assert - ) { + ['@test not invoking `next` prevents further handlers from being called'](assert) { assert.expect(1); function handler1() { @@ -132,9 +114,7 @@ moduleFor( invoke('blarz', 'Foo', false); } - ['@test handlers can call `next` with custom message and/or options']( - assert - ) { + ['@test handlers can call `next` with custom message and/or options'](assert) { assert.expect(4); let initialMessage = 'initial message'; @@ -144,29 +124,13 @@ moduleFor( let handler2Options = { id: 'handler-2' }; function handler1(message, options) { - assert.equal( - message, - handler2Message, - 'handler2 message provided to handler1' - ); - assert.equal( - options, - handler2Options, - 'handler2 options provided to handler1' - ); + assert.equal(message, handler2Message, 'handler2 message provided to handler1'); + assert.equal(options, handler2Options, 'handler2 options provided to handler1'); } function handler2(message, options, next) { - assert.equal( - message, - initialMessage, - 'initial message provided to handler2' - ); - assert.equal( - options, - initialOptions, - 'initial options proivided to handler2' - ); + assert.equal(message, initialMessage, 'initial message provided to handler2'); + assert.equal(options, initialOptions, 'initial options proivided to handler2'); next(handler2Message, handler2Options); } diff --git a/packages/ember-debug/tests/main_test.js b/packages/ember-debug/tests/main_test.js index 14be17fc65a..ae40d50f862 100644 --- a/packages/ember-debug/tests/main_test.js +++ b/packages/ember-debug/tests/main_test.js @@ -5,13 +5,13 @@ import { registerHandler, missingOptionsDeprecation, missingOptionsIdDeprecation, - missingOptionsUntilDeprecation + missingOptionsUntilDeprecation, } from '../deprecate'; import { missingOptionsIdDeprecation as missingWarnOptionsIdDeprecation, missingOptionsDeprecation as missingWarnOptionsDeprecation, - registerHandler as registerWarnHandler + registerHandler as registerWarnHandler, } from '../warn'; import { deprecate, warn, assert as emberAssert } from '../index'; @@ -55,9 +55,7 @@ moduleFor( console.warn = originalConsoleWarn; // eslint-disable-line no-console } - ['@test deprecate does not throw if RAISE_ON_DEPRECATION is false']( - assert - ) { + ['@test deprecate does not throw if RAISE_ON_DEPRECATION is false'](assert) { assert.expect(1); console.warn = noop; // eslint-disable-line no-console @@ -67,10 +65,7 @@ moduleFor( deprecate('Should not throw', false, { id: 'test', until: 'forever' }); assert.ok(true, 'deprecate did not throw'); } catch (e) { - assert.ok( - false, - `Expected deprecate not to throw but it did: ${e.message}` - ); + assert.ok(false, `Expected deprecate not to throw but it did: ${e.message}`); } } @@ -86,10 +81,7 @@ moduleFor( deprecate('Should not throw', false, { id: 'test', until: 'forever' }); assert.ok(true, 'deprecate did not throw'); } catch (e) { - assert.ok( - false, - `Expected deprecate not to throw but it did: ${e.message}` - ); + assert.ok(false, `Expected deprecate not to throw but it did: ${e.message}`); } ENV.RAISE_ON_DEPRECATION = true; @@ -114,27 +106,24 @@ moduleFor( try { deprecate('should be silenced with matching id', false, { id: 'my-deprecation', - until: 'forever' + until: 'forever', }); assert.ok(true, 'Did not throw when level is set by id'); } catch (e) { - assert.ok( - false, - `Expected deprecate not to throw but it did: ${e.message}` - ); + assert.ok(false, `Expected deprecate not to throw but it did: ${e.message}`); } assert.throws(() => { deprecate('Should throw with no matching id', false, { id: 'test', - until: 'forever' + until: 'forever', }); }, /Should throw with no matching id/); assert.throws(() => { deprecate('Should throw with non-matching id', false, { id: 'other-id', - until: 'forever' + until: 'forever', }); }, /Should throw with non-matching id/); } @@ -145,20 +134,14 @@ moduleFor( assert.throws(() => deprecate('Deprecation is thrown', false, { id: 'test', - until: 'forever' + until: 'forever', }) ); - assert.throws(() => - deprecate('Deprecation is thrown', '', { id: 'test', until: 'forever' }) - ); - assert.throws(() => - deprecate('Deprecation is thrown', 0, { id: 'test', until: 'forever' }) - ); + assert.throws(() => deprecate('Deprecation is thrown', '', { id: 'test', until: 'forever' })); + assert.throws(() => deprecate('Deprecation is thrown', 0, { id: 'test', until: 'forever' })); } - ['@test deprecate does not invoke a function as the second argument']( - assert - ) { + ['@test deprecate does not invoke a function as the second argument'](assert) { assert.expect(1); deprecate( @@ -172,14 +155,12 @@ moduleFor( assert.ok(true, 'deprecations were not thrown'); } - ['@test deprecate does not throw deprecations if second argument is truthy']( - assert - ) { + ['@test deprecate does not throw deprecations if second argument is truthy'](assert) { assert.expect(1); deprecate('Deprecation is thrown', true, { id: 'test', - until: 'forever' + until: 'forever', }); deprecate('Deprecation is thrown', '1', { id: 'test', until: 'forever' }); deprecate('Deprecation is thrown', 1, { id: 'test', until: 'forever' }); @@ -223,9 +204,7 @@ moduleFor( assert.ok(true, 'assertions were not thrown'); } - ['@test deprecate does not throw a deprecation at log and silence']( - assert - ) { + ['@test deprecate does not throw a deprecation at log and silence'](assert) { assert.expect(4); let id = 'ABC'; let until = 'forever'; @@ -243,20 +222,14 @@ moduleFor( deprecate('Deprecation for testing purposes', false, { id, until }); assert.ok(true, 'Deprecation did not throw'); } catch (e) { - assert.ok( - false, - 'Deprecation was thrown despite being added to blacklist' - ); + assert.ok(false, 'Deprecation was thrown despite being added to blacklist'); } try { deprecate('Deprecation for testing purposes', false, { id, until }); assert.ok(true, 'Deprecation did not throw'); } catch (e) { - assert.ok( - false, - 'Deprecation was thrown despite being added to blacklist' - ); + assert.ok(false, 'Deprecation was thrown despite being added to blacklist'); } shouldThrow = true; @@ -275,10 +248,7 @@ moduleFor( registerHandler(function(message) { if (message === missingOptionsDeprecation) { - assert.ok( - true, - 'proper deprecation is triggered when options is missing' - ); + assert.ok(true, 'proper deprecation is triggered when options is missing'); } else if (message === 'foo') { assert.ok(true, 'original deprecation is still triggered'); } @@ -310,10 +280,7 @@ moduleFor( registerHandler(function(message) { if (message === missingOptionsIdDeprecation) { - assert.ok( - true, - 'proper deprecation is triggered when options.id is missing' - ); + assert.ok(true, 'proper deprecation is triggered when options.id is missing'); } else if (message === 'foo') { assert.ok(true, 'original deprecation is still triggered'); } @@ -338,10 +305,7 @@ moduleFor( registerHandler(function(message) { if (message === missingOptionsUntilDeprecation) { - assert.ok( - true, - 'proper deprecation is triggered when options.until is missing' - ); + assert.ok(true, 'proper deprecation is triggered when options.until is missing'); } else if (message === 'foo') { assert.ok(true, 'original deprecation is still triggered'); } @@ -451,9 +415,7 @@ moduleFor( ); } - ['@test warn without test but with options does not trigger a deprecation']( - assert - ) { + ['@test warn without test but with options does not trigger a deprecation'](assert) { assert.expect(1); ENV._ENABLE_WARN_OPTIONS_SUPPORT = true; @@ -469,9 +431,7 @@ moduleFor( warn('foo', { id: 'ember-debug.do-not-raise' }); } - ['@test warn without test but with options does not trigger an assertion']( - assert - ) { + ['@test warn without test but with options does not trigger an assertion'](assert) { assert.expect(1); registerWarnHandler(function(message) { diff --git a/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js b/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js index 013b8d1dab1..19a819d834f 100644 --- a/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js +++ b/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js @@ -3,12 +3,7 @@ import { getDebugFunction, setDebugFunction } from 'ember-debug'; import { _warnIfUsingStrippedFeatureFlags } from '../index'; import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers'; -let oldWarn, - oldRunInDebug, - origEnvFeatures, - origEnableOptional, - features, - knownFeatures; +let oldWarn, oldRunInDebug, origEnvFeatures, origEnableOptional, features, knownFeatures; function confirmWarns(assert, expectedMsg) { let featuresWereStripped = true; @@ -24,19 +19,11 @@ function confirmWarns(assert, expectedMsg) { }); // Should trigger our 1 warning - _warnIfUsingStrippedFeatureFlags( - features, - knownFeatures, - featuresWereStripped - ); + _warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); // Shouldn't trigger any warnings now that we're "in canary" featuresWereStripped = false; - _warnIfUsingStrippedFeatureFlags( - features, - knownFeatures, - featuresWereStripped - ); + _warnIfUsingStrippedFeatureFlags(features, knownFeatures, featuresWereStripped); } moduleFor( @@ -53,7 +40,7 @@ moduleFor( knownFeatures = { fred: null, barney: null, - wilma: null + wilma: null, }; } @@ -78,16 +65,14 @@ moduleFor( ); } - ['@test Enabling a known FEATURE flag in non-canary, debug build causes a warning']( - assert - ) { + ['@test Enabling a known FEATURE flag in non-canary, debug build causes a warning'](assert) { assert.expect(1); ENV.ENABLE_OPTIONAL_FEATURES = false; features = { fred: true, barney: false, - wilma: null + wilma: null, }; confirmWarns( @@ -103,7 +88,7 @@ moduleFor( ENV.ENABLE_OPTIONAL_FEATURES = false; features = { - 'some-ember-data-feature-flag': true + 'some-ember-data-feature-flag': true, }; confirmWarns( diff --git a/packages/ember-environment/lib/global.js b/packages/ember-environment/lib/global.js index 2e86af95ad1..a7d8f3c0381 100644 --- a/packages/ember-environment/lib/global.js +++ b/packages/ember-environment/lib/global.js @@ -11,9 +11,7 @@ function checkElementIdShadowing(value) { } // export real global -export default checkGlobal( - checkElementIdShadowing(typeof global === 'object' && global) -) || +export default checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || mainContext || // set before strict mode in Ember loader/wrapper diff --git a/packages/ember-environment/lib/index.js b/packages/ember-environment/lib/index.js index b00f72c51bd..652913b20bf 100644 --- a/packages/ember-environment/lib/index.js +++ b/packages/ember-environment/lib/index.js @@ -52,9 +52,7 @@ ENV.EXTEND_PROTOTYPES = normalizeExtendPrototypes(ENV.EXTEND_PROTOTYPES); @for EmberENV @public */ -ENV.LOG_STACKTRACE_ON_DEPRECATION = defaultTrue( - ENV.LOG_STACKTRACE_ON_DEPRECATION -); +ENV.LOG_STACKTRACE_ON_DEPRECATION = defaultTrue(ENV.LOG_STACKTRACE_ON_DEPRECATION); /** The `LOG_VERSION` property, when true, tells Ember to log versions of all @@ -96,9 +94,7 @@ ENV.RAISE_ON_DEPRECATION = defaultFalse(ENV.RAISE_ON_DEPRECATION); @default true @private */ -ENV._APPLICATION_TEMPLATE_WRAPPER = defaultTrue( - ENV._APPLICATION_TEMPLATE_WRAPPER -); +ENV._APPLICATION_TEMPLATE_WRAPPER = defaultTrue(ENV._APPLICATION_TEMPLATE_WRAPPER); /** Whether to use Glimmer Component semantics (as opposed to the classic "Curly" @@ -113,9 +109,7 @@ ENV._APPLICATION_TEMPLATE_WRAPPER = defaultTrue( @default false @private */ -ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = defaultFalse( - ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS -); +ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = defaultFalse(ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS); // check if window exists and actually is the global const hasDOM = @@ -134,7 +128,7 @@ export const context = { // export Ember exports: originalContext.exports || global, // search for Namespaces - lookup: originalContext.lookup || global + lookup: originalContext.lookup || global, }; // TODO: cleanup single source of truth issues with this stuff @@ -146,7 +140,7 @@ export const environment = hasDOM location: window.location, history: window.history, userAgent: window.navigator.userAgent, - window + window, } : { hasDOM: false, @@ -155,5 +149,5 @@ export const environment = hasDOM location: null, history: null, userAgent: 'Lynx (textmode)', - window: null + window: null, }; diff --git a/packages/ember-environment/lib/utils.js b/packages/ember-environment/lib/utils.js index 4ea9044a36e..a94fdbf2dbc 100644 --- a/packages/ember-environment/lib/utils.js +++ b/packages/ember-environment/lib/utils.js @@ -15,7 +15,7 @@ export function normalizeExtendPrototypes(obj) { return { String: defaultTrue(obj.String), Array: defaultTrue(obj.Array), - Function: defaultTrue(obj.Function) + Function: defaultTrue(obj.Function), }; } } diff --git a/packages/ember-extension-support/lib/container_debug_adapter.js b/packages/ember-extension-support/lib/container_debug_adapter.js index da6d0d3b8a7..22ba1924758 100644 --- a/packages/ember-extension-support/lib/container_debug_adapter.js +++ b/packages/ember-extension-support/lib/container_debug_adapter.js @@ -3,7 +3,7 @@ import { typeOf, String as StringUtils, Namespace, - Object as EmberObject + Object as EmberObject, } from 'ember-runtime'; /** @@ -100,5 +100,5 @@ export default EmberObject.extend({ } }); return types; - } + }, }); diff --git a/packages/ember-extension-support/lib/data_adapter.js b/packages/ember-extension-support/lib/data_adapter.js index 9882b278490..e41720f1efb 100644 --- a/packages/ember-extension-support/lib/data_adapter.js +++ b/packages/ember-extension-support/lib/data_adapter.js @@ -1,16 +1,10 @@ import { getOwner } from 'ember-utils'; -import { - get, - scheduleOnce, - objectAt, - addArrayObserver, - removeArrayObserver -} from 'ember-metal'; +import { get, scheduleOnce, objectAt, addArrayObserver, removeArrayObserver } from 'ember-metal'; import { String as StringUtils, Namespace, Object as EmberObject, - A as emberA + A as emberA, } from 'ember-runtime'; /** @@ -226,7 +220,7 @@ export default EmberObject.extend({ didChange: contentDidChange, willChange() { return this; - } + }, }; addArrayObserver(records, this, observer); @@ -307,7 +301,7 @@ export default EmberObject.extend({ }, willChange() { return this; - } + }, }; addArrayObserver(records, this, observer); @@ -342,7 +336,7 @@ export default EmberObject.extend({ name, count: get(records, 'length'), columns: this.columnsForType(klass), - object: klass + object: klass, }; return typeToSend; @@ -369,7 +363,7 @@ export default EmberObject.extend({ types = emberA(types).map(name => { return { klass: this._nameToClass(name), - name + name, }; }); types = emberA(types).filter(type => this.detect(type.klass)); @@ -498,5 +492,5 @@ export default EmberObject.extend({ */ observeRecord() { return function() {}; - } + }, }); diff --git a/packages/ember-extension-support/tests/container_debug_adapter_test.js b/packages/ember-extension-support/tests/container_debug_adapter_test.js index ed5fce63485..9292eb55b69 100644 --- a/packages/ember-extension-support/tests/container_debug_adapter_test.js +++ b/packages/ember-extension-support/tests/container_debug_adapter_test.js @@ -15,14 +15,12 @@ moduleFor( constructor() { setDebugFunction('debug', noop); super(); - adapter = this.application.__deprecatedInstance__.lookup( - 'container-debug-adapter:main' - ); + adapter = this.application.__deprecatedInstance__.lookup('container-debug-adapter:main'); } get applicationOptions() { return assign(super.applicationOptions, { - autoboot: true + autoboot: true, }); } @@ -35,9 +33,7 @@ moduleFor( super.teardown(); } - ['@test default ContainerDebugAdapter cannot catalog certain entries by type']( - assert - ) { + ['@test default ContainerDebugAdapter cannot catalog certain entries by type'](assert) { assert.equal( adapter.canCatalogEntriesByType('model'), false, @@ -50,9 +46,7 @@ moduleFor( ); } - ['@test default ContainerDebugAdapter can catalog typical entries by type']( - assert - ) { + ['@test default ContainerDebugAdapter can catalog typical entries by type'](assert) { assert.equal( adapter.canCatalogEntriesByType('controller'), true, @@ -70,9 +64,7 @@ moduleFor( ); } - ['@test default ContainerDebugAdapter catalogs controller entries']( - assert - ) { + ['@test default ContainerDebugAdapter catalogs controller entries'](assert) { this.application.PostController = EmberController.extend(); let controllerClasses = adapter.catalogEntriesByType('controller'); diff --git a/packages/ember-extension-support/tests/data_adapter_test.js b/packages/ember-extension-support/tests/data_adapter_test.js index b0abc8c9735..10fe13954e3 100644 --- a/packages/ember-extension-support/tests/data_adapter_test.js +++ b/packages/ember-extension-support/tests/data_adapter_test.js @@ -20,9 +20,9 @@ const DataAdapter = EmberDataAdapter.extend({ }, catalogEntriesByType() { return emberA(['post']); - } + }, }); - } + }, }); moduleFor( @@ -37,7 +37,7 @@ moduleFor( }, columnsForType() { return [{ name: 'title', desc: 'Title' }]; - } + }, }) ); this.add('model:post', PostClass); @@ -50,11 +50,7 @@ moduleFor( let postType = types[0]; assert.equal(postType.name, 'post', 'Correctly sets the name'); assert.equal(postType.count, 3, 'Correctly sets the record count'); - assert.strictEqual( - postType.object, - PostClass, - 'Correctly sets the object' - ); + assert.strictEqual(postType.object, PostClass, 'Correctly sets the object'); assert.deepEqual( postType.columns, [{ name: 'title', desc: 'Title' }], @@ -73,7 +69,7 @@ moduleFor( getRecords(klass, name) { assert.equal(name, 'post'); return emberA(); - } + }, }) ); this.add('model:post', PostClass); @@ -91,7 +87,7 @@ moduleFor( }, catalogEntriesByType() { return emberA(['post']); - } + }, }); this.add('container-debug-adapter:main', StubContainerDebugAdapter); this.add( @@ -102,7 +98,7 @@ moduleFor( }, columnsForType() { return [{ name: 'title', desc: 'Title' }]; - } + }, }) ); this.add('model:post', PostClass); @@ -115,11 +111,7 @@ moduleFor( let postType = types[0]; assert.equal(postType.name, 'post', 'Correctly sets the name'); assert.equal(postType.count, 3, 'Correctly sets the record count'); - assert.strictEqual( - postType.object, - PostClass, - 'Correctly sets the object' - ); + assert.strictEqual(postType.object, PostClass, 'Correctly sets the object'); assert.deepEqual( postType.columns, [{ name: 'title', desc: 'Title' }], @@ -138,7 +130,7 @@ moduleFor( DataAdapter.extend({ getRecords() { return records; - } + }, }) ); this.add('model:post', PostClass); @@ -161,9 +153,7 @@ moduleFor( }); } - ['@test Model Types Updated but Unchanged Do not Trigger Callbacks']( - assert - ) { + ['@test Model Types Updated but Unchanged Do not Trigger Callbacks'](assert) { assert.expect(0); let records = emberA([1, 2, 3]); this.add( @@ -171,7 +161,7 @@ moduleFor( DataAdapter.extend({ getRecords() { return records; - } + }, }) ); this.add('model:post', PostClass); @@ -186,10 +176,7 @@ moduleFor( } function modelTypesUpdated() { - assert.ok( - false, - "modelTypesUpdated should not be triggered if the array didn't change" - ); + assert.ok(false, "modelTypesUpdated should not be triggered if the array didn't change"); } adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated); @@ -215,7 +202,7 @@ moduleFor( }, getRecordKeywords() { return ['Post ' + countAdded]; - } + }, }) ); this.add('model:post', PostClass); @@ -236,11 +223,7 @@ moduleFor( ['Post ' + countAdded], 'Sets search keywords correctly' ); - assert.strictEqual( - record.object, - post, - 'Sets the object to the record instance' - ); + assert.strictEqual(record.object, post, 'Sets the object to the record instance'); } adapter.watchRecords('post', recordsAdded); @@ -273,7 +256,7 @@ moduleFor( }, getRecordColumnValues(record) { return { title: get(record, 'title') }; - } + }, }) ); this.add('model:post', PostClass); @@ -290,11 +273,7 @@ moduleFor( assert.equal(records[0].columnValues.title, 'Post Modified'); } - let release = adapter.watchRecords( - 'post', - recordsAdded, - recordsUpdated - ); + let release = adapter.watchRecords('post', recordsAdded, recordsUpdated); release(); set(post, 'title', 'New Title'); assert.equal(updatesCalled, 1, 'Release function removes observers'); diff --git a/packages/ember-glimmer/tests/integration/application/actions-test.js b/packages/ember-glimmer/tests/integration/application/actions-test.js index 213912ee283..fea8b910dc0 100644 --- a/packages/ember-glimmer/tests/integration/application/actions-test.js +++ b/packages/ember-glimmer/tests/integration/application/actions-test.js @@ -1,9 +1,5 @@ import { Controller } from 'ember-runtime'; -import { - moduleFor, - ApplicationTest, - RenderingTest -} from '../../utils/test-case'; +import { moduleFor, ApplicationTest, RenderingTest } from '../../utils/test-case'; import { Component } from '../../utils/helpers'; import { getDebugFunction, setDebugFunction } from 'ember-debug'; @@ -33,8 +29,8 @@ moduleFor( actions: { handleIt() { assert.ok(true, 'controller received action properly'); - } - } + }, + }, }) ); @@ -48,9 +44,7 @@ moduleFor( }); } - ['@test actions in nested outlet template target their controller']( - assert - ) { + ['@test actions in nested outlet template target their controller'](assert) { assert.expect(1); this.add( @@ -58,12 +52,9 @@ moduleFor( Controller.extend({ actions: { handleIt() { - assert.ok( - false, - 'application controller should not have received action!' - ); - } - } + assert.ok(false, 'application controller should not have received action!'); + }, + }, }) ); @@ -73,15 +64,12 @@ moduleFor( actions: { handleIt() { assert.ok(true, 'controller received action properly'); - } - } + }, + }, }) ); - this.addTemplate( - 'index', - '' - ); + this.addTemplate('index', ''); return this.visit('/').then(() => { this.runTask(() => this.$('#handle-it').click()); @@ -103,10 +91,10 @@ moduleFor( actions: { fire() { assert.ok(false); - } - } + }, + }, }), - template: `` + template: ``, }); this.render('{{foo-bar tagName=""}}'); diff --git a/packages/ember-glimmer/tests/integration/application/engine-test.js b/packages/ember-glimmer/tests/integration/application/engine-test.js index ba3617d3b10..51e996a8273 100644 --- a/packages/ember-glimmer/tests/integration/application/engine-test.js +++ b/packages/ember-glimmer/tests/integration/application/engine-test.js @@ -49,7 +49,7 @@ moduleFor( return enginePromise.then(() => syncHandler(name)); }; - } + }, }; } @@ -74,7 +74,7 @@ moduleFor( Route.extend({ model() { hooks.push('application - application'); - } + }, }) ); @@ -87,44 +87,41 @@ moduleFor( 'controller:application', Controller.extend({ queryParams: ['lang'], - lang: '' + lang: '', }) ); this.register( 'controller:category', Controller.extend({ - queryParams: ['type'] + queryParams: ['type'], }) ); this.register( 'controller:authorKtrl', Controller.extend({ - queryParams: ['official'] + queryParams: ['official'], }) ); - this.register( - 'template:application', - compile('Engine{{lang}}{{outlet}}') - ); + this.register('template:application', compile('Engine{{lang}}{{outlet}}')); this.register( 'route:application', Route.extend({ model() { hooks.push('engine - application'); - } + }, }) ); this.register( 'route:author', Route.extend({ - controllerName: 'authorKtrl' + controllerName: 'authorKtrl', }) ); if (self._additionalEngineRegistrations) { self._additionalEngineRegistrations.call(this); } - } + }, }) ); } @@ -144,10 +141,10 @@ moduleFor( init() { this._super(...arguments); hooks.push('engine - application'); - } + }, }) ); - } + }, }) ); } @@ -164,7 +161,7 @@ moduleFor( Route.extend({ model() { hooks.push('application - application'); - } + }, }) ); @@ -174,19 +171,16 @@ moduleFor( init() { this._super(...arguments); this.register('template:foo', compile('foo partial')); - this.register( - 'template:application', - compile('Engine{{outlet}} {{partial "foo"}}') - ); + this.register('template:application', compile('Engine{{outlet}} {{partial "foo"}}')); this.register( 'route:application', Route.extend({ model() { hooks.push('engine - application'); - } + }, }) ); - } + }, }) ); } @@ -198,7 +192,7 @@ moduleFor( Route.extend({ model() { hooks.push('application - application'); - } + }, }) ); } @@ -212,20 +206,17 @@ moduleFor( init() { this._super(...arguments); this.register('template:foo', compile('foo partial')); - this.register( - 'template:application', - compile('Engine {{partial "foo"}}') - ); + this.register('template:application', compile('Engine {{partial "foo"}}')); this.register( 'controller:application', Controller.extend({ init() { this._super(...arguments); hooks.push('engine - application'); - } + }, }) ); - } + }, }) ); } @@ -242,22 +233,16 @@ moduleFor( Engine.extend({ init() { this._super(...arguments); - this.register( - 'template:components/foo-bar', - compile(`{{partial "troll"}}`) - ); + this.register('template:components/foo-bar', compile(`{{partial "troll"}}`)); this.register('template:troll', compile('{{attrs.wat}}')); this.register( 'controller:application', Controller.extend({ - contextType: 'Engine' + contextType: 'Engine', }) ); - this.register( - 'template:application', - compile('Engine {{foo-bar wat=contextType}}') - ); - } + this.register('template:application', compile('Engine {{foo-bar wat=contextType}}')); + }, }) ); } @@ -289,7 +274,7 @@ moduleFor( 'controller:application', Controller.extend({ contextType: 'Application', - 'ambiguous-curlies': 'Controller Data!' + 'ambiguous-curlies': 'Controller Data!', }) ); @@ -307,7 +292,7 @@ moduleFor( this.register( 'controller:application', Controller.extend({ - contextType: 'Engine' + contextType: 'Engine', }) ); this.register('template:application', sharedTemplate); @@ -317,7 +302,7 @@ moduleFor(

Component!

`) ); - } + }, }) ); @@ -334,7 +319,7 @@ moduleFor( `); let sharedComponent = Component.extend({ - layout: sharedLayout + layout: sharedLayout, }); this.addTemplate( @@ -373,7 +358,7 @@ moduleFor(

Component!

`) ); - } + }, }) ); @@ -482,9 +467,7 @@ moduleFor( }); } - ['@test deactivate should be called on Engine Routes before destruction']( - assert - ) { + ['@test deactivate should be called on Engine Routes before destruction'](assert) { assert.expect(3); this.setupAppAndRoutableEngine(); @@ -500,14 +483,11 @@ moduleFor( Route.extend({ deactivate() { assert.notOk(this.isDestroyed, 'Route is not destroyed'); - assert.notOk( - this.isDestroying, - 'Route is not being destroyed' - ); - } + assert.notOk(this.isDestroying, 'Route is not being destroyed'); + }, }) ); - } + }, }) ); @@ -524,9 +504,7 @@ moduleFor( }); } - ['@test error substate route works for the application route of an Engine']( - assert - ) { + ['@test error substate route works for the application route of an Engine'](assert) { assert.expect(2); let errorEntered = RSVP.defer(); @@ -538,19 +516,16 @@ moduleFor( Route.extend({ activate() { next(errorEntered.resolve); - } + }, }) ); - this.register( - 'template:application_error', - compile('Error! {{model.message}}') - ); + this.register('template:application_error', compile('Error! {{model.message}}')); this.register( 'route:post', Route.extend({ model() { return RSVP.reject(new Error('Oh, noes!')); - } + }, }) ); }); @@ -580,7 +555,7 @@ moduleFor( Route.extend({ activate() { next(errorEntered.resolve); - } + }, }) ); this.register('template:error', compile('Error! {{model.message}}')); @@ -589,7 +564,7 @@ moduleFor( Route.extend({ model() { return RSVP.reject(new Error('Oh, noes!')); - } + }, }) ); }); @@ -607,9 +582,7 @@ moduleFor( }); } - ['@test error substate route works for a child route of an Engine']( - assert - ) { + ['@test error substate route works for a child route of an Engine'](assert) { assert.expect(2); let errorEntered = RSVP.defer(); @@ -621,19 +594,16 @@ moduleFor( Route.extend({ activate() { next(errorEntered.resolve); - } + }, }) ); - this.register( - 'template:post_error', - compile('Error! {{model.message}}') - ); + this.register('template:post_error', compile('Error! {{model.message}}')); this.register( 'route:post', Route.extend({ model() { return RSVP.reject(new Error('Oh, noes!')); - } + }, }) ); }); @@ -663,19 +633,16 @@ moduleFor( Route.extend({ activate() { next(errorEntered.resolve); - } + }, }) ); - this.register( - 'template:post.error', - compile('Error! {{model.message}}') - ); + this.register('template:post.error', compile('Error! {{model.message}}')); this.register( 'route:post.comments', Route.extend({ model() { return RSVP.reject(new Error('Oh, noes!')); - } + }, }) ); }); @@ -693,9 +660,7 @@ moduleFor( }); } - ['@test loading substate route works for the application route of an Engine']( - assert - ) { + ['@test loading substate route works for the application route of an Engine'](assert) { assert.expect(3); let done = assert.async(); @@ -709,7 +674,7 @@ moduleFor( Route.extend({ activate() { next(loadingEntered.resolve); - } + }, }) ); this.register('template:application_loading', compile('Loading')); @@ -719,7 +684,7 @@ moduleFor( Route.extend({ model() { return resolveLoading.promise; - } + }, }) ); }); @@ -742,9 +707,7 @@ moduleFor( }); } - ['@test loading route works for the application route of an Engine']( - assert - ) { + ['@test loading route works for the application route of an Engine'](assert) { assert.expect(3); let done = assert.async(); @@ -758,7 +721,7 @@ moduleFor( Route.extend({ activate() { next(loadingEntered.resolve); - } + }, }) ); this.register('template:loading', compile('Loading')); @@ -768,7 +731,7 @@ moduleFor( Route.extend({ model() { return resolveLoading.promise; - } + }, }) ); }); @@ -791,9 +754,7 @@ moduleFor( }); } - ['@test loading substate route works for a child route of an Engine']( - assert - ) { + ['@test loading substate route works for a child route of an Engine'](assert) { assert.expect(3); let resolveLoading; @@ -811,7 +772,7 @@ moduleFor( return new RSVP.Promise(resolve => { resolveLoading = resolve; }); - } + }, }) ); }); @@ -847,7 +808,7 @@ moduleFor( Route.extend({ activate() { next(loadingEntered.resolve); - } + }, }) ); this.register('template:post.loading', compile('Loading')); @@ -857,7 +818,7 @@ moduleFor( Route.extend({ model() { return resolveLoading.promise; - } + }, }) ); }); @@ -880,9 +841,7 @@ moduleFor( }); } - ["@test query params don't have stickiness by default between model"]( - assert - ) { + ["@test query params don't have stickiness by default between model"](assert) { assert.expect(1); let tmpl = '{{#link-to "blog.category" 1337}}Category 1337{{/link-to}}'; this.setupAppAndRoutableEngine(); @@ -917,14 +876,8 @@ moduleFor( let href1337 = this.element.querySelector('.author-1337').href; // check if link ends with the suffix - assert.ok( - this.stringsEndWith(href1, suffix1), - `${href1} ends with ${suffix1}` - ); - assert.ok( - this.stringsEndWith(href1337, suffix1337), - `${href1337} ends with ${suffix1337}` - ); + assert.ok(this.stringsEndWith(href1, suffix1), `${href1} ends with ${suffix1}`); + assert.ok(this.stringsEndWith(href1337, suffix1337), `${href1337} ends with ${suffix1337}`); }); } @@ -939,7 +892,7 @@ moduleFor( Route.extend({ init() { throw new Error('Whoops! Something went wrong...'); - } + }, }) ); }); diff --git a/packages/ember-glimmer/tests/integration/application/rendering-test.js b/packages/ember-glimmer/tests/integration/application/rendering-test.js index 0e8e49da387..30069f45187 100644 --- a/packages/ember-glimmer/tests/integration/application/rendering-test.js +++ b/packages/ember-glimmer/tests/integration/application/rendering-test.js @@ -44,7 +44,7 @@ moduleFor( Route.extend({ model() { return ['red', 'yellow', 'blue']; - } + }, }) ); @@ -85,7 +85,7 @@ moduleFor( Route.extend({ model() { return ['red', 'yellow', 'blue']; - } + }, }) ); @@ -138,9 +138,9 @@ moduleFor( this.render(); this.render('nav', { into: 'application', - outlet: 'nav' + outlet: 'nav', }); - } + }, }) ); @@ -149,7 +149,7 @@ moduleFor( Route.extend({ model() { return ['red', 'yellow', 'blue']; - } + }, }) ); @@ -207,9 +207,9 @@ moduleFor( this.render(); this.render('nav', { into: 'application', - outlet: 'nav' + outlet: 'nav', }); - } + }, }) ); @@ -218,7 +218,7 @@ moduleFor( Route.extend({ model() { return ['red', 'yellow', 'blue']; - } + }, }) ); @@ -290,7 +290,7 @@ moduleFor( Route.extend({ model(params) { return params.color; - } + }, }) ); @@ -317,14 +317,14 @@ moduleFor( this.add( 'controller:a', Controller.extend({ - value: 'a' + value: 'a', }) ); this.add( 'controller:b', Controller.extend({ - value: 'b' + value: 'b', }) ); @@ -353,28 +353,25 @@ moduleFor( renderTemplate(controller, model) { this.render({ controller: model.color, model }); - } + }, }) ); this.add( 'controller:red', Controller.extend({ - color: 'red' + color: 'red', }) ); this.add( 'controller:green', Controller.extend({ - color: 'green' + color: 'green', }) ); - this.addTemplate( - 'color', - 'model color: {{model.color}}, controller color: {{color}}' - ); + this.addTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); return this.visit('/colors/red') .then(() => { @@ -401,7 +398,7 @@ moduleFor( renderTemplate(controller, model) { this.render('common', { controller: 'common', model }); - } + }, }) ); @@ -414,14 +411,14 @@ moduleFor( renderTemplate(controller, model) { this.render('common', { controller: 'common', model }); - } + }, }) ); this.add( 'controller:common', Controller.extend({ - prefix: 'common' + prefix: 'common', }) ); @@ -461,7 +458,7 @@ moduleFor( Route.extend({ activate() { this.transitionTo('a'); - } + }, }) ); @@ -482,23 +479,20 @@ moduleFor( Route.extend({ model() { return { name: 'Alex' }; - } + }, }) ); - this.addTemplate( - 'routeWithError', - 'Hi {{model.name}} {{x-foo person=model}}' - ); + this.addTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); this.addComponent('x-foo', { ComponentClass: Component.extend({ init() { this._super(...arguments); this.set('person.name', 'Ben'); - } + }, }), - template: 'Hi {{person.name}} from component' + template: 'Hi {{person.name}} from component', }); let expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "template:my-app\/templates\/routeWithError.hbs" and modified in "component:x-foo"/; diff --git a/packages/ember-glimmer/tests/integration/components/append-test.js b/packages/ember-glimmer/tests/integration/components/append-test.js index 04f5400ac2d..f3e891b81f1 100644 --- a/packages/ember-glimmer/tests/integration/components/append-test.js +++ b/packages/ember-glimmer/tests/integration/components/append-test.js @@ -53,9 +53,7 @@ class AbstractAppendTest extends RenderingTest { init() { this._super(...arguments); if (name in componentsByName) { - throw new TypeError( - 'Component named: ` ' + name + ' ` already registered' - ); + throw new TypeError('Component named: ` ' + name + ' ` already registered'); } componentsByName[name] = this; pushHook('init'); @@ -109,9 +107,9 @@ class AbstractAppendTest extends RenderingTest { willDestroy() { pushHook('willDestroy'); this._super(...arguments); - } + }, }), - template: _options.template + template: _options.template, }; oldRegisterComponent.call(this, name, options); @@ -119,19 +117,18 @@ class AbstractAppendTest extends RenderingTest { this.registerComponent('x-parent', { ComponentClass: Component.extend({ - layoutName: 'components/x-parent' + layoutName: 'components/x-parent', }), - template: - '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}', }); this.registerComponent('x-child', { ComponentClass: Component.extend({ - tagName: '' + tagName: '', }), - template: '[child: {{bar}}]{{yield}}' + template: '[child: {{bar}}]{{yield}}', }); let XParent; @@ -165,7 +162,7 @@ class AbstractAppendTest extends RenderingTest { ['x-child', 'didRender'], ['x-parent', 'didInsertElement'], - ['x-parent', 'didRender'] + ['x-parent', 'didRender'], ], 'appending of x-parent' ); @@ -181,7 +178,7 @@ class AbstractAppendTest extends RenderingTest { ['x-parent', 'willRender'], ['x-parent', 'didUpdate'], - ['x-parent', 'didRender'] + ['x-parent', 'didRender'], ], 'rerender x-parent' ); @@ -203,7 +200,7 @@ class AbstractAppendTest extends RenderingTest { ['x-child', 'didRender'], ['x-parent', 'didUpdate'], - ['x-parent', 'didRender'] + ['x-parent', 'didRender'], ], 'rerender x-child' ); @@ -228,7 +225,7 @@ class AbstractAppendTest extends RenderingTest { ['x-child', 'didRender'], ['x-parent', 'didUpdate'], - ['x-parent', 'didRender'] + ['x-parent', 'didRender'], ], 'set foo = wow' ); @@ -253,7 +250,7 @@ class AbstractAppendTest extends RenderingTest { ['x-child', 'didRender'], ['x-parent', 'didUpdate'], - ['x-parent', 'didRender'] + ['x-parent', 'didRender'], ], 'set foo = zomg' ); @@ -275,7 +272,7 @@ class AbstractAppendTest extends RenderingTest { ['x-parent', 'didDestroyElement'], ['x-parent', 'willDestroy'], - ['x-child', 'willDestroy'] + ['x-child', 'willDestroy'], ], 'destroy' ); @@ -289,19 +286,18 @@ class AbstractAppendTest extends RenderingTest { layoutName: 'components/x-parent', willDestroyElement() { willDestroyCalled++; - } + }, }), - template: - '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}' + template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}', }); this.registerComponent('x-child', { ComponentClass: Component.extend({ - tagName: '' + tagName: '', }), - template: '[child: {{bar}}]{{yield}}' + template: '[child: {{bar}}]{{yield}}', }); let XParent; @@ -317,7 +313,7 @@ class AbstractAppendTest extends RenderingTest { let componentElement = this.component.element; this.assertComponentElement(componentElement, { - content: '[parent: zomg][child: zomg][yielded: zomg]' + content: '[parent: zomg][child: zomg][yielded: zomg]', }); assert.equal( @@ -329,7 +325,7 @@ class AbstractAppendTest extends RenderingTest { this.runTask(() => this.rerender()); this.assertComponentElement(componentElement, { - content: '[parent: zomg][child: zomg][yielded: zomg]' + content: '[parent: zomg][child: zomg][yielded: zomg]', }); assert.equal( @@ -341,7 +337,7 @@ class AbstractAppendTest extends RenderingTest { this.runTask(() => set(this.component, 'foo', 'wow')); this.assertComponentElement(componentElement, { - content: '[parent: wow][child: wow][yielded: wow]' + content: '[parent: wow][child: wow][yielded: wow]', }); assert.equal( @@ -353,7 +349,7 @@ class AbstractAppendTest extends RenderingTest { this.runTask(() => set(this.component, 'foo', 'zomg')); this.assertComponentElement(componentElement, { - content: '[parent: zomg][child: zomg][yielded: zomg]' + content: '[parent: zomg][child: zomg][yielded: zomg]', }); assert.equal( @@ -365,10 +361,7 @@ class AbstractAppendTest extends RenderingTest { this.runTask(() => this.component.destroy()); assert.ok(!this.component.element, 'It should not have an element'); - assert.ok( - !componentElement.parentElement, - 'The component element should be detached' - ); + assert.ok(!componentElement.parentElement, 'The component element should be detached'); this.assert.equal(willDestroyCalled, 1); } @@ -377,7 +370,7 @@ class AbstractAppendTest extends RenderingTest { let renderer = this.owner.lookup('renderer:-dom'); this.registerComponent('x-component', { - ComponentClass: Component.extend() + ComponentClass: Component.extend(), }); this.component = this.owner.factoryFor('component:x-component').create(); @@ -399,10 +392,10 @@ class AbstractAppendTest extends RenderingTest { willDestroyElement() { willDestroyCalled++; - } + }, }), - template: 'x-first {{foo}}!' + template: 'x-first {{foo}}!', }); this.registerComponent('x-second', { @@ -411,10 +404,10 @@ class AbstractAppendTest extends RenderingTest { willDestroyElement() { willDestroyCalled++; - } + }, }), - template: 'x-second {{bar}}!' + template: 'x-second {{bar}}!', }); let First, Second; @@ -438,7 +431,7 @@ class AbstractAppendTest extends RenderingTest { this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); this.assertComponentElement(componentElement2, { - content: 'x-second bar!' + content: 'x-second bar!', }); assert.equal( @@ -456,7 +449,7 @@ class AbstractAppendTest extends RenderingTest { this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); this.assertComponentElement(componentElement2, { - content: 'x-second bar!' + content: 'x-second bar!', }); assert.equal( @@ -474,7 +467,7 @@ class AbstractAppendTest extends RenderingTest { this.assertComponentElement(componentElement1, { content: 'x-first FOO!' }); this.assertComponentElement(componentElement2, { - content: 'x-second BAR!' + content: 'x-second BAR!', }); assert.equal( @@ -495,7 +488,7 @@ class AbstractAppendTest extends RenderingTest { this.assertComponentElement(componentElement1, { content: 'x-first foo!' }); this.assertComponentElement(componentElement2, { - content: 'x-second bar!' + content: 'x-second bar!', }); assert.equal( @@ -515,19 +508,10 @@ class AbstractAppendTest extends RenderingTest { }); assert.ok(!first.element, 'The first component should not have an element'); - assert.ok( - !second.element, - 'The second component should not have an element' - ); + assert.ok(!second.element, 'The second component should not have an element'); - assert.ok( - !componentElement1.parentElement, - 'The first component element should be detached' - ); - assert.ok( - !componentElement2.parentElement, - 'The second component element should be detached' - ); + assert.ok(!componentElement1.parentElement, 'The first component element should be detached'); + assert.ok(!componentElement2.parentElement, 'The second component element should be detached'); this.assert.equal(willDestroyCalled, 2); } @@ -550,8 +534,8 @@ class AbstractAppendTest extends RenderingTest { let SecondComponent = owner.factoryFor('component:second-component'); append(SecondComponent.create()); - } - }) + }, + }), }); this.registerComponent('second-component', { @@ -560,8 +544,8 @@ class AbstractAppendTest extends RenderingTest { didInsertElement() { element2 = this.element; - } - }) + }, + }), }); let FirstComponent = this.owner.factoryFor('component:first-component'); @@ -597,7 +581,7 @@ class AbstractAppendTest extends RenderingTest { this._instance = OtherRoot.create({ didInsertElement() { element2 = this.element; - } + }, }); append(this._instance); @@ -605,8 +589,8 @@ class AbstractAppendTest extends RenderingTest { willDestroy() { this._instance.destroy(); - } - }) + }, + }), }); this.registerComponent('baz-qux', { @@ -626,7 +610,7 @@ class AbstractAppendTest extends RenderingTest { this._instance = OtherRoot.create({ didInsertElement() { element4 = this.element; - } + }, }); append(this._instance); @@ -634,8 +618,8 @@ class AbstractAppendTest extends RenderingTest { willDestroy() { this._instance.destroy(); - } - }) + }, + }), }); let instantiatedRoots = 0; @@ -650,8 +634,8 @@ class AbstractAppendTest extends RenderingTest { willDestroy() { destroyedRoots++; this._super(...arguments); - } - }) + }, + }), }); this.render( @@ -709,24 +693,19 @@ moduleFor( return document.getElementById('qunit-fixture'); } - ['@test raises an assertion when the target does not exist in the DOM']( - assert - ) { + ['@test raises an assertion when the target does not exist in the DOM'](assert) { this.registerComponent('foo-bar', { ComponentClass: Component.extend({ - layoutName: 'components/foo-bar' + layoutName: 'components/foo-bar', }), - template: 'FOO BAR!' + template: 'FOO BAR!', }); let FooBar = this.owner.factoryFor('component:foo-bar'); this.component = FooBar.create(); - assert.ok( - !this.component.element, - 'precond - should not have an element' - ); + assert.ok(!this.component.element, 'precond - should not have an element'); this.runTask(() => { expectAssertion(() => { @@ -734,10 +713,7 @@ moduleFor( }, /You tried to append to \(#does-not-exist-in-dom\) but that isn't in the DOM/); }); - assert.ok( - !this.component.element, - 'component should not have an element' - ); + assert.ok(!this.component.element, 'component should not have an element'); } } ); diff --git a/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js b/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js index 3f1bf9c3d22..c2bcea2adf3 100644 --- a/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js +++ b/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js @@ -8,12 +8,12 @@ moduleFor( class extends RenderingTest { ['@test it can have attribute bindings']() { let FooBarComponent = Component.extend({ - attributeBindings: ['foo:data-foo', 'bar:data-bar'] + attributeBindings: ['foo:data-foo', 'bar:data-bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); @@ -21,7 +21,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -29,7 +29,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -40,7 +40,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -51,28 +51,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); } ['@test it can have attribute bindings with attrs']() { let FooBarComponent = Component.extend({ - attributeBindings: ['attrs.foo:data-foo', 'attrs.baz.bar:data-bar'] + attributeBindings: ['attrs.foo:data-foo', 'attrs.baz.bar:data-bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=model.foo baz=model.baz}}', { - model: { foo: undefined, baz: { bar: 'bar' } } + model: { foo: undefined, baz: { bar: 'bar' } }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { 'data-bar': 'bar' } + attrs: { 'data-bar': 'bar' }, }); this.runTask(() => this.rerender()); @@ -80,7 +80,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { 'data-bar': 'bar' } + attrs: { 'data-bar': 'bar' }, }); this.runTask(() => { @@ -91,31 +91,31 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'model', { foo: undefined, - baz: { bar: 'bar' } + baz: { bar: 'bar' }, }) ); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { 'data-bar': 'bar' } + attrs: { 'data-bar': 'bar' }, }); } ['@test it can have attribute bindings with a nested path']() { let FooBarComponent = Component.extend({ - attributeBindings: ['foo.bar:data-foo-bar'] + attributeBindings: ['foo.bar:data-foo-bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); @@ -123,7 +123,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -131,7 +131,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo.bar', 'FOO-BAR')); @@ -139,7 +139,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'FOO-BAR' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo.bar', undefined)); @@ -147,7 +147,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo', undefined)); @@ -155,7 +155,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo', { bar: 'foo-bar' })); @@ -163,28 +163,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, - content: 'hello' + content: 'hello', }); } ['@test handles non-microsyntax attributeBindings']() { let FooBarComponent = Component.extend({ - attributeBindings: ['type'] + attributeBindings: ['type'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar type=submit}}', { - submit: 'submit' + submit: 'submit', }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -192,7 +192,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'submit', 'password')); @@ -200,7 +200,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'submit', null)); @@ -208,7 +208,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'submit', 'submit')); @@ -216,18 +216,18 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, - content: 'hello' + content: 'hello', }); } ['@test non-microsyntax attributeBindings cannot contain nested paths']() { let FooBarComponent = Component.extend({ - attributeBindings: ['foo.bar'] + attributeBindings: ['foo.bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -237,22 +237,22 @@ moduleFor( ['@test normalizes attributeBindings for property names']() { let FooBarComponent = Component.extend({ - attributeBindings: ['tiTLe'] + attributeBindings: ['tiTLe'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar tiTLe=name}}', { - name: 'qux' + name: 'qux', }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, - content: 'hello' + content: 'hello', }); this.assertStableRerender(); @@ -262,7 +262,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'name', 'qux')); @@ -270,28 +270,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, - content: 'hello' + content: 'hello', }); } ['@test normalizes attributeBindings for attribute names']() { let FooBarComponent = Component.extend({ - attributeBindings: ['foo:data-FOO'] + attributeBindings: ['foo:data-FOO'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=foo}}', { - foo: 'qux' + foo: 'qux', }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, - content: 'hello' + content: 'hello', }); this.assertStableRerender(); @@ -301,7 +301,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo', 'qux')); @@ -309,29 +309,29 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, - content: 'hello' + content: 'hello', }); } ['@test attributeBindings handles null/undefined']() { let FooBarComponent = Component.extend({ - attributeBindings: ['fizz', 'bar'] + attributeBindings: ['fizz', 'bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar fizz=fizz bar=bar}}', { fizz: null, - bar: undefined + bar: undefined, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -339,7 +339,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -350,7 +350,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { fizz: 'fizz', bar: 'bar' }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -361,28 +361,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); } ['@test attributeBindings handles number value']() { let FooBarComponent = Component.extend({ - attributeBindings: ['size'] + attributeBindings: ['size'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar size=size}}', { - size: 21 + size: 21, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -390,7 +390,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'size', 0)); @@ -398,7 +398,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '0' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'size', 21)); @@ -406,7 +406,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, - content: 'hello' + content: 'hello', }); } @@ -418,12 +418,12 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); @@ -431,7 +431,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -439,7 +439,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(component, 'type', 'checkbox')); @@ -447,7 +447,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'checkbox' }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(component, 'type', 'password')); @@ -455,33 +455,33 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, - content: 'hello' + content: 'hello', }); } ['@test can set attributeBindings on component with a different tagName']() { let FooBarComponent = Component.extend({ tagName: 'input', - attributeBindings: ['type', 'isDisabled:disabled'] + attributeBindings: ['type', 'isDisabled:disabled'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); this.render('{{foo-bar type=type isDisabled=disabled}}', { type: 'password', - disabled: false + disabled: false, }); this.assertComponentElement(this.firstChild, { tagName: 'input', - attrs: { type: 'password' } + attrs: { type: 'password' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'input', - attrs: { type: 'password' } + attrs: { type: 'password' }, }); this.runTask(() => { @@ -491,7 +491,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'input', - attrs: { type: 'checkbox', disabled: '' } + attrs: { type: 'checkbox', disabled: '' }, }); this.runTask(() => { @@ -501,45 +501,45 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'input', - attrs: { type: 'password' } + attrs: { type: 'password' }, }); } ['@test should allow namespaced attributes in micro syntax']() { let FooBarComponent = Component.extend({ - attributeBindings: ['xlinkHref:xlink:href'] + attributeBindings: ['xlinkHref:xlink:href'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); this.render('{{foo-bar type=type xlinkHref=xlinkHref}}', { - xlinkHref: '/foo.png' + xlinkHref: '/foo.png', }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { 'xlink:href': '/foo.png' } + attrs: { 'xlink:href': '/foo.png' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { 'xlink:href': '/foo.png' } + attrs: { 'xlink:href': '/foo.png' }, }); this.runTask(() => set(this.context, 'xlinkHref', '/lol.png')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { 'xlink:href': '/lol.png' } + attrs: { 'xlink:href': '/lol.png' }, }); this.runTask(() => set(this.context, 'xlinkHref', '/foo.png')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { 'xlink:href': '/foo.png' } + attrs: { 'xlink:href': '/foo.png' }, }); } @@ -548,7 +548,7 @@ moduleFor( // String object instead of a normal string. ['@test should allow for String objects']() { let FooBarComponent = Component.extend({ - attributeBindings: ['foo'] + attributeBindings: ['foo'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); @@ -556,19 +556,19 @@ moduleFor( this.render('{{foo-bar foo=foo}}', { foo: function() { return this; - }.call('bar') + }.call('bar'), }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { foo: 'bar' } + attrs: { foo: 'bar' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { foo: 'bar' } + attrs: { foo: 'bar' }, }); this.runTask(() => @@ -583,7 +583,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { foo: 'baz' } + attrs: { foo: 'baz' }, }); this.runTask(() => @@ -598,81 +598,81 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { foo: 'bar' } + attrs: { foo: 'bar' }, }); } ['@test can set id initially via attributeBindings ']() { let FooBarComponent = Component.extend({ - attributeBindings: ['specialSauce:id'] + attributeBindings: ['specialSauce:id'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); this.render('{{foo-bar specialSauce=sauce}}', { - sauce: 'special-sauce' + sauce: 'special-sauce', }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'special-sauce' } + attrs: { id: 'special-sauce' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'special-sauce' } + attrs: { id: 'special-sauce' }, }); this.runTask(() => set(this.context, 'sauce', 'foo')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'special-sauce' } + attrs: { id: 'special-sauce' }, }); this.runTask(() => set(this.context, 'sauce', 'special-sauce')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'special-sauce' } + attrs: { id: 'special-sauce' }, }); } ['@test attributeBindings are overwritten']() { let FooBarComponent = Component.extend({ attributeBindings: ['href'], - href: 'a href' + href: 'a href', }); let FizzBarComponent = FooBarComponent.extend({ - attributeBindings: ['newHref:href'] + attributeBindings: ['newHref:href'], }); this.registerComponent('fizz-bar', { ComponentClass: FizzBarComponent }); this.render('{{fizz-bar newHref=href}}', { - href: 'dog.html' + href: 'dog.html', }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { href: 'dog.html' } + attrs: { href: 'dog.html' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { href: 'dog.html' } + attrs: { href: 'dog.html' }, }); this.runTask(() => set(this.context, 'href', 'cat.html')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { href: 'cat.html' } + attrs: { href: 'cat.html' }, }); } @@ -692,12 +692,12 @@ moduleFor( } this.attributeBindings = bindings; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render( @@ -713,22 +713,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -736,22 +736,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -762,22 +762,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'bar', 'BAR')); @@ -785,22 +785,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'BAR' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO', 'data-bar': 'BAR' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -811,22 +811,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, - content: 'hello' + content: 'hello', }); } @@ -840,12 +840,12 @@ moduleFor( ['@test asserts if an attributeBinding is setup on class']() { let FooBarComponent = Component.extend({ - attributeBindings: ['class'] + attributeBindings: ['class'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -858,21 +858,21 @@ moduleFor( let FooBarComponent = Component.extend({ tagName: 'a', - attributeBindings: ['href'] + attributeBindings: ['href'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar href=xss}}', { - xss: "javascript:alert('foo')" + xss: "javascript:alert('foo')", }); this.assertComponentElement(this.firstChild, { tagName: 'a', - attrs: { href: "unsafe:javascript:alert('foo')" } + attrs: { href: "unsafe:javascript:alert('foo')" }, }); } @@ -881,28 +881,28 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar role=role}}', { role: 'button' }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { role: 'button' } + attrs: { role: 'button' }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { role: 'button' } + attrs: { role: 'button' }, }); this.runTask(() => set(this.context, 'role', 'combobox')); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { role: 'combobox' } + attrs: { role: 'combobox' }, }); this.runTask(() => set(this.context, 'role', null)); @@ -915,30 +915,24 @@ moduleFor( ComponentClass: Component.extend({ attributeBindings: ['id'], - id: undefined - }) + id: undefined, + }), }); this.registerComponent('baz-qux', { ComponentClass: Component.extend({ attributeBindings: ['somethingUndefined:id'], - somethingUndefined: undefined - }) + somethingUndefined: undefined, + }), }); this.render(`{{foo-bar}}{{baz-qux}}`); this.assertComponentElement(this.nthChild(0), { content: '' }); this.assertComponentElement(this.nthChild(1), { content: '' }); - this.assert.ok( - this.nthChild(0).id.match(/ember\d+/), - 'a valid `id` was used' - ); - this.assert.ok( - this.nthChild(1).id.match(/ember\d+/), - 'a valid `id` was used' - ); + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); } ['@test component with an `id` attribute binding of null']() { @@ -946,30 +940,24 @@ moduleFor( ComponentClass: Component.extend({ attributeBindings: ['id'], - id: null - }) + id: null, + }), }); this.registerComponent('baz-qux', { ComponentClass: Component.extend({ attributeBindings: ['somethingNull:id'], - somethingNull: null - }) + somethingNull: null, + }), }); this.render(`{{foo-bar}}{{baz-qux}}`); this.assertComponentElement(this.nthChild(0), { content: '' }); this.assertComponentElement(this.nthChild(1), { content: '' }); - this.assert.ok( - this.nthChild(0).id.match(/ember\d+/), - 'a valid `id` was used' - ); - this.assert.ok( - this.nthChild(1).id.match(/ember\d+/), - 'a valid `id` was used' - ); + this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used'); + this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used'); } } ); diff --git a/packages/ember-glimmer/tests/integration/components/attrs-lookup-test.js b/packages/ember-glimmer/tests/integration/components/attrs-lookup-test.js index 75e2df15495..e387b22c825 100644 --- a/packages/ember-glimmer/tests/integration/components/attrs-lookup-test.js +++ b/packages/ember-glimmer/tests/integration/components/attrs-lookup-test.js @@ -10,7 +10,7 @@ moduleFor( this.registerComponent('foo-bar', { template: '{{first}}' }); this.render(`{{foo-bar first=firstAttr}}`, { - firstAttr: 'first attr' + firstAttr: 'first attr', }); this.assertText('first attr'); @@ -28,24 +28,22 @@ moduleFor( this.assertText('first attr'); } - ['@test it should be able to lookup attrs without `attrs.` - component access']( - assert - ) { + ['@test it should be able to lookup attrs without `attrs.` - component access'](assert) { let instance; let FooBarComponent = Component.extend({ init() { this._super(...arguments); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{first}}' + template: '{{first}}', }); this.render(`{{foo-bar first=firstAttr}}`, { - firstAttr: 'first attr' + firstAttr: 'first attr', }); assert.equal(instance.get('first'), 'first attr'); @@ -63,9 +61,7 @@ moduleFor( this.assertText('first attr'); } - ['@test should be able to modify a provided attr into local state #11571 / #11559']( - assert - ) { + ['@test should be able to modify a provided attr into local state #11571 / #11559'](assert) { let instance; let FooBarComponent = Component.extend({ init() { @@ -75,20 +71,16 @@ moduleFor( didReceiveAttrs() { this.set('first', this.get('first').toUpperCase()); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{first}}' + template: '{{first}}', }); this.render(`{{foo-bar first="first attr"}}`); - assert.equal( - instance.get('first'), - 'FIRST ATTR', - 'component lookup uses local state' - ); + assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state'); this.assertText('FIRST ATTR'); this.runTask(() => this.rerender()); @@ -115,50 +107,34 @@ moduleFor( }, didReceiveAttrs() { - assert.equal( - this.get('woot'), - wootVal, - 'found attr in didReceiveAttrs' - ); - } + assert.equal(this.get('woot'), wootVal, 'found attr in didReceiveAttrs'); + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); this.render(`{{foo-bar woot=woot}}`, { - woot: wootVal + woot: wootVal, }); assert.equal(instance.get('woot'), 'yes', 'component found attr'); this.runTask(() => this.rerender()); - assert.equal( - instance.get('woot'), - 'yes', - 'component found attr after rerender' - ); + assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender'); this.runTask(() => { wootVal = 'nope'; set(this.context, 'woot', wootVal); }); - assert.equal( - instance.get('woot'), - 'nope', - 'component found attr after attr change' - ); + assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change'); this.runTask(() => { wootVal = 'yes'; set(this.context, 'woot', wootVal); }); - assert.equal( - instance.get('woot'), - 'yes', - 'component found attr after reset' - ); + assert.equal(instance.get('woot'), 'yes', 'component found attr after reset'); } ['@test getAttr() should return the same value as get()'](assert) { @@ -184,21 +160,13 @@ moduleFor( attrFirstPositional, 'root property matches attrs value' ); - assert.equal( - rootFirst, - attrFirst, - 'root property matches attrs value' - ); - assert.equal( - rootSecond, - attrSecond, - 'root property matches attrs value' - ); - } + assert.equal(rootFirst, attrFirst, 'root property matches attrs value'); + assert.equal(rootSecond, attrSecond, 'root property matches attrs value'); + }, }); FooBarComponent.reopenClass({ - positionalParams: ['firstPositional'] + positionalParams: ['firstPositional'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); @@ -206,24 +174,16 @@ moduleFor( this.render(`{{foo-bar firstPositional first=first second=second}}`, { firstPositional: 'firstPositional', first: 'first', - second: 'second' + second: 'second', }); - assert.equal( - instance.get('firstPositional'), - 'firstPositional', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); assert.equal(instance.get('first'), 'first', 'matches known value'); assert.equal(instance.get('second'), 'second', 'matches known value'); this.runTask(() => this.rerender()); - assert.equal( - instance.get('firstPositional'), - 'firstPositional', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); assert.equal(instance.get('first'), 'first', 'matches known value'); assert.equal(instance.get('second'), 'second', 'matches known value'); @@ -231,11 +191,7 @@ moduleFor( set(this.context, 'first', 'third'); }); - assert.equal( - instance.get('firstPositional'), - 'firstPositional', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); assert.equal(instance.get('first'), 'third', 'matches known value'); assert.equal(instance.get('second'), 'second', 'matches known value'); @@ -243,11 +199,7 @@ moduleFor( set(this.context, 'second', 'fourth'); }); - assert.equal( - instance.get('firstPositional'), - 'firstPositional', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); assert.equal(instance.get('first'), 'third', 'matches known value'); assert.equal(instance.get('second'), 'fourth', 'matches known value'); @@ -255,11 +207,7 @@ moduleFor( set(this.context, 'firstPositional', 'fifth'); }); - assert.equal( - instance.get('firstPositional'), - 'fifth', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'fifth', 'matches known value'); assert.equal(instance.get('first'), 'third', 'matches known value'); assert.equal(instance.get('second'), 'fourth', 'matches known value'); @@ -269,11 +217,7 @@ moduleFor( set(this.context, 'second', 'second'); }); - assert.equal( - instance.get('firstPositional'), - 'firstPositional', - 'matches known value' - ); + assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value'); assert.equal(instance.get('first'), 'first', 'matches known value'); assert.equal(instance.get('second'), 'second', 'matches known value'); } @@ -287,7 +231,7 @@ moduleFor( return htmlSafe(`height: ${height}px; background-color: ${color};`); }), color: 'red', - height: 20 + height: 20, }); let BarClass = FooClass.extend({ @@ -295,7 +239,7 @@ moduleFor( this._super(...arguments); this.height = 150; }, - color: 'yellow' + color: 'yellow', }); this.registerComponent('x-foo', { ComponentClass: FooClass }); @@ -305,15 +249,15 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { style: styles('height: 20px; background-color: red;') } + attrs: { style: styles('height: 20px; background-color: red;') }, }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', - attrs: { style: styles('height: 150px; background-color: yellow;') } + attrs: { style: styles('height: 150px; background-color: yellow;') }, }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', - attrs: { style: styles('height: 150px; background-color: green;') } + attrs: { style: styles('height: 150px; background-color: green;') }, }); this.assertStableRerender(); diff --git a/packages/ember-glimmer/tests/integration/components/class-bindings-test.js b/packages/ember-glimmer/tests/integration/components/class-bindings-test.js index 1c69e3ece85..2867300bf95 100644 --- a/packages/ember-glimmer/tests/integration/components/class-bindings-test.js +++ b/packages/ember-glimmer/tests/integration/components/class-bindings-test.js @@ -9,24 +9,24 @@ moduleFor( class extends RenderingTest { ['@test it can have class name bindings on the class definition']() { let FooBarComponent = Component.extend({ - classNameBindings: ['foo', 'isEnabled:enabled', 'isHappy:happy:sad'] + classNameBindings: ['foo', 'isEnabled:enabled', 'isHappy:happy:sad'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=foo isEnabled=isEnabled isHappy=isHappy}}', { foo: 'foo', isEnabled: true, - isHappy: false + isHappy: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -34,7 +34,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -45,7 +45,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view FOO sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -56,7 +56,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view happy') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -68,31 +68,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); } ['@test attrs in classNameBindings']() { let FooBarComponent = Component.extend({ - classNameBindings: [ - 'attrs.joker:purple:green', - 'attrs.batman.robin:black:red' - ] + classNameBindings: ['attrs.joker:purple:green', 'attrs.batman.robin:black:red'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar joker=model.wat batman=model.super}}', { - model: { wat: false, super: { robin: true } } + model: { wat: false, super: { robin: true } }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view green black') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -100,7 +97,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view green black') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -111,20 +108,20 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view purple red') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'model', { wat: false, - super: { robin: true } + super: { robin: true }, }) ); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view green black') }, - content: 'hello' + content: 'hello', }); } @@ -140,29 +137,25 @@ moduleFor( isBig: true, isOpen: false, isUp: true, - bar: true - } + bar: true, + }, } ); this.assertComponentElement(this.firstChild, { attrs: { - class: classes( - 'ember-view some-initially-true-property static big closed isTruthy' - ) + class: classes('ember-view some-initially-true-property static big closed isTruthy'), }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { attrs: { - class: classes( - 'ember-view some-initially-true-property static big closed isTruthy' - ) + class: classes('ember-view some-initially-true-property static big closed isTruthy'), }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -179,9 +172,9 @@ moduleFor( attrs: { class: classes( 'ember-view some-initially-false-property some-initially-undefined-property static open down isFalsy' - ) + ), }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -192,43 +185,37 @@ moduleFor( isBig: true, isOpen: false, isUp: true, - bar: true + bar: true, }); }); this.assertComponentElement(this.firstChild, { attrs: { - class: classes( - 'ember-view some-initially-true-property static big closed isTruthy' - ) + class: classes('ember-view some-initially-true-property static big closed isTruthy'), }, - content: 'hello' + content: 'hello', }); } ['@test it can have class name bindings with nested paths']() { let FooBarComponent = Component.extend({ - classNameBindings: [ - 'foo.bar', - 'is.enabled:enabled', - 'is.happy:happy:sad' - ] + classNameBindings: ['foo.bar', 'is.enabled:enabled', 'is.happy:happy:sad'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar foo=foo is=is}}', { foo: { bar: 'foo-bar' }, - is: { enabled: true, happy: false } + is: { enabled: true, happy: false }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar enabled sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -236,7 +223,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar enabled sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -247,7 +234,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view FOO-BAR sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -258,7 +245,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view happy') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -269,7 +256,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view sad') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -280,29 +267,29 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar enabled sad') }, - content: 'hello' + content: 'hello', }); } ['@test it should dasherize the path when the it resolves to true']() { let FooBarComponent = Component.extend({ - classNameBindings: ['fooBar', 'nested.fooBarBaz'] + classNameBindings: ['fooBar', 'nested.fooBarBaz'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar fooBar=fooBar nested=nested}}', { fooBar: true, - nested: { fooBarBaz: false } + nested: { fooBarBaz: false }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -310,7 +297,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -321,7 +308,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar-baz') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -332,7 +319,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view FOO-BAR') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'nested', null)); @@ -340,7 +327,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view FOO-BAR') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -351,20 +338,20 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo-bar') }, - content: 'hello' + content: 'hello', }); } ['@test const bindings can be set as attrs']() { this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classNameBindings="foo:enabled:disabled"}}', { - foo: true + foo: true, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view enabled') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -372,7 +359,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view enabled') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo', false)); @@ -380,7 +367,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view disabled') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'foo', true)); @@ -388,28 +375,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view enabled') }, - content: 'hello' + content: 'hello', }); } ['@test :: class name syntax works with an empty true class']() { let FooBarComponent = Component.extend({ - classNameBindings: ['isEnabled::not-enabled'] + classNameBindings: ['isEnabled::not-enabled'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar isEnabled=enabled}}', { - enabled: false + enabled: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view not-enabled') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'enabled', true)); @@ -417,7 +404,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'enabled', false)); @@ -425,28 +412,28 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view not-enabled') }, - content: 'hello' + content: 'hello', }); } ['@test uses all provided static class names (issue #11193)']() { let FooBarComponent = Component.extend({ - classNameBindings: [':class-one', ':class-two'] + classNameBindings: [':class-one', ':class-two'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}', { - enabled: false + enabled: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view class-one class-two') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'enabled', true)); @@ -454,18 +441,18 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view class-one class-two') }, - content: 'hello' + content: 'hello', }); } ['@test Providing a binding with a space in it asserts']() { let FooBarComponent = Component.extend({ - classNameBindings: 'i:think:i am:so:clever' + classNameBindings: 'i:think:i am:so:clever', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -477,12 +464,12 @@ moduleFor( let FooBarComponent = Component.extend({ foo: 'foo', bar: 'bar', - classNameBindings: ['foo', , 'bar'] // eslint-disable-line no-sparse-arrays + classNameBindings: ['foo', , 'bar'], // eslint-disable-line no-sparse-arrays }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -494,12 +481,12 @@ moduleFor( let FooBarComponent = Component.extend({ foo: 'foo', bar: 'bar', - classNameBindings: ['foo', '', 'bar'] + classNameBindings: ['foo', '', 'bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -523,12 +510,12 @@ moduleFor( if (this.get('bindIsHappy')) { bindings.push('isHappy:happy:sad'); } - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render( @@ -544,22 +531,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view foo enabled') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view foo sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: classes('ember-view foo') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -567,22 +554,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view foo enabled') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view foo sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: classes('ember-view foo') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -593,22 +580,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view FOO') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view FOO sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view FOO sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: classes('ember-view FOO') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -619,22 +606,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view happy') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view happy') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: classes('ember-view') }, - content: 'hello' + content: 'hello', }); this.runTask(() => { @@ -646,22 +633,22 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view foo enabled') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view foo sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view foo enabled sad') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: classes('ember-view foo') }, - content: 'hello' + content: 'hello', }); } @@ -669,12 +656,12 @@ moduleFor( let FooBarComponent = Component.extend({ classNameBindings: computed(function() { return ['isHappy:happy:sad']; - }) + }), }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -695,7 +682,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo ember-view') } + attrs: { class: classes('foo ember-view') }, }); this.runTask(() => this.rerender()); @@ -703,7 +690,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo ember-view') } + attrs: { class: classes('foo ember-view') }, }); } @@ -711,13 +698,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="birdman:respeck" class="myName"}}', { - birdman: true + birdman: true, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('respeck myName ember-view') } + attrs: { class: classes('respeck myName ember-view') }, }); this.runTask(() => this.rerender()); @@ -725,7 +712,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('respeck myName ember-view') } + attrs: { class: classes('respeck myName ember-view') }, }); } @@ -733,13 +720,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="myName:respeck"}}', { - myName: true + myName: true, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('respeck ember-view') } + attrs: { class: classes('respeck ember-view') }, }); this.runTask(() => this.rerender()); @@ -747,7 +734,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('respeck ember-view') } + attrs: { class: classes('respeck ember-view') }, }); } @@ -755,13 +742,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="myName::shade"}}', { - myName: false + myName: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('shade ember-view') } + attrs: { class: classes('shade ember-view') }, }); this.runTask(() => this.rerender()); @@ -769,7 +756,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('shade ember-view') } + attrs: { class: classes('shade ember-view') }, }); } @@ -777,13 +764,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="myName:respeck"}}', { - myName: false + myName: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); this.runTask(() => this.rerender()); @@ -791,7 +778,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); } @@ -803,7 +790,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); this.runTask(() => this.rerender()); @@ -811,7 +798,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); } @@ -819,13 +806,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { - swag: false + swag: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('scrub ember-view') } + attrs: { class: classes('scrub ember-view') }, }); this.runTask(() => this.rerender()); @@ -833,7 +820,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('scrub ember-view') } + attrs: { class: classes('scrub ember-view') }, }); } @@ -841,13 +828,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { - swag: true + swag: true, }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fresh ember-view') } + attrs: { class: classes('fresh ember-view') }, }); this.runTask(() => this.rerender()); @@ -855,7 +842,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fresh ember-view') } + attrs: { class: classes('fresh ember-view') }, }); } } diff --git a/packages/ember-glimmer/tests/integration/components/contextual-components-test.js b/packages/ember-glimmer/tests/integration/components/contextual-components-test.js index 742aade1b5f..15daee18364 100644 --- a/packages/ember-glimmer/tests/integration/components/contextual-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/contextual-components-test.js @@ -12,7 +12,7 @@ moduleFor( let expectedText = 'Hodi'; this.registerComponent('-looked-up', { - template: expectedText + template: expectedText, }); this.render('{{component (component "-looked-up")}}'); @@ -27,9 +27,9 @@ moduleFor( ['@test renders with component helper with invocation params, hash']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{greeting}} {{name}}' + template: '{{greeting}} {{name}}', }); this.render(strip` @@ -45,20 +45,17 @@ moduleFor( ['@test GH#13742 keeps nested rest positional parameters if rendered with no positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'params' + positionalParams: 'params', }), - template: '{{#each params as |p|}}{{p}}{{/each}}' + template: '{{#each params as |p|}}{{p}}{{/each}}', }); - this.render( - '{{component (component "-looked-up" model.greeting model.name)}}', - { - model: { - greeting: 'Gabon ', - name: 'Zack' - } - } - ); + this.render('{{component (component "-looked-up" model.greeting model.name)}}', { + model: { + greeting: 'Gabon ', + name: 'Zack', + }, + }); this.assertText('Gabon Zack'); @@ -74,9 +71,7 @@ moduleFor( this.assertText('Good morning Matthew'); - this.runTask(() => - this.context.set('model', { greeting: 'Gabon ', name: 'Zack' }) - ); + this.runTask(() => this.context.set('model', { greeting: 'Gabon ', name: 'Zack' })); this.assertText('Gabon Zack'); } @@ -85,9 +80,9 @@ moduleFor( ['@test overwrites nested rest positional parameters if rendered with positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'params' + positionalParams: 'params', }), - template: '{{#each params as |p|}}{{p}}{{/each}}' + template: '{{#each params as |p|}}{{p}}{{/each}}', }); this.render( @@ -95,8 +90,8 @@ moduleFor( { model: { greeting: 'Gabon ', - name: 'Zack ' - } + name: 'Zack ', + }, } ); @@ -114,9 +109,7 @@ moduleFor( this.assertText('Good morning Matthew Matthew Good morning '); - this.runTask(() => - this.context.set('model', { greeting: 'Gabon ', name: 'Zack ' }) - ); + this.runTask(() => this.context.set('model', { greeting: 'Gabon ', name: 'Zack ' })); this.assertText('Gabon Zack Zack Gabon '); } @@ -124,20 +117,17 @@ moduleFor( ['@test GH#13742 keeps nested rest positional parameters if nested and rendered with no positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'params' + positionalParams: 'params', }), - template: '{{#each params as |p|}}{{p}}{{/each}}' + template: '{{#each params as |p|}}{{p}}{{/each}}', }); - this.render( - '{{component (component (component "-looked-up" model.greeting model.name))}}', - { - model: { - greeting: 'Gabon ', - name: 'Zack' - } - } - ); + this.render('{{component (component (component "-looked-up" model.greeting model.name))}}', { + model: { + greeting: 'Gabon ', + name: 'Zack', + }, + }); this.assertText('Gabon Zack'); @@ -153,9 +143,7 @@ moduleFor( this.assertText('Good morning Matthew'); - this.runTask(() => - this.context.set('model', { greeting: 'Gabon ', name: 'Zack' }) - ); + this.runTask(() => this.context.set('model', { greeting: 'Gabon ', name: 'Zack' })); this.assertText('Gabon Zack'); } @@ -163,9 +151,9 @@ moduleFor( ['@test overwrites nested rest positional parameters if nested with new pos params and rendered with no positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'params' + positionalParams: 'params', }), - template: '{{#each params as |p|}}{{p}}{{/each}}' + template: '{{#each params as |p|}}{{p}}{{/each}}', }); this.render( @@ -173,8 +161,8 @@ moduleFor( { model: { greeting: 'Gabon ', - name: 'Zack ' - } + name: 'Zack ', + }, } ); @@ -192,9 +180,7 @@ moduleFor( this.assertText('Good morning Matthew Matthew Good morning '); - this.runTask(() => - this.context.set('model', { greeting: 'Gabon ', name: 'Zack ' }) - ); + this.runTask(() => this.context.set('model', { greeting: 'Gabon ', name: 'Zack ' })); this.assertText('Gabon Zack Zack Gabon '); } @@ -202,9 +188,9 @@ moduleFor( ['@test renders with component helper with curried params, hash']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{greeting}} {{name}}' + template: '{{greeting}} {{name}}', }); this.render(strip` @@ -220,17 +206,17 @@ moduleFor( ['@test updates when component path is bound']() { this.registerComponent('-mandarin', { - template: 'ni hao' + template: 'ni hao', }); this.registerComponent('-hindi', { - template: 'Namaste' + template: 'Namaste', }); this.render('{{component (component model.lookupComponent)}}', { model: { - lookupComponent: '-mandarin' - } + lookupComponent: '-mandarin', + }, }); this.assertText('ni hao'); @@ -243,26 +229,21 @@ moduleFor( this.assertText('Namaste'); - this.runTask(() => - this.context.set('model', { lookupComponent: '-mandarin' }) - ); + this.runTask(() => this.context.set('model', { lookupComponent: '-mandarin' })); this.assertText('ni hao'); } ['@test updates when curried hash argument is bound']() { this.registerComponent('-looked-up', { - template: '{{greeting}}' + template: '{{greeting}}', }); - this.render( - `{{component (component "-looked-up" greeting=model.greeting)}}`, - { - model: { - greeting: 'Hodi' - } - } - ); + this.render(`{{component (component "-looked-up" greeting=model.greeting)}}`, { + model: { + greeting: 'Hodi', + }, + }); this.assertText('Hodi'); @@ -281,7 +262,7 @@ moduleFor( ['@test updates when curried hash arguments is bound in block form']() { this.registerComponent('-looked-up', { - template: '{{greeting}}' + template: '{{greeting}}', }); this.render( @@ -291,8 +272,8 @@ moduleFor( {{/with}}`, { model: { - greeting: 'Hodi' - } + greeting: 'Hodi', + }, } ); @@ -314,9 +295,9 @@ moduleFor( ['@test nested components do not overwrite positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] + positionalParams: ['name', 'age'], }), - template: '{{name}} {{age}}' + template: '{{name}} {{age}}', }); this.render( @@ -333,14 +314,12 @@ moduleFor( ['@test positional parameters are combined not clobbered']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['greeting', 'name', 'age'] + positionalParams: ['greeting', 'name', 'age'], }), - template: '{{greeting}} {{name}} {{age}}' + template: '{{greeting}} {{name}} {{age}}', }); - this.render( - '{{component (component (component "-looked-up" "Hi") "Max") 9}}' - ); + this.render('{{component (component (component "-looked-up" "Hi") "Max") 9}}'); this.assertText('Hi Max 9'); @@ -352,9 +331,9 @@ moduleFor( ['@test nested components positional parameters override named parameters [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] + positionalParams: ['name', 'age'], }), - template: '{{name}} {{age}}' + template: '{{name}} {{age}}', }); expectDeprecation(() => { @@ -373,9 +352,9 @@ moduleFor( ['@test nested components with positional params at outer layer are override hash parameters [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['greeting', 'name', 'age'] + positionalParams: ['greeting', 'name', 'age'], }), - template: '{{greeting}} {{name}} {{age}}' + template: '{{greeting}} {{name}} {{age}}', }); expectDeprecation(() => { @@ -388,8 +367,8 @@ moduleFor( {{/with}}`, { model: { - greeting: 'Hodi' - } + greeting: 'Hodi', + }, } ); }, 'You cannot specify both a positional param (at position 1) and the hash argument `name`.'); @@ -404,10 +383,10 @@ moduleFor( ['@test nested components with positional params at middle layer partially override hash parameters [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['greeting', 'name', 'age'] + positionalParams: ['greeting', 'name', 'age'], }), - template: '{{greeting}} {{name}} {{age}}' + template: '{{greeting}} {{name}} {{age}}', }); expectDeprecation(() => { @@ -420,8 +399,8 @@ moduleFor( {{/with}}`, { model: { - greeting: 'Hodi' - } + greeting: 'Hodi', + }, } ); }, 'You cannot specify both a positional param (at position 0) and the hash argument `greeting`.'); @@ -436,10 +415,10 @@ moduleFor( ['@test nested components with positional params at invocation override earlier hash parameters [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['greeting', 'name', 'age'] + positionalParams: ['greeting', 'name', 'age'], }), - template: '{{greeting}} {{name}} {{age}}' + template: '{{greeting}} {{name}} {{age}}', }); expectDeprecation(() => { @@ -452,8 +431,8 @@ moduleFor( {{/with}}`, { model: { - greeting: 'Hodi' - } + greeting: 'Hodi', + }, } ); }, 'You cannot specify both a positional param (at position 0) and the hash argument `greeting`.'); @@ -475,7 +454,7 @@ moduleFor( ['@test nested components overwrite hash parameters']() { this.registerComponent('-looked-up', { - template: '{{greeting}} {{name}} {{age}}' + template: '{{greeting}} {{name}} {{age}}', }); this.render( @@ -487,8 +466,8 @@ moduleFor( {{/with}}`, { model: { - greeting: 'Hodi' - } + greeting: 'Hodi', + }, } ); @@ -510,16 +489,16 @@ moduleFor( ['@test bound outer named parameters get updated in the right scope']() { this.registerComponent('-inner-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['comp'] + positionalParams: ['comp'], }), - template: '{{component comp "Inner"}}' + template: '{{component comp "Inner"}}', }); this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] + positionalParams: ['name', 'age'], }), - template: '{{name}} {{age}}' + template: '{{name}} {{age}}', }); this.render( @@ -527,8 +506,8 @@ moduleFor( { model: { outerName: 'Outer', - outerAge: 28 - } + outerAge: 28, + }, } ); @@ -549,7 +528,7 @@ moduleFor( this.runTask(() => { this.context.set('model', { outerName: 'Outer', - outerAge: 28 + outerAge: 28, }); }); @@ -559,13 +538,13 @@ moduleFor( ['@test bound outer hash parameters get updated in the right scope']() { this.registerComponent('-inner-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['comp'] + positionalParams: ['comp'], }), - template: '{{component comp name="Inner"}}' + template: '{{component comp name="Inner"}}', }); this.registerComponent('-looked-up', { - template: '{{name}} {{age}}' + template: '{{name}} {{age}}', }); this.render( @@ -573,8 +552,8 @@ moduleFor( { model: { outerName: 'Outer', - outerAge: 28 - } + outerAge: 28, + }, } ); @@ -595,7 +574,7 @@ moduleFor( this.runTask(() => { this.context.set('model', { outerName: 'Outer', - outerAge: 28 + outerAge: 28, }); }); @@ -605,9 +584,9 @@ moduleFor( ['@test conflicting positional and hash parameters trigger a deprecation if in the same component context [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{greeting}} {{name}}' + template: '{{greeting}} {{name}}', }); expectDeprecation(() => { @@ -622,19 +601,16 @@ moduleFor( // assertion. This test checks it does not. this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{greeting}} {{name}}' + template: '{{greeting}} {{name}}', }); - this.render( - '{{component (component "-looked-up" model.name greeting="Hodi")}}', - { - model: { - name: 'Hodari' - } - } - ); + this.render('{{component (component "-looked-up" model.name greeting="Hodi")}}', { + model: { + name: 'Hodari', + }, + }); this.assertText('Hodi Hodari'); @@ -654,9 +630,9 @@ moduleFor( ['@test conflicting positional and hash parameters trigger a deprecation [DEPRECATED]']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{greeting}} {{name}}' + template: '{{greeting}} {{name}}', }); expectDeprecation(() => { @@ -677,7 +653,7 @@ moduleFor( this.render('{{component (component componentName name=name)}}', { componentName: undefined, - name: 'Alex' + name: 'Alex', }); this.assertText(''); @@ -700,7 +676,7 @@ moduleFor( this.render('{{component (component componentName name=name)}}', { componentName: 'foo-bar', - name: 'Alex' + name: 'Alex', }); this.assertText('hello Alex'); @@ -723,7 +699,7 @@ moduleFor( this.render('{{component (component componentName name=name)}}', { componentName: null, - name: 'Alex' + name: 'Alex', }); this.assertText(''); @@ -746,7 +722,7 @@ moduleFor( this.render('{{component (component componentName name=name)}}', { componentName: 'foo-bar', - name: 'Alex' + name: 'Alex', }); this.assertText('hello Alex'); @@ -773,7 +749,7 @@ moduleFor( ['@test raises an assertion when component path is not a component name (dynamic)']() { expectAssertion(() => { this.render('{{component (component compName)}}', { - compName: 'not-a-component' + compName: 'not-a-component', }); }, 'Could not find component named "not-a-component" (no component or template with that name was found)'); } @@ -781,7 +757,7 @@ moduleFor( ['@test renders with dot path']() { let expectedText = 'Hodi'; this.registerComponent('-looked-up', { - template: expectedText + template: expectedText, }); this.render(strip` @@ -799,7 +775,7 @@ moduleFor( ['@test renders with dot path and attr']() { let expectedText = 'Hodi'; this.registerComponent('-looked-up', { - template: '{{expectedText}}' + template: '{{expectedText}}', }); this.render( @@ -809,8 +785,8 @@ moduleFor( {{/with}}`, { model: { - expectedText - } + expectedText, + }, } ); @@ -832,7 +808,7 @@ moduleFor( ['@test renders with dot path and curried over attr']() { let expectedText = 'Hodi'; this.registerComponent('-looked-up', { - template: '{{expectedText}}' + template: '{{expectedText}}', }); this.render( @@ -842,8 +818,8 @@ moduleFor( {{/with}}`, { model: { - expectedText - } + expectedText, + }, } ); @@ -865,9 +841,9 @@ moduleFor( ['@test renders with dot path and with rest positional parameters']() { this.registerComponent('-looked-up', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'params' + positionalParams: 'params', }), - template: '{{params}}' + template: '{{params}}', }); let expectedText = 'Hodi'; @@ -879,8 +855,8 @@ moduleFor( {{/with}}`, { model: { - expectedText - } + expectedText, + }, } ); @@ -909,10 +885,10 @@ moduleFor( ComponentClass: Component.extend({ didReceiveAttrs() { value = this.getAttr('value'); - } + }, }).reopenClass({ - positionalParams: ['value'] - }) + positionalParams: ['value'], + }), }); this.render( @@ -931,14 +907,14 @@ moduleFor( ComponentClass: Component.extend({ didReceiveAttrs() { this.set('myProp', this.getAttr('my-parent-attr')); - } + }, }), - template: '{{myProp}}' + template: '{{myProp}}', }); this.registerComponent('my-component', { template: - '{{yield (hash my-nested-component=(component "my-nested-component" my-parent-attr=my-attr))}}' + '{{yield (hash my-nested-component=(component "my-nested-component" my-parent-attr=my-attr))}}', }); this.registerComponent('my-action-component', { @@ -946,21 +922,21 @@ moduleFor( actions: { changeValue() { this.incrementProperty('myProp'); - } - } + }, + }, }), template: strip` {{#my-component my-attr=myProp as |api|}} {{api.my-nested-component}} {{/my-component}}
- ` + `, }); this.render('{{my-action-component myProp=model.myProp}}', { model: { - myProp: 1 - } + myProp: 1, + }, }); assert.equal(this.$('#nested-prop').text(), '1'); @@ -986,11 +962,11 @@ moduleFor( // If parameters and attributes are not handled correctly, setting a value // in an invokation can leak to others invocation. this.registerComponent('select-box', { - template: '{{yield (hash option=(component "select-box-option"))}}' + template: '{{yield (hash option=(component "select-box-option"))}}', }); this.registerComponent('select-box-option', { - template: '{{label}}' + template: '{{label}}', }); this.render(strip` @@ -1006,20 +982,18 @@ moduleFor( this.assertText('Foo'); } - ['@test parameters in a contextual component are mutable when value is a param']( - assert - ) { + ['@test parameters in a contextual component are mutable when value is a param'](assert) { // This checks that a `(mut)` is added to parameters and attributes to // contextual components when it is a param. this.registerComponent('change-button', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['val'] + positionalParams: ['val'], }), template: strip` ` + `, }); this.render( @@ -1028,8 +1002,8 @@ moduleFor( {{model.val2}}`, { model: { - val2: 8 - } + val2: 8, + }, } ); @@ -1050,7 +1024,7 @@ moduleFor( ['@test tagless blockless components render'](assert) { this.registerComponent('my-comp', { - ComponentClass: Component.extend({ tagName: '' }) + ComponentClass: Component.extend({ tagName: '' }), }); this.render(`{{my-comp}}`); @@ -1060,27 +1034,25 @@ moduleFor( assert.equal(this.$().text(), ''); } - ['@test GH#13494 tagless blockless component with property binding']( - assert - ) { + ['@test GH#13494 tagless blockless component with property binding'](assert) { this.registerComponent('outer-component', { ComponentClass: Component.extend({ message: 'hello', actions: { change() { this.set('message', 'goodbye'); - } - } + }, + }, }), template: strip` message: {{message}}{{inner-component message=message}} - ` + `, }); setup.call(this, assert); @@ -1541,7 +1432,7 @@ class MutableParamTestGenerator { this.runTask(() => this.context.set('model', { val2: 8 })); assert.equal(this.$('.value').text(), '8'); - } + }, }; } } @@ -1553,7 +1444,7 @@ applyMixins( title: 'param', setup() { this.render('{{component (component "change-button" model.val2)}}'); - } + }, }, { @@ -1561,42 +1452,38 @@ applyMixins( setup() { this.registerComponent('my-comp', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['components'] + positionalParams: ['components'], }), - template: '{{component components.comp}}' + template: '{{component components.comp}}', }); - this.render( - '{{my-comp (hash comp=(component "change-button" model.val2))}}' - ); - } + this.render('{{my-comp (hash comp=(component "change-button" model.val2))}}'); + }, }, { title: 'hash value', setup() { this.registerComponent('my-comp', { - template: '{{component component}}' + template: '{{component component}}', }); - this.render( - '{{my-comp component=(component "change-button" val=model.val2)}}' - ); - } + this.render('{{my-comp component=(component "change-button" val=model.val2)}}'); + }, }, { title: 'nested hash value', setup() { this.registerComponent('my-comp', { - template: '{{component components.button}}' + template: '{{component components.button}}', }); this.render( '{{my-comp components=(hash button=(component "change-button" val=model.val2))}}' ); - } - } + }, + }, ]) ); diff --git a/packages/ember-glimmer/tests/integration/components/curly-components-test.js b/packages/ember-glimmer/tests/integration/components/curly-components-test.js index d1132cd87f7..7a742ab8ad5 100644 --- a/packages/ember-glimmer/tests/integration/components/curly-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/curly-components-test.js @@ -1,22 +1,12 @@ /* globals EmberDev */ import { set, get, observer, on, computed, run } from 'ember-metal'; -import { - Object as EmberObject, - A as emberA, - inject, - Service -} from 'ember-runtime'; +import { Object as EmberObject, A as emberA, inject, Service } from 'ember-runtime'; import { jQueryDisabled } from 'ember-views/system/jquery'; import { ENV } from 'ember-environment'; import { Component, compile, htmlSafe } from '../../utils/helpers'; import { strip } from '../../utils/abstract-test-case'; import { moduleFor, RenderingTest } from '../../utils/test-case'; -import { - classes, - equalTokens, - equalsElement, - styles -} from '../../utils/test-helpers'; +import { classes, equalTokens, equalsElement, styles } from '../../utils/test-helpers'; import { MANDATORY_SETTER } from 'ember/features'; moduleFor( @@ -48,13 +38,13 @@ moduleFor( this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' }); this.render('{{foo-bar id=customId}}', { - customId: 'bizz' + customId: 'bizz', }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, - content: 'bizz bizz' + content: 'bizz bizz', }); this.runTask(() => this.rerender()); @@ -62,7 +52,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, - content: 'bizz bizz' + content: 'bizz bizz', }); this.runTask(() => set(this.context, 'customId', 'bar')); @@ -70,7 +60,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, - content: 'bar bizz' + content: 'bar bizz', }); this.runTask(() => set(this.context, 'customId', 'bizz')); @@ -78,7 +68,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, - content: 'bizz bizz' + content: 'bizz bizz', }); } @@ -89,12 +79,12 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{elementId}}' + template: '{{elementId}}', }); this.render('{{foo-bar}}'); @@ -102,22 +92,18 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, - content: 'blahzorz' + content: 'blahzorz', }); if (EmberDev && !EmberDev.runningProdBuild) { - let willThrow = () => - run(null, set, component, 'elementId', 'herpyderpy'); + let willThrow = () => run(null, set, component, 'elementId', 'herpyderpy'); - assert.throws( - willThrow, - /Changing a view's elementId after creation is not allowed/ - ); + assert.throws(willThrow, /Changing a view's elementId after creation is not allowed/); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, - content: 'blahzorz' + content: 'blahzorz', }); } } @@ -129,7 +115,7 @@ moduleFor( init() { this._super(...arguments); this.local = 'hey'; - } + }, }); this.registerTemplate('fizz-bar', `FIZZ BAR {{local}}`); @@ -150,7 +136,7 @@ moduleFor( init() { this._super(...arguments); this.lulz = 'heyo'; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); @@ -160,16 +146,14 @@ moduleFor( this.assertText('so much layout wat heyo'); } - ['@test passing undefined elementId results in a default elementId']( - assert - ) { + ['@test passing undefined elementId results in a default elementId'](assert) { let FooBarComponent = Component.extend({ - tagName: 'h1' + tagName: 'h1', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'something' + template: 'something', }); this.render('{{foo-bar id=somethingUndefined}}'); @@ -193,12 +177,12 @@ moduleFor( ['@test id is an alias for elementId'](assert) { let FooBarComponent = Component.extend({ - tagName: 'h1' + tagName: 'h1', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'something' + template: 'something', }); this.render('{{foo-bar id="custom-id"}}'); @@ -224,26 +208,26 @@ moduleFor( ['@test it can have a custom tagName']() { let FooBarComponent = Component.extend({ - tagName: 'foo-bar' + tagName: 'foo-bar', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); } @@ -252,26 +236,26 @@ moduleFor( init() { this._super(); this.tagName = 'foo-bar'; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); } @@ -282,14 +266,14 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', - content: 'hello' + content: 'hello', }); } @@ -297,12 +281,12 @@ moduleFor( let FooBarComponent = Component.extend({ tagName: computed(function() { return 'foo-bar'; - }) + }), }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); expectAssertion(() => { @@ -315,12 +299,12 @@ moduleFor( let FooBarComponent = Component.extend({ didInsertElement() { componentClass = this.element.className; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar class="foo-bar"}}'); @@ -330,12 +314,12 @@ moduleFor( ['@test it can have custom classNames']() { let FooBarComponent = Component.extend({ - classNames: ['foo', 'bar'] + classNames: ['foo', 'bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); @@ -343,7 +327,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo bar') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -351,7 +335,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo bar') }, - content: 'hello' + content: 'hello', }); } @@ -359,13 +343,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar class=somethingFalsy}}', { - somethingFalsy: false + somethingFalsy: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -373,7 +357,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, - content: 'hello' + content: 'hello', }); } @@ -381,13 +365,13 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar class=model.someTruth}}', { - model: { someTruth: true } + model: { someTruth: true }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view some-truth') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -395,7 +379,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view some-truth') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'model.someTruth', false)); @@ -403,7 +387,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view') }, - content: 'hello' + content: 'hello', }); this.runTask(() => set(this.context, 'model', { someTruth: true })); @@ -411,7 +395,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view some-truth') }, - content: 'hello' + content: 'hello', }); } @@ -419,33 +403,33 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar class=(if fooBar "foo-bar")}}', { - fooBar: true + fooBar: true, }); this.assertComponentElement(this.firstChild, { content: 'hello', - attrs: { class: classes('ember-view foo-bar') } + attrs: { class: classes('ember-view foo-bar') }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { content: 'hello', - attrs: { class: classes('ember-view foo-bar') } + attrs: { class: classes('ember-view foo-bar') }, }); this.runTask(() => set(this.context, 'fooBar', false)); this.assertComponentElement(this.firstChild, { content: 'hello', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); this.runTask(() => set(this.context, 'fooBar', true)); this.assertComponentElement(this.firstChild, { content: 'hello', - attrs: { class: classes('ember-view foo-bar') } + attrs: { class: classes('ember-view foo-bar') }, }); } @@ -454,17 +438,13 @@ moduleFor( init() { this._super(); this.classNames = this.classNames.slice(); - this.classNames.push( - 'foo', - 'bar', - `outside-${this.get('extraClass')}` - ); - } + this.classNames.push('foo', 'bar', `outside-${this.get('extraClass')}`); + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar extraClass="baz"}}'); @@ -472,7 +452,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo bar outside-baz') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -480,18 +460,18 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: classes('ember-view foo bar outside-baz') }, - content: 'hello' + content: 'hello', }); } ['@test it can set custom classNames from the invocation']() { let FooBarComponent = Component.extend({ - classNames: ['foo'] + classNames: ['foo'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render(strip` @@ -503,17 +483,17 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view foo bar baz') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view foo bar baz') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view foo') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.rerender()); @@ -521,17 +501,17 @@ moduleFor( this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: classes('ember-view foo bar baz') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: classes('ember-view foo bar baz') }, - content: 'hello' + content: 'hello', }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: classes('ember-view foo') }, - content: 'hello' + content: 'hello', }); } @@ -542,12 +522,12 @@ moduleFor( init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); @@ -572,12 +552,12 @@ moduleFor( init() { this._super(); fooBarInstance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '' + template: '', }); this.render('{{foo-bar}}'); @@ -600,23 +580,23 @@ moduleFor( init() { this._super(); fooBarInstance = this; - } + }, }); let FooBarBazComponent = Component.extend({ init() { this._super(); fooBarBazInstance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'foo-bar {{foo-bar-baz}}' + template: 'foo-bar {{foo-bar-baz}}', }); this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, - template: 'foo-bar-baz' + template: 'foo-bar-baz', }); this.render('{{foo-bar}}'); @@ -640,13 +620,13 @@ moduleFor( ['@feature(ember-glimmer-named-arguments) it renders passed named arguments']() { this.registerComponent('foo-bar', { - template: '{{@foo}}' + template: '{{@foo}}', }); this.render('{{foo-bar foo=model.bar}}', { model: { - bar: 'Hola' - } + bar: 'Hola', + }, }); this.assertText('Hola'); @@ -666,13 +646,13 @@ moduleFor( ['@test it reflects named arguments as properties']() { this.registerComponent('foo-bar', { - template: '{{foo}}' + template: '{{foo}}', }); this.render('{{foo-bar foo=model.bar}}', { model: { - bar: 'Hola' - } + bar: 'Hola', + }, }); this.assertText('Hola'); @@ -692,19 +672,19 @@ moduleFor( ['@test it can render a basic component with a block']() { this.registerComponent('foo-bar', { - template: '{{yield}} - In component' + template: '{{yield}} - In component', }); this.render('{{#foo-bar}}hello{{/foo-bar}}'); this.assertComponentElement(this.firstChild, { - content: 'hello - In component' + content: 'hello - In component', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'hello - In component' + content: 'hello - In component', }); } @@ -712,19 +692,19 @@ moduleFor( this.registerPartial('_partialWithYield', 'yielded: [{{yield}}]'); this.registerComponent('foo-bar', { - template: '{{partial "partialWithYield"}} - In component' + template: '{{partial "partialWithYield"}} - In component', }); this.render('{{#foo-bar}}hello{{/foo-bar}}'); this.assertComponentElement(this.firstChild, { - content: 'yielded: [hello] - In component' + content: 'yielded: [hello] - In component', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'yielded: [hello] - In component' + content: 'yielded: [hello] - In component', }); } @@ -732,19 +712,19 @@ moduleFor( this.registerPartial('_partialWithYield', 'yielded: [{{yield "hello"}}]'); this.registerComponent('foo-bar', { - template: '{{partial "partialWithYield"}} - In component' + template: '{{partial "partialWithYield"}} - In component', }); this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}'); this.assertComponentElement(this.firstChild, { - content: 'yielded: [hello] - In component' + content: 'yielded: [hello] - In component', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'yielded: [hello] - In component' + content: 'yielded: [hello] - In component', }); } @@ -756,12 +736,12 @@ moduleFor( this._super(); instance = this; this.set('message', 'hello'); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{message}}' + template: '{{message}}', }); this.render('{{foo-bar}}'); @@ -810,12 +790,12 @@ moduleFor( instance = this; }, - name: 'foo-bar' + name: 'foo-bar', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{yield this}}' + template: '{{yield this}}', }); this.render('{{#foo-bar as |component|}}{{component.name}}{{/foo-bar}}'); @@ -841,12 +821,12 @@ moduleFor( this._super(...arguments); instance = this; }, - greeting: 'hello' + greeting: 'hello', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{yield greeting greetee.firstName}}' + template: '{{yield greeting greetee.firstName}}', }); this.render( @@ -854,48 +834,48 @@ moduleFor( { person: { firstName: 'Joel', - lastName: 'Kang' - } + lastName: 'Kang', + }, } ); this.assertComponentElement(this.firstChild, { - content: 'Joel Kang, hello' + content: 'Joel Kang, hello', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'Joel Kang, hello' + content: 'Joel Kang, hello', }); this.runTask(() => set(this.context, 'person', { firstName: 'Dora', - lastName: 'the Explorer' + lastName: 'the Explorer', }) ); this.assertComponentElement(this.firstChild, { - content: 'Dora the Explorer, hello' + content: 'Dora the Explorer, hello', }); this.runTask(() => set(instance, 'greeting', 'hola')); this.assertComponentElement(this.firstChild, { - content: 'Dora the Explorer, hola' + content: 'Dora the Explorer, hola', }); this.runTask(() => { set(instance, 'greeting', 'hello'); set(this.context, 'person', { firstName: 'Joel', - lastName: 'Kang' + lastName: 'Kang', }); }); this.assertComponentElement(this.firstChild, { - content: 'Joel Kang, hello' + content: 'Joel Kang, hello', }); } @@ -906,12 +886,12 @@ moduleFor( this._super(...arguments); instance = this; }, - danger: 0 + danger: 0, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{danger}}{{yield danger}}' + template: '{{danger}}{{yield danger}}', }); // On initial render, create streams. The bug will not have manifested yet, but at this point @@ -948,8 +928,8 @@ moduleFor( willDestroy() { this._super(); destroyed[this.get('id')]++; - } - }) + }, + }), }); this.render( @@ -980,7 +960,7 @@ moduleFor( cond2: true, cond3: true, cond4: true, - cond5: true + cond5: true, } ); @@ -996,7 +976,7 @@ moduleFor( 5: 0, 6: 0, 7: 0, - 8: 0 + 8: 0, }); this.runTask(() => set(this.context, 'cond5', false)); @@ -1011,7 +991,7 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 0 + 8: 0, }); this.runTask(() => { @@ -1028,7 +1008,7 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 1 + 8: 1, }); this.runTask(() => { @@ -1044,7 +1024,7 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 1 + 8: 1, }); } @@ -1055,12 +1035,12 @@ moduleFor( this._super(...arguments); component = this; }, - output: 'you need to be more bold' + output: 'you need to be more bold', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{output}}' + template: '{{output}}', }); this.render('{{foo-bar}}'); @@ -1075,9 +1055,7 @@ moduleFor( this.assertText('you are so super'); - this.runTask(() => - set(component, 'output', 'you need to be more bold') - ); + this.runTask(() => set(component, 'output', 'you need to be more bold')); } ['@test should not escape HTML in triple mustaches']() { @@ -1089,12 +1067,12 @@ moduleFor( this._super(...arguments); component = this; }, - output: expectedHtmlBold + output: expectedHtmlBold, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{{output}}}' + template: '{{{output}}}', }); this.render('{{foo-bar}}'); @@ -1123,12 +1101,12 @@ moduleFor( this._super(...arguments); component = this; }, - output: htmlSafe(expectedHtmlBold) + output: htmlSafe(expectedHtmlBold), }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{output}}' + template: '{{output}}', }); this.render('{{foo-bar}}'); @@ -1139,9 +1117,7 @@ moduleFor( equalTokens(this.firstChild, expectedHtmlBold); - this.runTask(() => - set(component, 'output', htmlSafe(expectedHtmlItalic)) - ); + this.runTask(() => set(component, 'output', htmlSafe(expectedHtmlItalic))); equalTokens(this.firstChild, expectedHtmlItalic); @@ -1170,7 +1146,7 @@ moduleFor( this._super(...arguments); this.layout = this.cond ? hello : bye; templateIds.push(this.layout.id); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); @@ -1192,7 +1168,7 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('foo-bar', { @@ -1204,7 +1180,7 @@ moduleFor( {{else}} false {{/if}} - ` + `, }); this.render('{{foo-bar}}'); @@ -1225,12 +1201,12 @@ moduleFor( } ['@test lookup of component takes priority over property']() { this.registerComponent('some-component', { - template: 'some-component' + template: 'some-component', }); this.render('{{some-prop}} {{some-component}}', { 'some-component': 'not-some-component', - 'some-prop': 'some-prop' + 'some-prop': 'some-prop', }); this.assertText('some-prop some-component'); @@ -1242,11 +1218,11 @@ moduleFor( ['@test component without dash is not looked up']() { this.registerComponent('somecomponent', { - template: 'somecomponent' + template: 'somecomponent', }); this.render('{{somecomponent}}', { - somecomponent: 'notsomecomponent' + somecomponent: 'notsomecomponent', }); this.assertText('notsomecomponent'); @@ -1255,9 +1231,7 @@ moduleFor( this.assertText('notsomecomponent'); - this.runTask(() => - this.context.set('somecomponent', 'not not notsomecomponent') - ); + this.runTask(() => this.context.set('somecomponent', 'not not notsomecomponent')); this.assertText('not not notsomecomponent'); @@ -1268,11 +1242,11 @@ moduleFor( ['@test non-block with properties on attrs']() { this.registerComponent('non-block', { - template: 'In layout - someProp: {{attrs.someProp}}' + template: 'In layout - someProp: {{attrs.someProp}}', }); this.render('{{non-block someProp=prop}}', { - prop: 'something here' + prop: 'something here', }); this.assertText('In layout - someProp: something here'); @@ -1292,11 +1266,11 @@ moduleFor( ['@feature(ember-glimmer-named-arguments) non-block with named argument']() { this.registerComponent('non-block', { - template: 'In layout - someProp: {{@someProp}}' + template: 'In layout - someProp: {{@someProp}}', }); this.render('{{non-block someProp=prop}}', { - prop: 'something here' + prop: 'something here', }); this.assertText('In layout - someProp: something here'); @@ -1322,13 +1296,13 @@ moduleFor( this._super(...arguments); instance = this; this.someProp = 'value set in instance'; - } + }, }), - template: 'In layout - someProp: {{someProp}}' + template: 'In layout - someProp: {{someProp}}', }); this.render('{{non-block someProp=prop}}', { - prop: 'something passed when invoked' + prop: 'something passed when invoked', }); this.assertText('In layout - someProp: value set in instance'); @@ -1337,23 +1311,15 @@ moduleFor( this.assertText('In layout - someProp: value set in instance'); - this.runTask(() => - this.context.set('prop', 'updated something passed when invoked') - ); + this.runTask(() => this.context.set('prop', 'updated something passed when invoked')); - this.assertText( - 'In layout - someProp: updated something passed when invoked' - ); + this.assertText('In layout - someProp: updated something passed when invoked'); - this.runTask(() => - instance.set('someProp', 'update value set in instance') - ); + this.runTask(() => instance.set('someProp', 'update value set in instance')); this.assertText('In layout - someProp: update value set in instance'); - this.runTask(() => - this.context.set('prop', 'something passed when invoked') - ); + this.runTask(() => this.context.set('prop', 'something passed when invoked')); this.runTask(() => instance.set('someProp', 'value set in instance')); this.assertText('In layout - someProp: value set in instance'); @@ -1370,31 +1336,15 @@ moduleFor( callback(); if (willUpdate) { - assert.strictEqual( - willUpdateCount, - 1, - 'The willUpdate hook was fired' - ); + assert.strictEqual(willUpdateCount, 1, 'The willUpdate hook was fired'); } else { - assert.strictEqual( - willUpdateCount, - 0, - 'The willUpdate hook was not fired' - ); + assert.strictEqual(willUpdateCount, 0, 'The willUpdate hook was not fired'); } if (didReceiveAttrs) { - assert.strictEqual( - didReceiveAttrsCount, - 1, - 'The didReceiveAttrs hook was fired' - ); + assert.strictEqual(didReceiveAttrsCount, 1, 'The didReceiveAttrs hook was fired'); } else { - assert.strictEqual( - didReceiveAttrsCount, - 0, - 'The didReceiveAttrs hook was not fired' - ); + assert.strictEqual(didReceiveAttrsCount, 0, 'The didReceiveAttrs hook was not fired'); } } @@ -1406,14 +1356,14 @@ moduleFor( willUpdate() { willUpdateCount++; - } + }, }), - template: 'In layout - someProp: {{someProp}}' + template: 'In layout - someProp: {{someProp}}', }); expectHooks({ willUpdate: false, didReceiveAttrs: true }, () => { this.render('{{non-block someProp=someProp}}', { - someProp: 'wycats' + someProp: 'wycats', }); }); @@ -1459,14 +1409,14 @@ moduleFor( {{#each items as |item|}} {{item}} {{/each}} - ` + `, }); this.render('{{foo-bar value=model.value items=model.items}}', { model: { value: 'wat', - items: [1, 2, 3] - } + items: [1, 2, 3], + }, }); this.assertStableRerender(); @@ -1478,9 +1428,7 @@ moduleFor( this.assertText(strip`Args: lul | lul | lul111`); - this.runTask(() => - this.context.set('model', { value: 'wat', items: [1, 2, 3] }) - ); + this.runTask(() => this.context.set('model', { value: 'wat', items: [1, 2, 3] })); this.assertText('Args: wat | wat | wat123123123'); } @@ -1501,14 +1449,14 @@ moduleFor( {{#each items as |item|}} {{item}} {{/each}} - ` + `, }); this.render('{{foo-bar value=model.value items=model.items}}', { model: { value: 'wat', - items: [1, 2, 3] - } + items: [1, 2, 3], + }, }); this.assertStableRerender(); @@ -1520,20 +1468,18 @@ moduleFor( this.assertText(strip`Args: lul | lul | lul | lul1111`); - this.runTask(() => - this.context.set('model', { value: 'wat', items: [1, 2, 3] }) - ); + this.runTask(() => this.context.set('model', { value: 'wat', items: [1, 2, 3] })); this.assertText('Args: wat | wat | wat | wat123123123123'); } ['@test non-block with properties on self']() { this.registerComponent('non-block', { - template: 'In layout - someProp: {{someProp}}' + template: 'In layout - someProp: {{someProp}}', }); this.render('{{non-block someProp=prop}}', { - prop: 'something here' + prop: 'something here', }); this.assertText('In layout - someProp: something here'); @@ -1553,7 +1499,7 @@ moduleFor( ['@test block with properties on self']() { this.registerComponent('with-block', { - template: 'In layout - someProp: {{someProp}} - {{yield}}' + template: 'In layout - someProp: {{someProp}} - {{yield}}', }); this.render( @@ -1562,7 +1508,7 @@ moduleFor( In template {{/with-block}}`, { - prop: 'something here' + prop: 'something here', } ); @@ -1583,7 +1529,7 @@ moduleFor( ['@test block with properties on attrs']() { this.registerComponent('with-block', { - template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}' + template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}', }); this.render( @@ -1592,7 +1538,7 @@ moduleFor( In template {{/with-block}}`, { - prop: 'something here' + prop: 'something here', } ); @@ -1613,7 +1559,7 @@ moduleFor( ['@feature(ember-glimmer-named-arguments) block with named argument']() { this.registerComponent('with-block', { - template: 'In layout - someProp: {{@someProp}} - {{yield}}' + template: 'In layout - someProp: {{@someProp}} - {{yield}}', }); this.render( @@ -1622,7 +1568,7 @@ moduleFor( In template {{/with-block}}`, { - prop: 'something here' + prop: 'something here', } ); @@ -1644,12 +1590,12 @@ moduleFor( ['@test static arbitrary number of positional parameters'](assert) { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'names' + positionalParams: 'names', }), template: strip` {{#each names as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); this.render(strip` @@ -1668,37 +1614,34 @@ moduleFor( ['@test arbitrary positional parameter conflict with hash parameter is reported']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'names' + positionalParams: 'names', }), template: strip` {{#each names as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); expectAssertion(() => { - this.render( - `{{sample-component "Foo" 4 "Bar" names=numbers id="args-3"}}`, - { - numbers: [1, 2, 3] - } - ); + this.render(`{{sample-component "Foo" 4 "Bar" names=numbers id="args-3"}}`, { + numbers: [1, 2, 3], + }); }, 'You cannot specify positional parameters and the hash argument `names`.'); } ['@test can use hash parameter instead of arbitrary positional param [GH #12444]']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'names' + positionalParams: 'names', }), template: strip` {{#each names as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); this.render('{{sample-component names=things}}', { - things: emberA(['Foo', 4, 'Bar']) + things: emberA(['Foo', 4, 'Bar']), }); this.assertText('Foo4Bar'); @@ -1727,9 +1670,9 @@ moduleFor( ['@test can use hash parameter instead of positional param'](assert) { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['first', 'second'] + positionalParams: ['first', 'second'], }), - template: '{{first}} - {{second}}' + template: '{{first}} - {{second}}', }); // TODO: Fix when id is implemented @@ -1752,17 +1695,17 @@ moduleFor( ['@test dynamic arbitrary number of positional parameters']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'n' + positionalParams: 'n', }), template: strip` {{#each n as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); this.render(`{{sample-component user1 user2}}`, { user1: 'Foo', - user2: 4 + user2: 4, }); this.assertText('Foo4'); @@ -1789,11 +1732,11 @@ moduleFor( ['@test with ariaRole specified']() { this.registerComponent('aria-test', { - template: 'Here!' + template: 'Here!', }); this.render('{{aria-test ariaRole=role}}', { - role: 'main' + role: 'main', }); this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); @@ -1805,7 +1748,7 @@ moduleFor( this.runTask(() => this.context.set('role', 'input')); this.assertComponentElement(this.firstChild, { - attrs: { role: 'input' } + attrs: { role: 'input' }, }); this.runTask(() => this.context.set('role', 'main')); @@ -1816,9 +1759,9 @@ moduleFor( ['@test `template` specified in component is overridden by block']() { this.registerComponent('with-template', { ComponentClass: Component.extend({ - template: compile('Should not be used') + template: compile('Should not be used'), }), - template: '[In layout - {{name}}] {{yield}}' + template: '[In layout - {{name}}] {{yield}}', }); this.render( @@ -1828,7 +1771,7 @@ moduleFor( {{/with-template}} {{with-template name="without-block"}}`, { - name: 'Whoop, whoop!' + name: 'Whoop, whoop!', } ); @@ -1844,9 +1787,7 @@ moduleFor( this.runTask(() => this.context.set('name', 'Ole, ole')); - this.assertText( - '[In layout - with-block] [In block - Ole, ole][In layout - without-block] ' - ); + this.assertText('[In layout - with-block] [In block - Ole, ole][In layout - without-block] '); this.runTask(() => this.context.set('name', 'Whoop, whoop!')); @@ -1862,7 +1803,7 @@ moduleFor( {{yield}} {{else}} No Block! - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -1884,7 +1825,7 @@ moduleFor( {{yield}} {{else}} No Block! - {{/if}}` + {{/if}}`, }); this.render('{{with-block}}'); @@ -1903,7 +1844,7 @@ moduleFor( {{yield this}} - In Component {{else}} {{yield}} No Block! - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -1925,7 +1866,7 @@ moduleFor( {{yield this}} {{else}} {{yield}} No Block Param! - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -1943,9 +1884,9 @@ moduleFor( ['@test static named positional parameters']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] + positionalParams: ['name', 'age'], }), - template: '{{name}}{{age}}' + template: '{{name}}{{age}}', }); this.render('{{sample-component "Quint" 4}}'); @@ -1960,14 +1901,14 @@ moduleFor( ['@test dynamic named positional parameters']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] + positionalParams: ['name', 'age'], }), - template: '{{name}}{{age}}' + template: '{{name}}{{age}}', }); this.render('{{sample-component myName myAge}}', { myName: 'Quint', - myAge: 4 + myAge: 4, }); this.assertText('Quint4'); @@ -1995,15 +1936,15 @@ moduleFor( ['@test if a value is passed as a non-positional parameter, it raises an assertion']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name'] + positionalParams: ['name'], }), - template: '{{name}}' + template: '{{name}}', }); expectDeprecation(() => { this.render('{{sample-component notMyName name=myName}}', { myName: 'Quint', - notMyName: 'Sergio' + notMyName: 'Sergio', }); }, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.'); } @@ -2015,7 +1956,7 @@ moduleFor( Yes:{{yield someValue}} {{else}} No:{{yield to="inverse"}} - {{/if}}` + {{/if}}`, }); this.render( @@ -2026,7 +1967,7 @@ moduleFor( Goodbye {{/my-if}}`, { - activated: true + activated: true, } ); @@ -2052,7 +1993,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2072,7 +2013,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2092,7 +2033,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2112,7 +2053,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2132,7 +2073,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2152,7 +2093,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2172,7 +2113,7 @@ moduleFor( Yes {{else}} No - {{/if}}` + {{/if}}`, }); this.render(strip` @@ -2187,27 +2128,15 @@ moduleFor( ['@test hasBlock expression in an attribute'](assert) { this.registerComponent('check-attr', { - template: '' + template: '', }); this.render(strip` {{check-attr}} {{#check-attr}}{{/check-attr}}`); - equalsElement( - assert, - this.$('button')[0], - 'button', - { name: 'false' }, - '' - ); - equalsElement( - assert, - this.$('button')[1], - 'button', - { name: 'true' }, - '' - ); + equalsElement(assert, this.$('button')[0], 'button', { name: 'false' }, ''); + equalsElement(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); } @@ -2216,7 +2145,7 @@ moduleFor( this.registerComponent( 'check-attr', { - template: '' + template: '', }, '' ); @@ -2225,47 +2154,23 @@ moduleFor( {{#check-attr}}{{/check-attr}} {{#check-attr}}{{else}}{{/check-attr}}`); - equalsElement( - assert, - this.$('button')[0], - 'button', - { name: 'false' }, - '' - ); - equalsElement( - assert, - this.$('button')[1], - 'button', - { name: 'true' }, - '' - ); + equalsElement(assert, this.$('button')[0], 'button', { name: 'false' }, ''); + equalsElement(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); } ['@test hasBlockParams expression in an attribute'](assert) { this.registerComponent('check-attr', { - template: '' + template: '', }); this.render(strip` {{#check-attr}}{{/check-attr}} {{#check-attr as |something|}}{{/check-attr}}`); - equalsElement( - assert, - this.$('button')[0], - 'button', - { name: 'false' }, - '' - ); - equalsElement( - assert, - this.$('button')[1], - 'button', - { name: 'true' }, - '' - ); + equalsElement(assert, this.$('button')[0], 'button', { name: 'false' }, ''); + equalsElement(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); } @@ -2274,7 +2179,7 @@ moduleFor( this.registerComponent( 'check-attr', { - template: '' + template: '', }, '' ); @@ -2283,27 +2188,15 @@ moduleFor( {{#check-attr}}{{/check-attr}} {{#check-attr as |something|}}{{/check-attr}}`); - equalsElement( - assert, - this.$('button')[0], - 'button', - { name: 'false' }, - '' - ); - equalsElement( - assert, - this.$('button')[1], - 'button', - { name: 'false' }, - '' - ); + equalsElement(assert, this.$('button')[0], 'button', { name: 'false' }, ''); + equalsElement(assert, this.$('button')[1], 'button', { name: 'false' }, ''); this.assertStableRerender(); } ['@test hasBlock as a param to a helper']() { this.registerComponent('check-helper', { - template: '{{if hasBlock "true" "false"}}' + template: '{{if hasBlock "true" "false"}}', }); this.render(strip` @@ -2318,7 +2211,7 @@ moduleFor( ['@test hasBlock as an expression param to a helper']() { this.registerComponent('check-helper', { - template: '{{if (hasBlock) "true" "false"}}' + template: '{{if (hasBlock) "true" "false"}}', }); this.render(strip` @@ -2333,7 +2226,7 @@ moduleFor( ['@test hasBlock inverse as a param to a helper']() { this.registerComponent('check-helper', { - template: '{{if (hasBlock "inverse") "true" "false"}}' + template: '{{if (hasBlock "inverse") "true" "false"}}', }); this.render(strip` @@ -2348,7 +2241,7 @@ moduleFor( ['@test hasBlockParams as a param to a helper']() { this.registerComponent('check-helper', { - template: '{{if hasBlockParams "true" "false"}}' + template: '{{if hasBlockParams "true" "false"}}', }); this.render(strip` @@ -2363,7 +2256,7 @@ moduleFor( ['@test hasBlockParams as an expression param to a helper']() { this.registerComponent('check-helper', { - template: '{{if (hasBlockParams) "true" "false"}}' + template: '{{if (hasBlockParams) "true" "false"}}', }); this.render(strip` @@ -2378,7 +2271,7 @@ moduleFor( ['@test hasBlockParams inverse as a param to a helper']() { this.registerComponent('check-helper', { - template: '{{if (hasBlockParams "inverse") "true" "false"}}' + template: '{{if (hasBlockParams "inverse") "true" "false"}}', }); this.render(strip` @@ -2401,9 +2294,9 @@ moduleFor( init() { this._super(...arguments); outer = this; - } + }, }), - template: '{{x-inner-in-layout}}{{yield}}' + template: '{{x-inner-in-layout}}{{yield}}', }); this.registerComponent('x-inner-in-template', { @@ -2411,8 +2304,8 @@ moduleFor( init() { this._super(...arguments); innerTemplate = this; - } - }) + }, + }), }); this.registerComponent('x-inner-in-layout', { @@ -2420,8 +2313,8 @@ moduleFor( init() { this._super(...arguments); innerLayout = this; - } - }) + }, + }), }); this.render('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}'); @@ -2469,8 +2362,8 @@ moduleFor( init() { this._super(...arguments); outer = this; - } - }) + }, + }), }); this.registerComponent('x-inner', { @@ -2478,8 +2371,8 @@ moduleFor( init() { this._super(...arguments); inner = this; - } - }) + }, + }), }); this.render( @@ -2490,7 +2383,7 @@ moduleFor( {{/if}} {{/x-outer}}`, { - showInner: false + showInner: false, } ); @@ -2539,9 +2432,9 @@ moduleFor( this._super(...arguments); outer = this; }, - value: 1 + value: 1, }), - template: '{{#x-middle}}{{x-inner value=value}}{{/x-middle}}' + template: '{{#x-middle}}{{x-inner value=value}}{{/x-middle}}', }); this.registerComponent('x-middle', { @@ -2550,9 +2443,9 @@ moduleFor( this._super(...arguments); middle = this; }, - value: null + value: null, }), - template: '
{{value}}
{{yield}}' + template: '
{{value}}
{{yield}}', }); this.registerComponent('x-inner', { @@ -2560,18 +2453,14 @@ moduleFor( value: null, pushDataUp: observer('value', function() { middle.set('value', this.get('value')); - }) + }), }), - template: '
{{value}}
' + template: '
{{value}}
', }); this.render('{{x-outer}}'); - assert.equal( - this.$('#inner-value').text(), - '1', - 'initial render of inner' - ); + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); assert.equal( this.$('#middle-value').text(), '', @@ -2580,11 +2469,7 @@ moduleFor( this.runTask(() => this.rerender()); - assert.equal( - this.$('#inner-value').text(), - '1', - 'initial render of inner' - ); + assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner'); assert.equal( this.$('#middle-value').text(), '', @@ -2602,10 +2487,10 @@ moduleFor( this.registerComponent('x-outer', { ComponentClass: Component.extend({ value: 1, - wrapper: EmberObject.create({ content: null }) + wrapper: EmberObject.create({ content: null }), }), template: - '
{{wrapper.content}}
{{x-inner value=value wrapper=wrapper}}' + '
{{wrapper.content}}
{{x-inner value=value wrapper=wrapper}}', }); this.registerComponent('x-inner', { @@ -2613,9 +2498,9 @@ moduleFor( didReceiveAttrs() { this.get('wrapper').set('content', this.get('value')); }, - value: null + value: null, }), - template: '
{{wrapper.content}}
' + template: '
{{wrapper.content}}
', }); let expectedBacktrackingMessage = /modified "wrapper\.content" twice on <.+?> in a single render\. It was rendered in "component:x-outer" and modified in "component:x-inner"/; @@ -2630,11 +2515,11 @@ moduleFor( template: strip` In layout. {{#each items as |item|}} [{{child-non-block item=item}}] - {{/each}}` + {{/each}}`, }); this.registerComponent('child-non-block', { - template: 'Child: {{item}}.' + template: 'Child: {{item}}.', }); let items = emberA(['Tom', 'Dick', 'Harry']); @@ -2649,19 +2534,13 @@ moduleFor( this.runTask(() => this.context.get('items').pushObject('Sergio')); - this.assertText( - 'In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]' - ); + this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]'); this.runTask(() => this.context.get('items').shiftObject()); - this.assertText( - 'In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]' - ); + this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]'); - this.runTask(() => - this.context.set('items', emberA(['Tom', 'Dick', 'Harry'])) - ); + this.runTask(() => this.context.set('items', emberA(['Tom', 'Dick', 'Harry']))); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); } @@ -2670,8 +2549,8 @@ moduleFor( this.registerComponent('some-clicky-thing', { ComponentClass: Component.extend({ tagName: 'button', - classNames: ['foo', 'bar'] - }) + classNames: ['foo', 'bar'], + }), }); this.render(strip` @@ -2691,22 +2570,20 @@ moduleFor( // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined'); this.assertComponentElement(this.firstChild, { tagName: 'button', - attrs: { class: classes(expectedClassNames.join(' ')) } + attrs: { class: classes(expectedClassNames.join(' ')) }, }); this.runTask(() => this.rerender()); assert.ok( this.$('button').is('.foo.bar.baz.ember-view'), - `the element has the correct classes: ${this.$('button').attr( - 'class' - )} (rerender)` + `the element has the correct classes: ${this.$('button').attr('class')} (rerender)` ); // `ember-view` is no longer in classNames. // assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined (rerender)'); this.assertComponentElement(this.firstChild, { tagName: 'button', - attrs: { class: classes(expectedClassNames.join(' ')) } + attrs: { class: classes(expectedClassNames.join(' ')) }, }); } @@ -2714,13 +2591,13 @@ moduleFor( this.registerComponent('some-clicky-thing', { ComponentClass: Component.extend({ concatenatedProperties: ['blahzz'], - blahzz: ['blark', 'pory'] + blahzz: ['blark', 'pory'], }), template: strip` {{#each blahzz as |p|}} {{p}} {{/each}} - - {{yield}}` + - {{yield}}`, }); this.render(strip` @@ -2741,17 +2618,17 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{bar}}' + template: '{{bar}}', }); this.render('{{localBar}} - {{foo-bar bar=localBar}}', { - localBar: 'initial value' + localBar: 'initial value', }); this.assertText('initial value - initial value'); @@ -2803,18 +2680,18 @@ moduleFor( set(key, value) { this._bar = value; return this._bar; - } - }) + }, + }), }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{bar}}' + template: '{{bar}}', }); this.render('{{localBar}} - {{foo-bar bar=localBar}}', { - localBar: 'initial value' + localBar: 'initial value', }); this.assertText('initial value - initial value'); @@ -2852,17 +2729,17 @@ moduleFor( set(key, value) { this._bar = value; return this._bar; - } - }) + }, + }), }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '' + template: '', }); this.render('{{localBar}}{{foo-bar bar=localBar}}', { - localBar: 'initial value' + localBar: 'initial value', }); this.assertText('initial value'); @@ -2893,15 +2770,15 @@ moduleFor( this._super(...arguments); service = this; }, - last: 'Jackson' + last: 'Jackson', }) ); this.registerComponent('foo-bar', { ComponentClass: Component.extend({ - name: inject.service() + name: inject.service(), }), - template: '{{name.last}}' + template: '{{name.last}}', }); this.render('{{foo-bar}}'); @@ -2928,8 +2805,8 @@ moduleFor( ['@test injecting an unknown service raises an exception']() { this.registerComponent('foo-bar', { ComponentClass: Component.extend({ - missingService: inject.service() - }) + missingService: inject.service(), + }), }); expectAssertion(() => { @@ -2940,8 +2817,8 @@ moduleFor( ['@test throws if `this._super` is not called from `init`']() { this.registerComponent('foo-bar', { ComponentClass: Component.extend({ - init() {} - }) + init() {}, + }), }); expectAssertion(() => { @@ -2958,16 +2835,16 @@ moduleFor( result: matcher.match(actual), message: matcher.message(), actual, - expected + expected, }); }; this.registerComponent('foo-bar', { - template: `

foo

` + template: `

foo

`, }); this.render(`{{foo-bar id="foo-bar" isVisible=visible}}`, { - visible: false + visible: false, }); assertStyle('display: none;'); @@ -2989,19 +2866,19 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: Component.extend({ attributeBindings: ['style'], - style: htmlSafe('color: blue;') + style: htmlSafe('color: blue;'), }), - template: `

foo

` + template: `

foo

`, }); this.render(`{{foo-bar id="foo-bar" isVisible=visible}}`, { - visible: false + visible: false, }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'foo-bar', style: styles('color: blue; display: none;') } + attrs: { id: 'foo-bar', style: styles('color: blue; display: none;') }, }); this.assertStableRerender(); @@ -3012,7 +2889,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'foo-bar', style: styles('color: blue;') } + attrs: { id: 'foo-bar', style: styles('color: blue;') }, }); this.runTask(() => { @@ -3021,7 +2898,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { id: 'foo-bar', style: styles('color: blue; display: none;') } + attrs: { id: 'foo-bar', style: styles('color: blue; display: none;') }, }); } @@ -3036,21 +2913,21 @@ moduleFor( result: matcher.match(actual), message: matcher.message(), actual, - expected + expected, }); }; this.registerComponent('foo-bar', { ComponentClass: Component.extend({ attributeBindings: ['foo'], - foo: 'bar' + foo: 'bar', }), - template: `

foo

` + template: `

foo

`, }); this.render(`{{foo-bar id="foo-bar" foo=foo isVisible=visible}}`, { visible: false, - foo: 'baz' + foo: 'baz', }); assertStyle('display: none;'); @@ -3076,14 +2953,8 @@ moduleFor( let component; let assertElement = expectedValue => { // value is a property, not an attribute - this.assertHTML( - `` - ); - this.assert.equal( - this.firstChild.value, - expectedValue, - 'value property is correct' - ); + this.assertHTML(``); + this.assert.equal(this.firstChild.value, expectedValue, 'value property is correct'); this.assert.equal( get(component, 'value'), expectedValue, @@ -3104,12 +2975,12 @@ moduleFor( change() { let value = this.readDOMAttr('value'); this.set('value', value); - } - }) + }, + }), }); this.render('{{one-way-input value=value}}', { - value: 'foo' + value: 'foo', }); assertElement('foo'); @@ -3169,10 +3040,10 @@ moduleFor( this.get('options').removeObject(option); this.updateValue(); - } + }, }), - template: '{{yield this}}' + template: '{{yield this}}', }); this.registerComponent('x-option', { @@ -3193,8 +3064,8 @@ moduleFor( willDestroyElement() { this._super(...arguments); this.get('select').unregisterOption(this); - } - }) + }, + }), }); this.render(strip` @@ -3209,9 +3080,7 @@ moduleFor( this.assert.ok(true, 'no errors during teardown'); } - ['@test setting a property in willDestroyElement does not assert (GH#14273)']( - assert - ) { + ['@test setting a property in willDestroyElement does not assert (GH#14273)'](assert) { assert.expect(2); this.registerComponent('foo-bar', { @@ -3225,10 +3094,10 @@ moduleFor( this.set('showFoo', false); assert.ok(true, 'willDestroyElement was fired'); this._super(...arguments); - } + }, }), - template: `{{#if showFoo}}things{{/if}}` + template: `{{#if showFoo}}things{{/if}}`, }); this.render(`{{foo-bar}}`); @@ -3243,8 +3112,8 @@ moduleFor( ComponentClass: Component.extend({ foo: on('didInitAttrs', function() { assert.ok(true, 'should fire `didInitAttrs` event'); - }) - }) + }), + }), }); expectDeprecation(() => { @@ -3257,8 +3126,8 @@ moduleFor( ComponentClass: Component.extend({ foo: on('didInitAttrs', function() { assert.ok(true, 'should fire `didInitAttrs` event'); - }) - }) + }), + }), }); expectAssertion(() => { @@ -3266,9 +3135,7 @@ moduleFor( }, /didInitAttrs called/); } - ['@test didReceiveAttrs fires after .init() but before observers become active']( - assert - ) { + ['@test didReceiveAttrs fires after .init() but before observers become active'](assert) { let barCopyDidChangeCount = 0; this.registerComponent('foo-bar', { @@ -3279,55 +3146,40 @@ moduleFor( }, didReceiveAttrs() { - assert.ok( - this.didInit, - 'expected init to have run before didReceiveAttrs' - ); + assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); this.set('barCopy', this.attrs.bar.value + 1); }, barCopyDidChange: observer('barCopy', () => { barCopyDidChangeCount++; - }) + }), }), - template: '{{bar}}-{{barCopy}}' + template: '{{bar}}-{{barCopy}}', }); this.render(`{{foo-bar bar=bar}}`, { bar: 3 }); this.assertText('3-4'); - assert.strictEqual( - barCopyDidChangeCount, - 1, - 'expected observer firing for: barCopy' - ); + assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy'); this.runTask(() => set(this.context, 'bar', 7)); this.assertText('7-8'); - assert.strictEqual( - barCopyDidChangeCount, - 2, - 'expected observer firing for: barCopy' - ); + assert.strictEqual(barCopyDidChangeCount, 2, 'expected observer firing for: barCopy'); } ['@test overriding didReceiveAttrs does not trigger deprecation'](assert) { this.registerComponent('foo-bar', { ComponentClass: Component.extend({ didReceiveAttrs() { - assert.equal( - 1, - this.get('foo'), - 'expected attrs to have correct value' - ); - } + assert.equal(1, this.get('foo'), 'expected attrs to have correct value'); + }, }), - template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}', }); this.render(`{{foo-bar foo=foo bar=bar}}`, { foo: 1, bar: 3 }); @@ -3337,15 +3189,11 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: Component.extend({ didUpdateAttrs() { - assert.equal( - 5, - this.get('foo'), - 'expected newAttrs to have new value' - ); - } + assert.equal(5, this.get('foo'), 'expected newAttrs to have new value'); + }, }), - template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}' + template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}', }); this.render(`{{foo-bar foo=foo bar=bar}}`, { foo: 1, bar: 3 }); @@ -3362,20 +3210,17 @@ moduleFor( show() { assert.ok(true, 'display-toggle show action was called'); return true; - } - } + }, + }, }), - template: `` + template: ``, }); this.render(`{{display-toggle}}`, { send() { - assert.notOk( - true, - 'send should not be called when action is not "subscribed" to' - ); - } + assert.notOk(true, 'send should not be called when action is not "subscribed" to'); + }, }); this.assertText('Show'); @@ -3383,9 +3228,7 @@ moduleFor( this.runTask(() => this.$('button').click()); } - ['@test returning `true` from an action bubbles to the `target` if specified']( - assert - ) { + ['@test returning `true` from an action bubbles to the `target` if specified'](assert) { assert.expect(4); this.registerComponent('display-toggle', { @@ -3394,21 +3237,18 @@ moduleFor( show() { assert.ok(true, 'display-toggle show action was called'); return true; - } - } + }, + }, }), - template: `` + template: ``, }); this.render(`{{display-toggle target=this}}`, { send(actionName) { - assert.ok( - true, - 'send should be called when action is "subscribed" to' - ); + assert.ok(true, 'send should be called when action is "subscribed" to'); assert.equal(actionName, 'show'); - } + }, }); this.assertText('Show'); @@ -3449,16 +3289,14 @@ moduleFor( ); }), - listenerForSomeTruthyProperty: on('someTruthyProperty', function( - ...data - ) { + listenerForSomeTruthyProperty: on('someTruthyProperty', function(...data) { assert.deepEqual( data, payload, 'the listener `listenerForSomeTruthyProperty` should be called, when `someTruthyProperty` is triggered' ); - }) - }) + }), + }), }); this.render(`{{evented-component}}`); @@ -3466,7 +3304,7 @@ moduleFor( ['@test component yielding in an {{#each}} has correct block values after rerendering (GH#14284)']() { this.registerComponent('list-items', { - template: `{{#each items as |item|}}{{yield item}}{{/each}}` + template: `{{#each items as |item|}}{{yield item}}{{/each}}`, }); this.render( @@ -3481,7 +3319,7 @@ moduleFor( `, { editMode: false, - items: ['foo', 'bar', 'qux', 'baz'] + items: ['foo', 'bar', 'qux', 'baz'], } ); @@ -3491,9 +3329,7 @@ moduleFor( this.runTask(() => set(this.context, 'editMode', true)); - this.assertText( - '|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz' - ); + this.assertText('|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz'); this.runTask(() => set(this.context, 'editMode', false)); @@ -3502,7 +3338,7 @@ moduleFor( ['@test unimplimented positionalParams do not cause an error GH#14416']() { this.registerComponent('foo-bar', { - template: 'hello' + template: 'hello', }); this.render('{{foo-bar wat}}'); @@ -3514,10 +3350,9 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: MyComponent.reopenClass({ - positionalParams: ['myVar'] + positionalParams: ['myVar'], }), - template: - 'MyVar1: {{attrs.myVar}} {{myVar}} MyVar2: {{myVar2}} {{attrs.myVar2}}' + template: 'MyVar1: {{attrs.myVar}} {{myVar}} MyVar2: {{myVar2}} {{attrs.myVar2}}', }); this.render('{{foo-bar 1 myVar2=2}}'); @@ -3530,9 +3365,9 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: MyComponent.reopenClass({ - positionalParams: ['myVar'] + positionalParams: ['myVar'], }), - template: 'MyVar1: {{@myVar}} {{myVar}} MyVar2: {{myVar2}} {{@myVar2}}' + template: 'MyVar1: {{@myVar}} {{myVar}} MyVar2: {{myVar2}} {{@myVar2}}', }); this.render('{{foo-bar 1 myVar2=2}}'); @@ -3545,9 +3380,9 @@ moduleFor( ComponentClass: Component.extend({ toString() { return 'special sauce goes here!'; - } + }, }), - template: '{{this}}' + template: '{{this}}', }); this.render('{{foo-bar}}'); @@ -3567,11 +3402,11 @@ moduleFor( foo: { bar: { - baz: 'huzzah!' - } - } + baz: 'huzzah!', + }, + }, }), - template: '{{this.foo.bar.baz}}' + template: '{{this.foo.bar.baz}}', }); this.render('{{foo-bar}}'); @@ -3591,7 +3426,7 @@ moduleFor( ['@test can use custom element in component layout']() { this.registerComponent('foo-bar', { - template: 'Hi!' + template: 'Hi!', }); this.render('{{foo-bar}}'); @@ -3601,7 +3436,7 @@ moduleFor( ['@test can use nested custom element in component layout']() { this.registerComponent('foo-bar', { - template: 'Hi!' + template: 'Hi!', }); this.render('{{foo-bar}}'); @@ -3612,10 +3447,10 @@ moduleFor( ['@feature(!ember-glimmer-named-arguments) can access properties off of rest style positionalParams array']() { this.registerComponent('foo-bar', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'things' + positionalParams: 'things', }), // using `attrs` here to simulate `@things.length` - template: `{{attrs.things.length}}` + template: `{{attrs.things.length}}`, }); this.render('{{foo-bar "foo" "bar" "baz"}}'); @@ -3626,9 +3461,9 @@ moduleFor( ['@feature(ember-glimmer-named-arguments) can access properties off of rest style positionalParams array']() { this.registerComponent('foo-bar', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'things' + positionalParams: 'things', }), - template: `{{@things.length}}` + template: `{{@things.length}}`, }); this.render('{{foo-bar "foo" "bar" "baz"}}'); @@ -3667,12 +3502,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); @@ -3694,12 +3529,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{foo-bar}}'); @@ -3724,12 +3559,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'inner' + template: 'inner', }); this.render('outer{{foo-bar}}'); diff --git a/packages/ember-glimmer/tests/integration/components/destroy-test.js b/packages/ember-glimmer/tests/integration/components/destroy-test.js index a76427caa1a..d36f4d0b2d6 100644 --- a/packages/ember-glimmer/tests/integration/components/destroy-test.js +++ b/packages/ember-glimmer/tests/integration/components/destroy-test.js @@ -10,11 +10,11 @@ moduleFor( this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { - switch: true + switch: true, }); this.assertComponentElement(this.firstChild, { content: 'hello' }); diff --git a/packages/ember-glimmer/tests/integration/components/dynamic-components-test.js b/packages/ember-glimmer/tests/integration/components/dynamic-components-test.js index ebb77c3669a..026ffcbd7bd 100644 --- a/packages/ember-glimmer/tests/integration/components/dynamic-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/dynamic-components-test.js @@ -29,37 +29,37 @@ moduleFor( ['@test it can render a basic component with a dynamic component name argument']() { this.registerComponent('foo-bar', { - template: 'hello {{name}} from foo-bar' + template: 'hello {{name}} from foo-bar', }); this.registerComponent('foo-bar-baz', { - template: 'hello {{name}} from foo-bar-baz' + template: 'hello {{name}} from foo-bar-baz', }); this.render('{{component componentName name=name}}', { componentName: 'foo-bar', - name: 'Alex' + name: 'Alex', }); this.assertComponentElement(this.firstChild, { - content: 'hello Alex from foo-bar' + content: 'hello Alex from foo-bar', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'hello Alex from foo-bar' + content: 'hello Alex from foo-bar', }); this.runTask(() => set(this.context, 'name', 'Ben')); this.assertComponentElement(this.firstChild, { - content: 'hello Ben from foo-bar' + content: 'hello Ben from foo-bar', }); this.runTask(() => set(this.context, 'componentName', 'foo-bar-baz')); this.assertComponentElement(this.firstChild, { - content: 'hello Ben from foo-bar-baz' + content: 'hello Ben from foo-bar-baz', }); this.runTask(() => { @@ -68,7 +68,7 @@ moduleFor( }); this.assertComponentElement(this.firstChild, { - content: 'hello Alex from foo-bar' + content: 'hello Alex from foo-bar', }); } @@ -79,12 +79,12 @@ moduleFor( init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{component "foo-bar"}}'); @@ -109,23 +109,23 @@ moduleFor( init() { this._super(); fooBarInstance = this; - } + }, }); let FooBarBazComponent = Component.extend({ init() { this._super(); fooBarBazInstance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'foo-bar {{foo-bar-baz}}' + template: 'foo-bar {{foo-bar-baz}}', }); this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, - template: 'foo-bar-baz' + template: 'foo-bar-baz', }); this.render('{{component "foo-bar"}}'); @@ -167,12 +167,12 @@ moduleFor( this._super(); instance = this; this.set('message', 'hello'); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{message}}' + template: '{{message}}', }); this.render('{{component "foo-bar"}}'); @@ -196,7 +196,7 @@ moduleFor( this.registerComponent('foo-bar', { template: '{{yield}}' }); this.render('{{#component "foo-bar"}}{{message}}{{/component}}', { - message: 'hello' + message: 'hello', }); this.assertComponentElement(this.firstChild, { content: 'hello' }); @@ -223,8 +223,8 @@ moduleFor( willDestroy() { this._super(); destroyed[this.get('id')]++; - } - }) + }, + }), }); this.render( @@ -255,7 +255,7 @@ moduleFor( cond2: true, cond3: true, cond4: true, - cond5: true + cond5: true, } ); @@ -271,7 +271,7 @@ moduleFor( 5: 0, 6: 0, 7: 0, - 8: 0 + 8: 0, }); this.runTask(() => set(this.context, 'cond5', false)); @@ -286,7 +286,7 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 0 + 8: 0, }); this.runTask(() => { @@ -303,7 +303,7 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 1 + 8: 1, }); this.runTask(() => { @@ -319,13 +319,11 @@ moduleFor( 5: 1, 6: 1, 7: 1, - 8: 1 + 8: 1, }); } - ['@test component helper destroys underlying component when it is swapped out']( - assert - ) { + ['@test component helper destroys underlying component when it is swapped out'](assert) { let destroyed = { 'foo-bar': 0, 'foo-bar-baz': 0 }; let testContext = this; @@ -343,8 +341,8 @@ moduleFor( willDestroy() { this._super(); destroyed['foo-bar']++; - } - }) + }, + }), }); this.registerComponent('foo-bar-baz', { @@ -353,12 +351,12 @@ moduleFor( willDestroy() { this._super(); destroyed['foo-bar-baz']++; - } - }) + }, + }), }); this.render('{{component componentName name=name}}', { - componentName: 'foo-bar' + componentName: 'foo-bar', }); assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); @@ -383,8 +381,8 @@ moduleFor( init: function() { this._super(...arguments); this.set('locationCopy', this.get('location')); - } - }) + }, + }), }); this.registerComponent('foo-bar-baz', { @@ -393,13 +391,12 @@ moduleFor( init: function() { this._super(...arguments); this.set('locationCopy', this.get('location')); - } - }) + }, + }), }); this.registerComponent('outer-component', { - template: - '{{#component componentName location=location}}arepas!{{/component}}', + template: '{{#component componentName location=location}}arepas!{{/component}}', ComponentClass: Component.extend({ componentName: computed('location', function() { if (this.get('location') === 'Caracas') { @@ -407,12 +404,12 @@ moduleFor( } else { return 'foo-bar-baz'; } - }) - }) + }), + }), }); this.render('{{outer-component location=location}}', { - location: 'Caracas' + location: 'Caracas', }); this.assertText('foo-bar Caracas Caracas arepas!'); @@ -437,14 +434,13 @@ moduleFor( classNames: 'inner-component', didInsertElement() { // trigger action on click in absence of app's EventDispatcher - let sendAction = (this.eventHandler = () => - this.sendAction('somethingClicked')); + let sendAction = (this.eventHandler = () => this.sendAction('somethingClicked')); this.element.addEventListener('click', sendAction); }, willDestroyElement() { this.element.removeEventListener('click', this.eventHandler); - } - }) + }, + }), }); let actionTriggered = 0; @@ -457,9 +453,9 @@ moduleFor( actions: { mappedAction() { actionTriggered++; - } - } - }) + }, + }, + }), }); this.render('{{outer-component}}'); @@ -475,13 +471,13 @@ moduleFor( ['@test nested component helpers']() { this.registerComponent('foo-bar', { - template: 'yippie! {{attrs.location}} {{yield}}' + template: 'yippie! {{attrs.location}} {{yield}}', }); this.registerComponent('baz-qux', { - template: 'yummy {{attrs.location}} {{yield}}' + template: 'yummy {{attrs.location}} {{yield}}', }); this.registerComponent('corge-grault', { - template: 'delicious {{attrs.location}} {{yield}}' + template: 'delicious {{attrs.location}} {{yield}}', }); this.render( @@ -489,7 +485,7 @@ moduleFor( { componentName1: 'foo-bar', componentName2: 'baz-qux', - location: 'Caracas' + location: 'Caracas', } ); @@ -518,7 +514,7 @@ moduleFor( ['@test component with dynamic name argument resolving to non-existent component']() { expectAssertion(() => { this.render('{{component componentName}}', { - componentName: 'does-not-exist' + componentName: 'does-not-exist', }); }, /Could not find component named "does-not-exist"/); } @@ -534,7 +530,7 @@ moduleFor( this.render('{{component componentName name=name}}', { componentName: 'foo-bar', - name: 'Alex' + name: 'Alex', }); this.assertText('hello Alex'); @@ -560,16 +556,13 @@ moduleFor( // store internally available name to ensure that the name available in `this.attrs.name` // matches the template lookup name set(this, 'internalName', this.get('name')); - } - }) + }, + }), }); - this.render( - '{{#each items as |item|}}{{component "foo-bar" name=item.name}}{{/each}}', - { - items: [{ name: 'Robert' }, { name: 'Jacquie' }] - } - ); + this.render('{{#each items as |item|}}{{component "foo-bar" name=item.name}}{{/each}}', { + items: [{ name: 'Robert' }, { name: 'Jacquie' }], + }); this.assertText('[Robert - Robert][Jacquie - Jacquie]'); @@ -577,15 +570,11 @@ moduleFor( this.assertText('[Robert - Robert][Jacquie - Jacquie]'); - this.runTask(() => - set(this.context, 'items', [{ name: 'Max' }, { name: 'James' }]) - ); + this.runTask(() => set(this.context, 'items', [{ name: 'Max' }, { name: 'James' }])); this.assertText('[Max - Max][James - James]'); - this.runTask(() => - set(this.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }]) - ); + this.runTask(() => set(this.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }])); this.assertText('[Robert - Robert][Jacquie - Jacquie]'); } @@ -602,49 +591,49 @@ moduleFor( this.registerComponent('foo-bar', { template: 'hello {{name}} ({{age}}) from foo-bar', ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] - }) + positionalParams: ['name', 'age'], + }), }); this.registerComponent('foo-bar-baz', { template: 'hello {{name}} ({{age}}) from foo-bar-baz', ComponentClass: Component.extend().reopenClass({ - positionalParams: ['name', 'age'] - }) + positionalParams: ['name', 'age'], + }), }); this.render('{{component componentName name age}}', { componentName: 'foo-bar', name: 'Alex', - age: 29 + age: 29, }); this.assertComponentElement(this.firstChild, { - content: 'hello Alex (29) from foo-bar' + content: 'hello Alex (29) from foo-bar', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'hello Alex (29) from foo-bar' + content: 'hello Alex (29) from foo-bar', }); this.runTask(() => set(this.context, 'name', 'Ben')); this.assertComponentElement(this.firstChild, { - content: 'hello Ben (29) from foo-bar' + content: 'hello Ben (29) from foo-bar', }); this.runTask(() => set(this.context, 'age', 22)); this.assertComponentElement(this.firstChild, { - content: 'hello Ben (22) from foo-bar' + content: 'hello Ben (22) from foo-bar', }); this.runTask(() => set(this.context, 'componentName', 'foo-bar-baz')); this.assertComponentElement(this.firstChild, { - content: 'hello Ben (22) from foo-bar-baz' + content: 'hello Ben (22) from foo-bar-baz', }); this.runTask(() => { @@ -654,7 +643,7 @@ moduleFor( }); this.assertComponentElement(this.firstChild, { - content: 'hello Alex (29) from foo-bar' + content: 'hello Alex (29) from foo-bar', }); } @@ -662,46 +651,44 @@ moduleFor( this.registerComponent('normal-message', { template: 'Normal: {{something}}!', ComponentClass: Component.extend().reopenClass({ - positionalParams: ['something'] - }) + positionalParams: ['something'], + }), }); this.registerComponent('alternative-message', { template: 'Alternative: {{something}} {{somethingElse}}!', ComponentClass: Component.extend({ - something: 'Another' + something: 'Another', }).reopenClass({ - positionalParams: ['somethingElse'] - }) + positionalParams: ['somethingElse'], + }), }); this.render('{{component componentName message}}', { componentName: 'normal-message', - message: 'Hello' + message: 'Hello', }); this.assertComponentElement(this.firstChild, { - content: 'Normal: Hello!' + content: 'Normal: Hello!', }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { - content: 'Normal: Hello!' + content: 'Normal: Hello!', }); - this.runTask(() => - set(this.context, 'componentName', 'alternative-message') - ); + this.runTask(() => set(this.context, 'componentName', 'alternative-message')); this.assertComponentElement(this.firstChild, { - content: 'Alternative: Another Hello!' + content: 'Alternative: Another Hello!', }); this.runTask(() => set(this.context, 'message', 'Hi')); this.assertComponentElement(this.firstChild, { - content: 'Alternative: Another Hi!' + content: 'Alternative: Another Hi!', }); this.runTask(() => { @@ -710,24 +697,22 @@ moduleFor( }); this.assertComponentElement(this.firstChild, { - content: 'Normal: Hello!' + content: 'Normal: Hello!', }); } ['@test static arbitrary number of positional parameters']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'names' + positionalParams: 'names', }), template: strip` {{#each names as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); - this.render( - `{{component "sample-component" "Foo" 4 "Bar" 5 "Baz" elementId="helper"}}` - ); + this.render(`{{component "sample-component" "Foo" 4 "Bar" 5 "Baz" elementId="helper"}}`); this.assertText('Foo4Bar5Baz'); @@ -739,17 +724,17 @@ moduleFor( ['@test dynamic arbitrary number of positional parameters']() { this.registerComponent('sample-component', { ComponentClass: Component.extend().reopenClass({ - positionalParams: 'n' + positionalParams: 'n', }), template: strip` {{#each n as |name|}} {{name}} - {{/each}}` + {{/each}}`, }); this.render(`{{component "sample-component" user1 user2}}`, { user1: 'Foo', - user2: 4 + user2: 4, }); this.assertText('Foo4'); @@ -780,9 +765,9 @@ moduleFor( init() { this._super(...arguments); this.set('person', { name: 'Alex' }); - } + }, }), - template: `Hi {{person.name}}! {{component "error-component" person=person}}` + template: `Hi {{person.name}}! {{component "error-component" person=person}}`, }); this.registerComponent('error-component', { @@ -790,16 +775,16 @@ moduleFor( init() { this._super(...arguments); this.set('person.name', { name: 'Ben' }); - } + }, }), - template: '{{person.name}}' + template: '{{person.name}}', }); let expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "component:outer-component" and modified in "component:error-component"/; expectAssertion(() => { this.render('{{component componentName}}', { - componentName: 'outer-component' + componentName: 'outer-component', }); }, expectedBacktrackingMessage); } @@ -817,12 +802,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{component "foo-bar"}}'); @@ -844,12 +829,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{component "foo-bar"}}'); @@ -874,12 +859,12 @@ if (jQueryDisabled) { init() { this._super(); instance = this; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'inner' + template: 'inner', }); this.render('outer{{component "foo-bar"}}'); diff --git a/packages/ember-glimmer/tests/integration/components/error-handling-test.js b/packages/ember-glimmer/tests/integration/components/error-handling-test.js index 57e5528ba5d..1f661dcccb2 100644 --- a/packages/ember-glimmer/tests/integration/components/error-handling-test.js +++ b/packages/ember-glimmer/tests/integration/components/error-handling-test.js @@ -15,19 +15,16 @@ moduleFor( if (shouldThrow) { throw new Error('silly mistake in init!'); } - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); assert.throws(() => { - this.render( - '{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', - { switch: true } - ); + this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); }, /silly mistake in init/); assert.equal( @@ -57,16 +54,16 @@ moduleFor( if (shouldThrow) { throw new Error('silly mistake in init!'); } - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { - switch: true + switch: true, }); this.assertText('hello'); @@ -105,19 +102,16 @@ moduleFor( if (shouldThrow) { throw new Error('silly mistake!'); } - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); assert.throws(() => { - this.render( - '{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', - { switch: true } - ); + this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); }, /silly mistake/); assert.equal( @@ -133,9 +127,7 @@ moduleFor( this.assertText(''); } - ['@test it can recover resets the transaction when an error is thrown during destroy']( - assert - ) { + ['@test it can recover resets the transaction when an error is thrown during destroy'](assert) { let shouldThrow = true; let FooBarComponent = Component.extend({ destroy() { @@ -143,16 +135,16 @@ moduleFor( if (shouldThrow) { throw new Error('silly mistake!'); } - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { - switch: true + switch: true, }); this.assertText('hello'); diff --git a/packages/ember-glimmer/tests/integration/components/fragment-components-test.js b/packages/ember-glimmer/tests/integration/components/fragment-components-test.js index 789637981ff..9dd62c9ca74 100644 --- a/packages/ember-glimmer/tests/integration/components/fragment-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/fragment-components-test.js @@ -8,7 +8,7 @@ moduleFor( class extends RenderingTest { getCustomDispatcherEvents() { return { - hitDem: 'folks' + hitDem: 'folks', }; } @@ -21,14 +21,14 @@ moduleFor( instance = this; this.foo = true; this.bar = 'bar'; - } + }, }); let template = `{{#if foo}}
Hey
{{/if}}{{yield bar}}`; this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); this.render(`{{#foo-bar as |bar|}}{{bar}}{{/foo-bar}}`); @@ -55,12 +55,12 @@ moduleFor( let template = `hit dem folks`; let FooBarComponent = Component.extend({ tagName: '', - click() {} + click() {}, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { @@ -72,12 +72,12 @@ moduleFor( let template = `hit dem folks`; let FooBarComponent = Component.extend({ tagName: '', - folks() {} + folks() {}, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { @@ -90,12 +90,12 @@ moduleFor( let FooBarComponent = Component.extend({ tagName: '', foo: true, - classNameBindings: ['foo:is-foo:is-bar'] + classNameBindings: ['foo:is-foo:is-bar'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { @@ -107,12 +107,12 @@ moduleFor( let template = `hit dem folks`; let FooBarComponent = Component.extend({ tagName: '', - attributeBindings: ['href'] + attributeBindings: ['href'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { this.render(`{{#foo-bar}}{{/foo-bar}}`); @@ -123,12 +123,12 @@ moduleFor( let template = `hit dem folks`; let FooBarComponent = Component.extend({ tagName: '', - elementId: 'turntUp' + elementId: 'turntUp', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { this.render(`{{#foo-bar}}{{/foo-bar}}`); @@ -138,12 +138,12 @@ moduleFor( ['@test throws an error if `tagName` is an empty string and `elementId` is specified via template']() { let template = `hit dem folks`; let FooBarComponent = Component.extend({ - tagName: '' + tagName: '', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { this.render(`{{#foo-bar elementId='turntUp'}}{{/foo-bar}}`); @@ -154,12 +154,12 @@ moduleFor( let template = `{{id}}`; let FooBarComponent = Component.extend({ tagName: '', - id: 'baz' + id: 'baz', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); this.render(`{{#foo-bar}}{{/foo-bar}}`); this.assertText('baz'); @@ -168,12 +168,12 @@ moduleFor( ['@test does not throw an error if `tagName` is an empty string and `id` is specified via template']() { let template = `{{id}}`; let FooBarComponent = Component.extend({ - tagName: '' + tagName: '', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); this.render(`{{#foo-bar id='baz'}}{{/foo-bar}}`); this.assertText('baz'); @@ -182,12 +182,12 @@ moduleFor( ['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template']() { let template = `{{id}}`; let FooBarComponent = Component.extend({ - tagName: '' + tagName: '', }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); this.render(`{{#foo-bar id=fooBarId}}{{/foo-bar}}`, { fooBarId: 'baz' }); @@ -208,18 +208,18 @@ moduleFor( ['@test does not throw an error if `tagName` is an empty string and `id` is specified via template and passed to child component']() { let fooBarTemplate = `{{#baz-child id=id}}{{/baz-child}}`; let FooBarComponent = Component.extend({ - tagName: '' + tagName: '', }); let BazChildComponent = Component.extend(); let bazChildTemplate = `{{id}}`; this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: fooBarTemplate + template: fooBarTemplate, }); this.registerComponent('baz-child', { ComponentClass: BazChildComponent, - template: bazChildTemplate + template: bazChildTemplate, }); this.render(`{{#foo-bar id='baz'}}{{/foo-bar}}`); this.assertText('baz'); @@ -232,12 +232,12 @@ moduleFor( init() { this._super(); this.$(); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template + template, }); expectAssertion(() => { @@ -248,37 +248,37 @@ moduleFor( ['@test renders a contained view with omitted start tag and tagless parent view context']() { this.registerComponent('root-component', { ComponentClass: Component.extend({ - tagName: 'section' + tagName: 'section', }), - template: '{{frag-ment}}' + template: '{{frag-ment}}', }); this.registerComponent('frag-ment', { ComponentClass: Component.extend({ - tagName: '' + tagName: '', }), - template: '{{my-span}}' + template: '{{my-span}}', }); this.registerComponent('my-span', { ComponentClass: Component.extend({ - tagName: 'span' + tagName: 'span', }), - template: 'dab' + template: 'dab', }); this.render(`{{root-component}}`); this.assertElement(this.firstChild, { tagName: 'section' }); this.assertElement(this.firstChild.firstElementChild, { - tagName: 'span' + tagName: 'span', }); this.runTask(() => this.rerender()); this.assertElement(this.firstChild, { tagName: 'section' }); this.assertElement(this.firstChild.firstElementChild, { - tagName: 'span' + tagName: 'span', }); } } diff --git a/packages/ember-glimmer/tests/integration/components/instrumentation-compile-test.js b/packages/ember-glimmer/tests/integration/components/instrumentation-compile-test.js index 00ffe23e763..75e206af9a7 100644 --- a/packages/ember-glimmer/tests/integration/components/instrumentation-compile-test.js +++ b/packages/ember-glimmer/tests/integration/components/instrumentation-compile-test.js @@ -20,33 +20,25 @@ moduleFor( if (payload.view !== this.component) { this.actual.after.push(payload); } - } + }, }); } resetEvents() { this.expected = { before: [], - after: [] + after: [], }; this.actual = { before: [], - after: [] + after: [], }; } teardown() { - this.assert.deepEqual( - this.actual.before, - [], - 'No unexpected events (before)' - ); - this.assert.deepEqual( - this.actual.after, - [], - 'No unexpected events (after)' - ); + this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); + this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); super.teardown(); instrumentationReset(); } @@ -60,17 +52,17 @@ moduleFor( willRender() { testCase.expected.before.push(this); testCase.expected.after.unshift(this); - } + }, }); this.registerComponent('x-bar', { template: '[x-bar: {{bar}}]', - ComponentClass: BaseClass.extend() + ComponentClass: BaseClass.extend(), }); this.render(`[-top-level: {{foo}}] {{x-bar bar=bar}}`, { foo: 'foo', - bar: 'bar' + bar: 'bar', }); this.assertText('[-top-level: foo] [x-bar: bar]'); @@ -107,11 +99,7 @@ moduleFor( } assertPayload(payload, component) { - this.assert.equal( - payload.object, - component._debugContainerKey, - 'payload.object' - ); + this.assert.equal(payload.object, component._debugContainerKey, 'payload.object'); } } ); diff --git a/packages/ember-glimmer/tests/integration/components/instrumentation-test.js b/packages/ember-glimmer/tests/integration/components/instrumentation-test.js index 7cdd336b15b..f49906cb528 100644 --- a/packages/ember-glimmer/tests/integration/components/instrumentation-test.js +++ b/packages/ember-glimmer/tests/integration/components/instrumentation-test.js @@ -1,10 +1,6 @@ import { moduleFor, RenderingTest } from '../../utils/test-case'; import { Component } from '../../utils/helpers'; -import { - instrumentationSubscribe, - instrumentationReset, - set -} from 'ember-metal'; +import { instrumentationSubscribe, instrumentationReset, set } from 'ember-metal'; moduleFor( 'Components instrumentation', @@ -24,33 +20,25 @@ moduleFor( if (payload.view !== this.component) { this.actual.after.push(payload); } - } + }, }); } resetEvents() { this.expected = { before: [], - after: [] + after: [], }; this.actual = { before: [], - after: [] + after: [], }; } teardown() { - this.assert.deepEqual( - this.actual.before, - [], - 'No unexpected events (before)' - ); - this.assert.deepEqual( - this.actual.after, - [], - 'No unexpected events (after)' - ); + this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); + this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); super.teardown(); instrumentationReset(); } @@ -68,22 +56,22 @@ moduleFor( willRender() { testCase.expected.before.push(this); testCase.expected.after.unshift(this); - } + }, }); this.registerComponent('x-bar', { template: '[x-bar: {{bar}}] {{yield}}', - ComponentClass: BaseClass.extend() + ComponentClass: BaseClass.extend(), }); this.registerComponent('x-baz', { template: '[x-baz: {{baz}}]', - ComponentClass: BaseClass.extend() + ComponentClass: BaseClass.extend(), }); this.registerComponent('x-bat', { template: '[x-bat: {{bat}}]', - ComponentClass: BaseClass.extend() + ComponentClass: BaseClass.extend(), }); this.render( @@ -92,13 +80,11 @@ moduleFor( foo: 'foo', bar: 'bar', baz: 'baz', - bat: 'bat' + bat: 'bat', } ); - this.assertText( - '[-top-level: foo] [x-bar: bar] [x-baz: baz] [x-bat: bat]' - ); + this.assertText('[-top-level: foo] [x-bar: bar] [x-baz: baz] [x-bat: bat]'); this.assertEvents('after initial render', true); @@ -140,18 +126,8 @@ moduleFor( `${label}: before and after callbacks should be balanced` ); - this._assertEvents( - `${label} (before):`, - actual.before, - expected.before, - initialRender - ); - this._assertEvents( - `${label} (after):`, - actual.before, - expected.before, - initialRender - ); + this._assertEvents(`${label} (before):`, actual.before, expected.before, initialRender); + this._assertEvents(`${label} (after):`, actual.before, expected.before, initialRender); this.resetEvents(); } @@ -163,28 +139,15 @@ moduleFor( `${label}: expected ${expected.length} and got ${actual.length}` ); - actual.forEach((payload, i) => - this.assertPayload(payload, expected[i], initialRender) - ); + actual.forEach((payload, i) => this.assertPayload(payload, expected[i], initialRender)); } assertPayload(payload, component, initialRender) { this.assert.equal(payload.object, component.toString(), 'payload.object'); - this.assert.ok( - payload.containerKey, - 'the container key should be present' - ); - this.assert.equal( - payload.containerKey, - component._debugContainerKey, - 'payload.containerKey' - ); + this.assert.ok(payload.containerKey, 'the container key should be present'); + this.assert.equal(payload.containerKey, component._debugContainerKey, 'payload.containerKey'); this.assert.equal(payload.view, component, 'payload.view'); - this.assert.strictEqual( - payload.initialRender, - initialRender, - 'payload.initialRender' - ); + this.assert.strictEqual(payload.initialRender, initialRender, 'payload.initialRender'); } } ); diff --git a/packages/ember-glimmer/tests/integration/components/life-cycle-test.js b/packages/ember-glimmer/tests/integration/components/life-cycle-test.js index 1152978c2ab..7c3a4c6ee28 100644 --- a/packages/ember-glimmer/tests/integration/components/life-cycle-test.js +++ b/packages/ember-glimmer/tests/integration/components/life-cycle-test.js @@ -31,7 +31,7 @@ class LifeCycleHooksTest extends RenderingTest { getBootOptions() { return { - isInteractive: this.isInteractive + isInteractive: this.isInteractive, }; } @@ -53,7 +53,7 @@ class LifeCycleHooksTest extends RenderingTest { get boundHelpers() { return { invoke: bind(this.invocationFor, this), - attr: bind(this.attrFor, this) + attr: bind(this.attrFor, this), }; } @@ -69,11 +69,7 @@ class LifeCycleHooksTest extends RenderingTest { this.assert.deepEqual(actual, expected, 'registered views - ' + label); } else { - this.assert.deepEqual( - actual, - [], - 'no views should be registered for non-interactive mode' - ); + this.assert.deepEqual(actual, [], 'no views should be registered for non-interactive mode'); } } @@ -95,10 +91,7 @@ class LifeCycleHooksTest extends RenderingTest { }; let assertParentView = (hookName, instance) => { - this.assert.ok( - instance.parentView, - `parentView should be present in ${hookName}` - ); + this.assert.ok(instance.parentView, `parentView should be present in ${hookName}`); if (hookName === 'willDestroyElement') { this.assert.ok( @@ -290,7 +283,7 @@ class LifeCycleHooksTest extends RenderingTest { removeComponent(this); this._super(...arguments); - } + }, }); super.registerComponent(name, { ComponentClass, template }); @@ -311,7 +304,7 @@ class LifeCycleHooksTest extends RenderingTest {
Twitter: {{${attr('twitter')}}}| ${invoke('the-middle', { name: string('Tom Dale') })} -
` + `, }); this.registerComponent('the-middle', { @@ -319,18 +312,18 @@ class LifeCycleHooksTest extends RenderingTest {
Name: {{${attr('name')}}}| ${invoke('the-bottom', { website: string('tomdale.net') })} -
` + `, }); this.registerComponent('the-bottom', { template: strip`
Website: {{${attr('website')}}} -
` + `, }); this.render(invoke('the-top', { twitter: expr('twitter') }), { - twitter: '@tomdale' + twitter: '@tomdale', }); this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net'); @@ -369,7 +362,7 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], nonInteractive: [ @@ -384,8 +377,8 @@ class LifeCycleHooksTest extends RenderingTest { ['the-bottom', 'init'], ['the-bottom', 'on(init)'], - ['the-bottom', 'didReceiveAttrs'] - ] + ['the-bottom', 'didReceiveAttrs'], + ], }); this.runTask(() => this.components['the-bottom'].rerender()); @@ -415,10 +408,10 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didRender'], ['the-top', 'didUpdate'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => this.components['the-middle'].rerender()); @@ -443,10 +436,10 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didRender'], ['the-top', 'didUpdate'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => this.components['the-top'].rerender()); @@ -465,17 +458,15 @@ class LifeCycleHooksTest extends RenderingTest { // Async hooks ['the-top', 'didUpdate'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => set(this.context, 'twitter', '@horsetomdale')); - this.assertText( - 'Twitter: @horsetomdale|Name: Tom Dale|Website: tomdale.net' - ); + this.assertText('Twitter: @horsetomdale|Name: Tom Dale|Website: tomdale.net'); // Because the `twitter` attr is only used by the topmost component, // and not passed down, we do not expect to see lifecycle hooks @@ -498,14 +489,14 @@ class LifeCycleHooksTest extends RenderingTest { // Async hooks ['the-top', 'didUpdate'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], nonInteractive: [ // Sync hooks ['the-top', 'didUpdateAttrs'], - ['the-top', 'didReceiveAttrs'] - ] + ['the-top', 'didReceiveAttrs'], + ], }); this.teardownAssertions.push(() => { @@ -524,14 +515,14 @@ class LifeCycleHooksTest extends RenderingTest { ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], - ['the-bottom', 'willDestroy'] + ['the-bottom', 'willDestroy'], ], nonInteractive: [ ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], - ['the-bottom', 'willDestroy'] - ] + ['the-bottom', 'willDestroy'], + ], }); this.assertRegisteredViews('after destroy'); @@ -547,31 +538,31 @@ class LifeCycleHooksTest extends RenderingTest { ${invoke('the-first-child', { twitter: expr(attr('twitter')) })}| ${invoke('the-second-child', { name: expr(attr('name')) })}| ${invoke('the-last-child', { website: expr(attr('website')) })} - ` + `, }); this.registerComponent('the-first-child', { - template: `Twitter: {{${attr('twitter')}}}` + template: `Twitter: {{${attr('twitter')}}}`, }); this.registerComponent('the-second-child', { - template: `Name: {{${attr('name')}}}` + template: `Name: {{${attr('name')}}}`, }); this.registerComponent('the-last-child', { - template: `Website: {{${attr('website')}}}` + template: `Website: {{${attr('website')}}}`, }); this.render( invoke('the-parent', { twitter: expr('twitter'), name: expr('name'), - website: expr('website') + website: expr('website'), }), { twitter: '@tomdale', name: 'Tom Dale', - website: 'tomdale.net' + website: 'tomdale.net', } ); @@ -620,7 +611,7 @@ class LifeCycleHooksTest extends RenderingTest { ['the-last-child', 'didRender'], ['the-parent', 'didInsertElement'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], nonInteractive: [ @@ -640,8 +631,8 @@ class LifeCycleHooksTest extends RenderingTest { ['the-last-child', 'init'], ['the-last-child', 'on(init)'], - ['the-last-child', 'didReceiveAttrs'] - ] + ['the-last-child', 'didReceiveAttrs'], + ], }); this.runTask(() => this.components['the-first-child'].rerender()); @@ -666,10 +657,10 @@ class LifeCycleHooksTest extends RenderingTest { ['the-first-child', 'didRender'], ['the-parent', 'didUpdate'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => this.components['the-second-child'].rerender()); @@ -694,10 +685,10 @@ class LifeCycleHooksTest extends RenderingTest { ['the-second-child', 'didRender'], ['the-parent', 'didUpdate'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => this.components['the-last-child'].rerender()); @@ -722,10 +713,10 @@ class LifeCycleHooksTest extends RenderingTest { ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => this.components['the-parent'].rerender()); @@ -744,23 +735,21 @@ class LifeCycleHooksTest extends RenderingTest { // Async hooks ['the-parent', 'didUpdate'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], - nonInteractive: [] + nonInteractive: [], }); this.runTask(() => setProperties(this.context, { twitter: '@horsetomdale', name: 'Horse Tom Dale', - website: 'horsetomdale.net' + website: 'horsetomdale.net', }) ); - this.assertText( - 'Twitter: @horsetomdale|Name: Horse Tom Dale|Website: horsetomdale.net' - ); + this.assertText('Twitter: @horsetomdale|Name: Horse Tom Dale|Website: horsetomdale.net'); this.assertHooks({ label: 'after update', @@ -804,7 +793,7 @@ class LifeCycleHooksTest extends RenderingTest { ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], - ['the-parent', 'didRender'] + ['the-parent', 'didRender'], ], nonInteractive: [ @@ -820,8 +809,8 @@ class LifeCycleHooksTest extends RenderingTest { ['the-second-child', 'didReceiveAttrs'], ['the-last-child', 'didUpdateAttrs'], - ['the-last-child', 'didReceiveAttrs'] - ] + ['the-last-child', 'didReceiveAttrs'], + ], }); this.teardownAssertions.push(() => { @@ -846,15 +835,15 @@ class LifeCycleHooksTest extends RenderingTest { ['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], - ['the-last-child', 'willDestroy'] + ['the-last-child', 'willDestroy'], ], nonInteractive: [ ['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], - ['the-last-child', 'willDestroy'] - ] + ['the-last-child', 'willDestroy'], + ], }); this.assertRegisteredViews('after destroy'); @@ -868,27 +857,27 @@ class LifeCycleHooksTest extends RenderingTest { template: strip`
Top: ${invoke('the-middle', { twitterTop: expr(attr('twitter')) })} -
` + `, }); this.registerComponent('the-middle', { template: strip`
Middle: ${invoke('the-bottom', { - twitterMiddle: expr(attr('twitterTop')) + twitterMiddle: expr(attr('twitterTop')), })} -
` + `, }); this.registerComponent('the-bottom', { template: strip`
Bottom: {{${attr('twitterMiddle')}}} -
` + `, }); this.render(invoke('the-top', { twitter: expr('twitter') }), { - twitter: '@tomdale' + twitter: '@tomdale', }); this.assertText('Top: Middle: Bottom: @tomdale'); @@ -927,7 +916,7 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], nonInteractive: [ @@ -943,8 +932,8 @@ class LifeCycleHooksTest extends RenderingTest { ['the-bottom', 'init'], ['the-bottom', 'on(init)'], - ['the-bottom', 'didReceiveAttrs'] - ] + ['the-bottom', 'didReceiveAttrs'], + ], }); this.runTask(() => set(this.context, 'twitter', '@horsetomdale')); @@ -987,7 +976,7 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didRender'], ['the-top', 'didUpdate'], - ['the-top', 'didRender'] + ['the-top', 'didRender'], ], nonInteractive: [ @@ -1000,8 +989,8 @@ class LifeCycleHooksTest extends RenderingTest { ['the-middle', 'didReceiveAttrs'], ['the-bottom', 'didUpdateAttrs'], - ['the-bottom', 'didReceiveAttrs'] - ] + ['the-bottom', 'didReceiveAttrs'], + ], }); this.runTask(() => this.rerender()); @@ -1013,7 +1002,7 @@ class LifeCycleHooksTest extends RenderingTest { this.assertHooks({ label: 'after no-op rernder (root)', interactive: [], - nonInteractive: [] + nonInteractive: [], }); this.teardownAssertions.push(() => { @@ -1032,14 +1021,14 @@ class LifeCycleHooksTest extends RenderingTest { ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], - ['the-bottom', 'willDestroy'] + ['the-bottom', 'willDestroy'], ], nonInteractive: [ ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], - ['the-bottom', 'willDestroy'] - ] + ['the-bottom', 'willDestroy'], + ], }); this.assertRegisteredViews('after destroy'); @@ -1054,13 +1043,13 @@ class LifeCycleHooksTest extends RenderingTest { this.registerComponent('an-item', { template: strip` {{#nested-item}}Item: {{count}}{{/nested-item}} - ` + `, }); this.registerComponent('no-items', { template: strip` {{#nested-item}}Nothing to see here{{/nested-item}} - ` + `, }); this.render( @@ -1072,7 +1061,7 @@ class LifeCycleHooksTest extends RenderingTest { {{/each}} `, { - items: [1, 2, 3, 4, 5] + items: [1, 2, 3, 4, 5], } ); @@ -1080,11 +1069,7 @@ class LifeCycleHooksTest extends RenderingTest { this.assertRegisteredViews('intial render'); let initialHooks = () => { - let ret = [ - ['an-item', 'init'], - ['an-item', 'on(init)'], - ['an-item', 'didReceiveAttrs'] - ]; + let ret = [['an-item', 'init'], ['an-item', 'on(init)'], ['an-item', 'didReceiveAttrs']]; if (this.isInteractive) { ret.push(['an-item', 'willRender'], ['an-item', 'willInsertElement']); } @@ -1094,10 +1079,7 @@ class LifeCycleHooksTest extends RenderingTest { ['nested-item', 'didReceiveAttrs'] ); if (this.isInteractive) { - ret.push( - ['nested-item', 'willRender'], - ['nested-item', 'willInsertElement'] - ); + ret.push(['nested-item', 'willRender'], ['nested-item', 'willInsertElement']); } return ret; }; @@ -1108,7 +1090,7 @@ class LifeCycleHooksTest extends RenderingTest { ['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['an-item', 'didInsertElement'], - ['an-item', 'didRender'] + ['an-item', 'didRender'], ]; } else { return []; @@ -1131,7 +1113,7 @@ class LifeCycleHooksTest extends RenderingTest { ...initialAfterRenderHooks(4), ...initialAfterRenderHooks(3), ...initialAfterRenderHooks(2), - ...initialAfterRenderHooks(1) + ...initialAfterRenderHooks(1), ], nonInteractive: [ @@ -1147,28 +1129,20 @@ class LifeCycleHooksTest extends RenderingTest { ...initialAfterRenderHooks(4), ...initialAfterRenderHooks(3), ...initialAfterRenderHooks(2), - ...initialAfterRenderHooks(1) - ] + ...initialAfterRenderHooks(1), + ], }); // TODO: Is this correct? Should childViews be populated in non-interactive mode? if (this.isInteractive) { - this.assert.equal( - this.component.childViews.length, - 5, - 'childViews precond' - ); + this.assert.equal(this.component.childViews.length, 5, 'childViews precond'); } this.runTask(() => set(this.context, 'items', [])); // TODO: Is this correct? Should childViews be populated in non-interactive mode? if (this.isInteractive) { - this.assert.equal( - this.component.childViews.length, - 1, - 'childViews updated' - ); + this.assert.equal(this.component.childViews.length, 1, 'childViews updated'); } this.assertText('Nothing to see here'); @@ -1235,7 +1209,7 @@ class LifeCycleHooksTest extends RenderingTest { ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], - ['nested-item', 'willDestroy'] + ['nested-item', 'willDestroy'], ], nonInteractive: [ @@ -1256,8 +1230,8 @@ class LifeCycleHooksTest extends RenderingTest { ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], - ['nested-item', 'willDestroy'] - ] + ['nested-item', 'willDestroy'], + ], }); this.teardownAssertions.push(() => { @@ -1274,13 +1248,10 @@ class LifeCycleHooksTest extends RenderingTest { ['nested-item', 'didDestroyElement'], ['no-items', 'willDestroy'], - ['nested-item', 'willDestroy'] + ['nested-item', 'willDestroy'], ], - nonInteractive: [ - ['no-items', 'willDestroy'], - ['nested-item', 'willDestroy'] - ] + nonInteractive: [['no-items', 'willDestroy'], ['nested-item', 'willDestroy']], }); this.assertRegisteredViews('after destroy'); @@ -1370,7 +1341,7 @@ moduleFor( schedule('afterRender', () => { this.set('width', '10'); }); - } + }, }); let template = `{{width}}`; @@ -1392,7 +1363,7 @@ moduleFor( let parent = this.get('parent'); parent.set('foo', 'wat'); }); - } + }, }); let template = `{{foo}}`; @@ -1415,7 +1386,7 @@ moduleFor( attributeBindings: ['customHref:href'], willRender() { this.set('customHref', 'http://willRender.com'); - } + }, }); let template = `Hello World`; @@ -1429,8 +1400,8 @@ moduleFor( attrs: { id: 'foo', href: 'http://willRender.com', - class: classes('ember-view') - } + class: classes('ember-view'), + }, }); } @@ -1445,9 +1416,9 @@ moduleFor( name: 'parent-component', hasParent: !!this.element.parentNode, nextSibling: !!this.element.nextSibling, - previousSibling: !!this.element.previousSibling + previousSibling: !!this.element.previousSibling, }); - } + }, }); let PartentTemplate = strip` @@ -1465,30 +1436,24 @@ moduleFor( name: 'nested-component', hasParent: !!this.element.parentNode, nextSibling: !!this.element.nextSibling, - previousSibling: !!this.element.previousSibling + previousSibling: !!this.element.previousSibling, }); - } + }, }); let NestedTemplate = `{{yield}}`; this.registerComponent('parent-component', { ComponentClass: ParentComponent, - template: PartentTemplate + template: PartentTemplate, }); this.registerComponent('nested-component', { ComponentClass: NestedComponent, - template: NestedTemplate + template: NestedTemplate, }); - let array = emberA([ - { id: 1 }, - { id: 2 }, - { id: 3 }, - { id: 4 }, - { id: 5 } - ]); + let array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); this.render( strip` @@ -1504,7 +1469,7 @@ moduleFor( `, { items: array, - model: { shouldShow: true } + model: { shouldShow: true }, } ); @@ -1526,26 +1491,26 @@ moduleFor( id: 3, hasParent: true, nextSibling: true, - previousSibling: true + previousSibling: true, }, { id: 4, hasParent: true, nextSibling: true, - previousSibling: true + previousSibling: true, }, { id: 6, hasParent: true, nextSibling: true, - previousSibling: true + previousSibling: true, }, { id: 7, hasParent: true, nextSibling: false, - previousSibling: true - } + previousSibling: true, + }, ] ); @@ -1557,50 +1522,50 @@ moduleFor( id: '3-A', hasParent: true, nextSibling: true, - previousSibling: false + previousSibling: false, }, { id: '3-B', hasParent: true, nextSibling: false, - previousSibling: true + previousSibling: true, }, { id: '4-A', hasParent: true, nextSibling: true, - previousSibling: false + previousSibling: false, }, { id: '4-B', hasParent: true, nextSibling: false, - previousSibling: true + previousSibling: true, }, { id: '6-A', hasParent: true, nextSibling: true, - previousSibling: false + previousSibling: false, }, { id: '6-B', hasParent: true, nextSibling: false, - previousSibling: true + previousSibling: true, }, { id: '7-A', hasParent: true, nextSibling: true, - previousSibling: false + previousSibling: false, }, { id: '7-B', hasParent: true, nextSibling: false, - previousSibling: true - } + previousSibling: true, + }, ] ); } @@ -1617,45 +1582,30 @@ if (!jQueryDisabled) { let FooBarComponent = Component.extend({ tagName: 'div', init() { - assert.notOk( - this.$(), - 'no access to element via this.$() on init() enter' - ); + assert.notOk(this.$(), 'no access to element via this.$() on init() enter'); this._super(...arguments); - assert.notOk( - this.$(), - 'no access to element via this.$() after init() finished' - ); + assert.notOk(this.$(), 'no access to element via this.$() after init() finished'); }, willInsertElement() { component = this; - assert.ok( - this.$(), - 'willInsertElement has access to element via this.$()' - ); + assert.ok(this.$(), 'willInsertElement has access to element via this.$()'); }, didInsertElement() { - assert.ok( - this.$(), - 'didInsertElement has access to element via this.$()' - ); + assert.ok(this.$(), 'didInsertElement has access to element via this.$()'); }, willDestroyElement() { - assert.ok( - this.$(), - 'willDestroyElement has access to element via this.$()' - ); + assert.ok(this.$(), 'willDestroyElement has access to element via this.$()'); }, didDestroyElement() { assert.notOk( this.$(), 'didDestroyElement does not have access to element via this.$()' ); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); let { owner } = this; let comp = owner.lookup('component:foo-bar'); @@ -1670,16 +1620,8 @@ function assertDestroyHooks(assert, _actual, _expected) { _expected.forEach((expected, i) => { let name = expected.name; assert.equal(expected.id, _actual[i].id, `${name} id is the same`); - assert.equal( - expected.hasParent, - _actual[i].hasParent, - `${name} has parent node` - ); - assert.equal( - expected.nextSibling, - _actual[i].nextSibling, - `${name} has next sibling node` - ); + assert.equal(expected.hasParent, _actual[i].hasParent, `${name} has parent node`); + assert.equal(expected.nextSibling, _actual[i].nextSibling, `${name} has next sibling node`); assert.equal( expected.previousSibling, _actual[i].previousSibling, diff --git a/packages/ember-glimmer/tests/integration/components/link-to-test.js b/packages/ember-glimmer/tests/integration/components/link-to-test.js index 14693b5258b..310196f5ff9 100644 --- a/packages/ember-glimmer/tests/integration/components/link-to-test.js +++ b/packages/ember-glimmer/tests/integration/components/link-to-test.js @@ -1,8 +1,4 @@ -import { - moduleFor, - ApplicationTest, - RenderingTest -} from '../../utils/test-case'; +import { moduleFor, ApplicationTest, RenderingTest } from '../../utils/test-case'; import { Controller } from 'ember-runtime'; import { set } from 'ember-metal'; import { LinkComponent } from '../../utils/helpers'; @@ -22,10 +18,7 @@ moduleFor( } ['@test should be able to be inserted in DOM when the router is not present']() { - this.addTemplate( - 'application', - `{{#link-to 'index'}}Go to Index{{/link-to}}` - ); + this.addTemplate('application', `{{#link-to 'index'}}Go to Index{{/link-to}}`); return this.visit('/').then(() => { this.assertText('Go to Index'); @@ -44,7 +37,7 @@ moduleFor( controller = this; }, title: 'foo', - routeName: 'index' + routeName: 'index', }) ); @@ -67,7 +60,7 @@ moduleFor( this._super(...arguments); controller = this; }, - routeName: 'index' + routeName: 'index', }) ); @@ -87,7 +80,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - title: 'blah' + title: 'blah', }) ); @@ -96,14 +89,12 @@ moduleFor( }); } - ['@test escaped inline form with (-html-safe) does not escape link title']( - assert - ) { + ['@test escaped inline form with (-html-safe) does not escape link title'](assert) { this.addTemplate('application', `{{link-to (-html-safe title) 'index'}}`); this.add( 'controller:application', Controller.extend({ - title: 'blah' + title: 'blah', }) ); @@ -113,14 +104,12 @@ moduleFor( }); } - ['@test unescaped inline form (triple curlies) does not escape link title']( - assert - ) { + ['@test unescaped inline form (triple curlies) does not escape link title'](assert) { this.addTemplate('application', `{{{link-to title 'index'}}}`); this.add( 'controller:application', Controller.extend({ - title: 'blah' + title: 'blah', }) ); @@ -132,16 +121,13 @@ moduleFor( ['@test able to safely extend the built-in component and use the normal path']() { this.addComponent('custom-link-to', { - ComponentClass: LinkComponent.extend() + ComponentClass: LinkComponent.extend(), }); - this.addTemplate( - 'application', - `{{#custom-link-to 'index'}}{{title}}{{/custom-link-to}}` - ); + this.addTemplate('application', `{{#custom-link-to 'index'}}{{title}}{{/custom-link-to}}`); this.add( 'controller:application', Controller.extend({ - title: 'Hello' + title: 'Hello', }) ); @@ -152,13 +138,13 @@ moduleFor( ['@test [GH#13432] able to safely extend the built-in component and invoke it inline']() { this.addComponent('custom-link-to', { - ComponentClass: LinkComponent.extend() + ComponentClass: LinkComponent.extend(), }); this.addTemplate('application', `{{custom-link-to title 'index'}}`); this.add( 'controller:application', Controller.extend({ - title: 'Hello' + title: 'Hello', }) ); @@ -180,7 +166,7 @@ moduleFor( Controller.extend({ queryParams: ['foo'], foo: '123', - bar: 'yes' + bar: 'yes', }) ); } @@ -195,22 +181,19 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: '/?bar=NAW&foo=456' }, - content: 'Index' + content: 'Index', }); }); } ['@test populates href with partially supplied query param values, but omits if value is default value']() { - this.addTemplate( - 'index', - `{{#link-to 'index' (query-params foo='123')}}Index{{/link-to}}` - ); + this.addTemplate('index', `{{#link-to 'index' (query-params foo='123')}}Index{{/link-to}}`); return this.visit('/').then(() => { this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: '/', class: classMatcher('ember-view active') }, - content: 'Index' + content: 'Index', }); }); } diff --git a/packages/ember-glimmer/tests/integration/components/local-lookup-test.js b/packages/ember-glimmer/tests/integration/components/local-lookup-test.js index 153438ad045..69d57abf43d 100644 --- a/packages/ember-glimmer/tests/integration/components/local-lookup-test.js +++ b/packages/ember-glimmer/tests/integration/components/local-lookup-test.js @@ -1,10 +1,7 @@ import { moduleFor, RenderingTest } from '../../utils/test-case'; import { compile } from 'ember-template-compiler'; import { ModuleBasedTestResolver } from 'internal-test-helpers'; -import { - moduleFor as applicationModuleFor, - ApplicationTestCase -} from 'internal-test-helpers'; +import { moduleFor as applicationModuleFor, ApplicationTestCase } from 'internal-test-helpers'; import { Component } from '../../utils/helpers'; import { EMBER_MODULE_UNIFICATION } from 'ember/features'; import { helper, Helper } from 'ember-glimmer'; @@ -12,10 +9,10 @@ import { helper, Helper } from 'ember-glimmer'; class LocalLookupTest extends RenderingTest { ['@test it can lookup a local template']() { this.registerComponent('x-outer/x-inner', { - template: 'Nested template says: {{yield}}' + template: 'Nested template says: {{yield}}', }); this.registerComponent('x-outer', { - template: '{{#x-inner}}Hi!{{/x-inner}}' + template: '{{#x-inner}}Hi!{{/x-inner}}', }); this.render('{{x-outer}}'); @@ -29,11 +26,11 @@ class LocalLookupTest extends RenderingTest { ['@test tagless blockless component can lookup local template']() { this.registerComponent('x-outer/x-inner', { - template: 'Nested template says: {{yield}}' + template: 'Nested template says: {{yield}}', }); this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); this.registerComponent('x-outer', { - ComponentClass: Component.extend({ tagName: '' }) + ComponentClass: Component.extend({ tagName: '' }), }); this.render('{{x-outer}}'); @@ -46,10 +43,7 @@ class LocalLookupTest extends RenderingTest { } ['@test it can lookup a local component template']() { - this.registerTemplate( - 'components/x-outer/x-inner', - 'Nested template says: {{yield}}' - ); + this.registerTemplate('components/x-outer/x-inner', 'Nested template says: {{yield}}'); this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}'); this.render('{{x-outer}}'); @@ -63,7 +57,7 @@ class LocalLookupTest extends RenderingTest { ['@test it can local lookup a dynamic component']() { this.registerComponent('foo-bar', { - template: 'yall finished {{component child}}' + template: 'yall finished {{component child}}', }); this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); @@ -78,13 +72,13 @@ class LocalLookupTest extends RenderingTest { ['@test it can local lookup a dynamic component from a dynamic component']() { this.registerComponent('foo-bar', { - template: 'yall finished {{component child}}' + template: 'yall finished {{component child}}', }); this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' }); this.render('{{component componentName child=child}}', { componentName: 'foo-bar', - child: 'biz-baz' + child: 'biz-baz', }); this.assertText('yall finished or yall done?'); @@ -96,7 +90,7 @@ class LocalLookupTest extends RenderingTest { ['@test it can local lookup a dynamic component from a passed named argument']() { this.registerComponent('parent-foo', { - template: `yall finished {{global-biz baz=(component 'local-bar')}}` + template: `yall finished {{global-biz baz=(component 'local-bar')}}`, }); this.registerComponent('global-biz', { template: 'or {{component baz}}' }); this.registerComponent('parent-foo/local-bar', { template: 'yall done?' }); @@ -112,14 +106,14 @@ class LocalLookupTest extends RenderingTest { ['@test it can local lookup a re-wrapped dynamic component from a passed named argument']() { this.registerComponent('parent-foo', { - template: `yall finished {{global-x comp=(component 'local-bar')}}` + template: `yall finished {{global-x comp=(component 'local-bar')}}`, }); this.registerComponent('global-x', { - template: `or {{global-y comp=(component comp phrase='done')}}` + template: `or {{global-y comp=(component comp phrase='done')}}`, }); this.registerComponent('global-y', { template: `{{component comp}}?` }); this.registerComponent('parent-foo/local-bar', { - template: 'yall {{phrase}}' + template: 'yall {{phrase}}', }); this.render('{{parent-foo}}'); @@ -133,16 +127,16 @@ class LocalLookupTest extends RenderingTest { ['@test it can nest local lookups of dynamic components from a passed named argument']() { this.registerComponent('parent-foo', { - template: `yall finished {{global-x comp=(component 'local-bar')}}` + template: `yall finished {{global-x comp=(component 'local-bar')}}`, }); this.registerComponent('global-x', { - template: `or {{global-y comp=(component comp phrase='done')}}` + template: `or {{global-y comp=(component comp phrase='done')}}`, }); this.registerComponent('global-y', { - template: `{{component comp}}{{component 'local-bar'}}` + template: `{{component comp}}{{component 'local-bar'}}`, }); this.registerComponent('parent-foo/local-bar', { - template: 'yall {{phrase}}' + template: 'yall {{phrase}}', }); this.registerComponent('global-y/local-bar', { template: `?` }); @@ -157,10 +151,10 @@ class LocalLookupTest extends RenderingTest { ['@test it can switch from local to global lookups of dynamic components from a passed named argument']() { this.registerComponent('parent-foo', { - template: `yall finished {{global-x comp=(component bar)}}` + template: `yall finished {{global-x comp=(component bar)}}`, }); this.registerComponent('global-x', { - template: `or yall {{component comp}}` + template: `or yall {{component comp}}`, }); this.registerComponent('parent-foo/local-bar', { template: 'done?' }); this.registerComponent('global-bar', { template: `ready?` }); @@ -213,7 +207,7 @@ class LocalLookupTest extends RenderingTest { ['@test lookup without match issues standard assertion (with local helper name)']() { this.registerComponent('x-outer', { - template: '{{#x-inner}}Hi!{{/x-inner}}' + template: '{{#x-inner}}Hi!{{/x-inner}}', }); expectAssertion(() => { @@ -223,13 +217,13 @@ class LocalLookupTest extends RenderingTest { ['@test overrides global lookup']() { this.registerComponent('x-outer', { - template: '{{#x-inner}}Hi!{{/x-inner}}' + template: '{{#x-inner}}Hi!{{/x-inner}}', }); this.registerComponent('x-outer/x-inner', { - template: 'Nested template says (from local): {{yield}}' + template: 'Nested template says (from local): {{yield}}', }); this.registerComponent('x-inner', { - template: 'Nested template says (from global): {{yield}}' + template: 'Nested template says (from global): {{yield}}', }); this.render( @@ -263,10 +257,7 @@ function buildResolver() { sourceName = sourceName.replace('my-app/', ''); - if ( - sourceType === 'template' && - sourceName.slice(0, 21) === 'templates/components/' - ) { + if (sourceType === 'template' && sourceName.slice(0, 21) === 'templates/components/') { sourceName = sourceName.slice(21); } @@ -281,7 +272,7 @@ function buildResolver() { let result = `${type}:${sourceName}/${name}`; return result; - } + }, }; return resolver; @@ -305,9 +296,7 @@ if (EMBER_MODULE_UNIFICATION) { name = name.replace('components/', ''); namespace = namespace.replace('.hbs', ''); - return `${type}:${ - type === 'template' ? 'components/' : '' - }${namespace}/${name}`; + return `${type}:${type === 'template' ? 'components/' : ''}${namespace}/${name}`; } return super.expandLocalLookup(specifier, source); @@ -344,7 +333,7 @@ if (EMBER_MODULE_UNIFICATION) { resolver.add( `template:components/${name}`, this.compile(template, { - moduleName: `my-name/templates/components/${name}.hbs` + moduleName: `my-name/templates/components/${name}.hbs`, }) ); } @@ -356,7 +345,7 @@ if (EMBER_MODULE_UNIFICATION) { resolver.add( `template:${name}`, this.compile(template, { - moduleName: `my-name/templates/${name}.hbs` + moduleName: `my-name/templates/${name}.hbs`, }) ); } else { @@ -384,13 +373,11 @@ if (EMBER_MODULE_UNIFICATION) { applicationModuleFor( 'Components test: local lookup with resolution referrer (MU)', class extends ApplicationTestCase { - ['@test Ensure that the same specifier with two sources does not share a cache key']( - assert - ) { + ['@test Ensure that the same specifier with two sources does not share a cache key'](assert) { this.add( { specifier: 'template:components/x-not-shared', - source: 'template:my-app/templates/components/x-top.hbs' + source: 'template:my-app/templates/components/x-top.hbs', }, compile('child-x-not-shared') ); @@ -398,25 +385,22 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'template:components/x-top', - source: 'template:my-app/templates/application.hbs' + source: 'template:my-app/templates/application.hbs', }, compile('top-level-x-top ({{x-not-shared}})', { - moduleName: 'my-app/templates/components/x-top.hbs' + moduleName: 'my-app/templates/components/x-top.hbs', }) ); this.add( { specifier: 'template:components/x-not-shared', - source: 'template:my-app/templates/application.hbs' + source: 'template:my-app/templates/application.hbs', }, compile('top-level-x-not-shared') ); - this.addTemplate( - 'application', - '{{x-not-shared}} {{x-top}} {{x-not-shared}} {{x-top}}' - ); + this.addTemplate('application', '{{x-not-shared}} {{x-top}} {{x-not-shared}} {{x-top}}'); return this.visit('/').then(() => { assert.equal( diff --git a/packages/ember-glimmer/tests/integration/components/namespaced-lookup-test.js b/packages/ember-glimmer/tests/integration/components/namespaced-lookup-test.js index 9ae5fe22101..f6991cbbe6c 100644 --- a/packages/ember-glimmer/tests/integration/components/namespaced-lookup-test.js +++ b/packages/ember-glimmer/tests/integration/components/namespaced-lookup-test.js @@ -10,7 +10,7 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/my-component', - namespace: 'my-addon' + namespace: 'my-addon', }, 'namespaced template {{myProp}}' ); @@ -18,15 +18,15 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'component:my-component', - namespace: 'my-addon' + namespace: 'my-addon', }, Component.extend({ - myProp: 'My property' + myProp: 'My property', }) ); this.addComponent('x-outer', { - template: '{{my-addon::my-component}}' + template: '{{my-addon::my-component}}', }); this.render('{{x-outer}}'); @@ -42,7 +42,7 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/my-component', - namespace: 'second-addon' + namespace: 'second-addon', }, 'second namespaced template' ); @@ -50,33 +50,29 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/my-component', - namespace: 'first-addon' + namespace: 'first-addon', }, 'first namespaced template - {{second-addon::my-component}}' ); this.addComponent('x-outer', { - template: '{{first-addon::my-component}}' + template: '{{first-addon::my-component}}', }); this.render('{{x-outer}}'); - this.assertText( - 'first namespaced template - second namespaced template' - ); + this.assertText('first namespaced template - second namespaced template'); this.runTask(() => this.rerender()); - this.assertText( - 'first namespaced template - second namespaced template' - ); + this.assertText('first namespaced template - second namespaced template'); } ['@test it can render a nested un-namespaced component']() { this.addTemplate( { specifier: 'template:components/addon-component', - source: 'template:first-addon/src/ui/components/my-component.hbs' + source: 'template:first-addon/src/ui/components/my-component.hbs', }, 'un-namespaced addon template' ); @@ -85,13 +81,13 @@ if (EMBER_MODULE_UNIFICATION) { { specifier: 'template:components/my-component', moduleName: 'first-addon/src/ui/components/my-component.hbs', - namespace: 'first-addon' + namespace: 'first-addon', }, '{{addon-component}}' ); this.addComponent('x-outer', { - template: '{{first-addon::my-component}}' + template: '{{first-addon::my-component}}', }); this.render('{{x-outer}}'); @@ -107,7 +103,7 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/addon-component', - soruce: 'template:first-addon/src/ui/components/main.hbs' + soruce: 'template:first-addon/src/ui/components/main.hbs', }, 'Nested namespaced component' ); @@ -115,7 +111,7 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/first-addon', - moduleName: 'first-addon/src/ui/components/main.hbs' + moduleName: 'first-addon/src/ui/components/main.hbs', }, '{{addon-component}}' ); @@ -135,7 +131,7 @@ if (EMBER_MODULE_UNIFICATION) { this.addTemplate( { specifier: 'template:components/main', - namespace: 'my-addon' + namespace: 'my-addon', }, 'namespaced template {{myProp}}' ); @@ -143,17 +139,17 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'component:main', - namespace: 'my-addon' + namespace: 'my-addon', }, Component.extend({ - myProp: 'My property' + myProp: 'My property', }) ); this.add( { specifier: 'helper:my-addon', - namespace: 'empty-namespace' + namespace: 'empty-namespace', }, helper(() => 'my helper') ); @@ -171,7 +167,7 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'helper:my-helper', - namespace: 'my-namespace' + namespace: 'my-namespace', }, helper(() => 'my helper') ); diff --git a/packages/ember-glimmer/tests/integration/components/target-action-test.js b/packages/ember-glimmer/tests/integration/components/target-action-test.js index 6308af30e39..e14c1adc2bb 100644 --- a/packages/ember-glimmer/tests/integration/components/target-action-test.js +++ b/packages/ember-glimmer/tests/integration/components/target-action-test.js @@ -1,9 +1,5 @@ import { assign } from 'ember-utils'; -import { - moduleFor, - RenderingTest, - ApplicationTest -} from '../../utils/test-case'; +import { moduleFor, RenderingTest, ApplicationTest } from '../../utils/test-case'; import { strip } from '../../utils/abstract-test-case'; import { set, Mixin } from 'ember-metal'; import { Component } from '../../utils/helpers'; @@ -27,8 +23,8 @@ moduleFor( this._super(); self.delegate = this; this.name = 'action-delegate'; - } - }) + }, + }), }); } @@ -40,17 +36,13 @@ moduleFor( root.actionCounts[actionName] = root.actionCounts[actionName] || 0; root.actionCounts[actionName]++; root.actionArguments = args; - } + }, }); this.render(template, context); } assertSendCount(count) { - this.assert.equal( - this.sendCount, - count, - `Send was called ${count} time(s)` - ); + this.assert.equal(this.sendCount, count, `Send was called ${count} time(s)`); } assertNamedSendCount(actionName, count) { @@ -61,10 +53,7 @@ moduleFor( ); } - assertSentWithArgs( - expected, - message = 'arguments were sent with the action' - ) { + assertSentWithArgs(expected, message = 'arguments were sent with the action') { this.assert.deepEqual(this.actionArguments, expected, message); } @@ -94,9 +83,7 @@ moduleFor( this.renderDelegate(); this.runTask(() => { - set(this.delegate, 'action', () => - this.assert.ok(true, 'function is called') - ); + set(this.delegate, 'action', () => this.assert.ok(true, 'function is called')); this.delegate.sendAction(); }); } @@ -118,7 +105,7 @@ moduleFor( // TODO consolidate these next 2 tests ['@test Calling sendAction on a component with a reference attr calls the function with arguments']() { this.renderDelegate('{{action-delegate playing=playing}}', { - playing: null + playing: null, }); this.runTask(() => this.delegate.sendAction()); @@ -139,7 +126,7 @@ moduleFor( ['@test Calling sendAction on a component with a {{mut}} attr calls the function with arguments']() { this.renderDelegate('{{action-delegate playing=(mut playing)}}', { - playing: null + playing: null, }); this.runTask(() => this.delegate.sendAction('playing')); @@ -206,10 +193,7 @@ moduleFor( this.assertSendCount(1); this.assertNamedSendCount('didStartPlaying', 1); - this.assertSentWithArgs( - [testContext], - 'context was sent with the action' - ); + this.assertSentWithArgs([testContext], 'context was sent with the action'); this.runTask(() => { this.delegate.sendAction('playing', firstContext, secondContext); @@ -239,20 +223,16 @@ moduleFor( actions: { derp(arg1) { assert.ok(true, 'action called on action-delgate'); - assert.equal( - arg1, - 'something special', - 'argument passed through properly' - ); - } - } + assert.equal(arg1, 'something special', 'argument passed through properly'); + }, + }, }), template: strip` {{#component-a}} {{component-b bar="derp"}} {{/component-a}} - ` + `, }); this.registerComponent('component-a', { @@ -264,9 +244,9 @@ moduleFor( actions: { derp() { assert.ok(false, 'no! bad scoping!'); - } - } - }) + }, + }, + }), }); let innerChild; @@ -276,8 +256,8 @@ moduleFor( this._super(...arguments); innerChild = this; this.name = 'component-b'; - } - }) + }, + }), }); this.renderDelegate(); @@ -297,12 +277,12 @@ moduleFor( toString() { return 'component:rip-alley'; - } - }) + }, + }), }); this.render('{{#if shouldRender}}{{rip-alley}}{{/if}}', { - shouldRender: true + shouldRender: true, }); this.runTask(() => { @@ -340,9 +320,9 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: `{{val}}` + template: `{{val}}`, }); this.add( @@ -359,7 +339,7 @@ moduleFor( 'top', 'action arguments were passed into the top level controller' ); - } + }, }) ); this.addTemplate('a', '{{foo-bar val="a" poke="poke"}}'); @@ -371,8 +351,8 @@ moduleFor( poke(actionContext) { assert.ok(true, 'Unhandled action sent to route'); assert.equal(actionContext, 'top no controller'); - } - } + }, + }, }) ); this.addTemplate('b', '{{foo-bar val="b" poke="poke"}}'); @@ -384,8 +364,8 @@ moduleFor( poke(actionContext) { assert.ok(true, 'Unhandled action sent to route'); assert.equal(actionContext, 'top with nested no controller'); - } - } + }, + }, }) ); this.addTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}'); @@ -396,17 +376,13 @@ moduleFor( 'controller:c.d', Controller.extend({ send(actionName, actionContext) { - assert.equal( - actionName, - 'poke', - 'send() method was invoked from a nested controller' - ); + assert.equal(actionName, 'poke', 'send() method was invoked from a nested controller'); assert.equal( actionContext, 'nested', 'action arguments were passed into the nested controller' ); - } + }, }) ); this.addTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}'); @@ -418,8 +394,8 @@ moduleFor( poke(actionContext) { assert.ok(true, 'Unhandled action sent to route'); assert.equal(actionContext, 'nested no controller'); - } - } + }, + }, }) ); this.addTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}'); @@ -435,9 +411,7 @@ moduleFor( this.assertText('b'); return this.visit('/c'); }) - .then(() => - component.sendAction('poke', 'top with nested no controller') - ) + .then(() => component.sendAction('poke', 'top with nested no controller')) .then(() => { this.assertText('c'); return this.visit('/c/d'); @@ -463,10 +437,10 @@ moduleFor( actions: { poke() { assert.ok(true, 'parent component handled the aciton'); - } - } + }, + }, }), - template: '{{x-child poke="poke"}}' + template: '{{x-child poke="poke"}}', }); this.addComponent('x-child', { @@ -474,8 +448,8 @@ moduleFor( init() { this._super(...arguments); component = this; - } - }) + }, + }), }); this.addTemplate('application', '{{x-parent}}'); @@ -484,7 +458,7 @@ moduleFor( Controller.extend({ send() { throw new Error('controller action should not be called'); - } + }, }) ); @@ -505,18 +479,18 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: Component.extend({ outerSubmit() { assert.ok(true, 'outerSubmit called'); - } + }, }), - template: '{{inner-component submitAction=(action outerSubmit)}}' + template: '{{inner-component submitAction=(action outerSubmit)}}', }); this.render('{{outer-component}}'); @@ -538,9 +512,9 @@ moduleFor( init() { this._super(...arguments); innerComponent = this; - } + }, }), - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { @@ -549,10 +523,10 @@ moduleFor( actions: { outerSubmit() { actualArgs = [...arguments]; - } - } + }, + }, }), - template: `{{inner-component innerSubmit=(action (action "outerSubmit" "${first}") "${second}" third)}}` + template: `{{inner-component innerSubmit=(action (action "outerSubmit" "${first}") "${second}" third)}}`, }); this.render('{{outer-component}}'); @@ -585,9 +559,9 @@ moduleFor( actions: { foo(message) { assert.equal('bar', message); - } - } - }) + }, + }, + }), }); this.render('{{foo-bar}}'); @@ -605,7 +579,7 @@ moduleFor( send: (message, payload) => { this.assert.equal('foo', message); this.assert.equal('baz', payload); - } + }, }; this.registerComponent('foo-bar', { @@ -614,8 +588,8 @@ moduleFor( this._super(); component = this; }, - target - }) + target, + }), }); this.render('{{foo-bar}}'); @@ -638,16 +612,16 @@ moduleFor( poke: () => { this.assert.ok(true, 'component action called'); return true; - } + }, }, target: Controller.extend({ actions: { poke: () => { this.assert.ok(true, 'action bubbled to controller'); - } - } - }).create() - }) + }, + }, + }).create(), + }), }); this.render('{{foo-bar poke="poke"}}'); @@ -667,8 +641,8 @@ moduleFor( }, bar(msg) { assert.equal(msg, 'HELLO'); - } - } + }, + }, }); let BarViewMixin = Mixin.create({ @@ -676,8 +650,8 @@ moduleFor( bar(msg) { assert.equal(msg, 'HELLO'); this._super(msg); - } - } + }, + }, }); this.registerComponent('x-index', { @@ -689,9 +663,9 @@ moduleFor( actions: { baz() { assert.ok(true, 'baz'); - } - } - }) + }, + }, + }), }); this.render('{{x-index}}'); @@ -712,13 +686,13 @@ moduleFor( actions: { foo() { assert.ok(true, 'foo'); - } - } + }, + }, }); }, /`actions` must be provided at extend time, not at create time/); // but should be OK on an object that doesn't mix in Ember.ActionHandler EmberObject.create({ - actions: ['foo'] + actions: ['foo'], }); } @@ -734,12 +708,12 @@ moduleFor( toString() { return 'component:rip-alley'; - } - }) + }, + }), }); this.render('{{#if shouldRender}}{{rip-alley}}{{/if}}', { - shouldRender: true + shouldRender: true, }); this.runTask(() => { diff --git a/packages/ember-glimmer/tests/integration/components/template-only-components-test.js b/packages/ember-glimmer/tests/integration/components/template-only-components-test.js index fa14c6d6c52..0d365dc8180 100644 --- a/packages/ember-glimmer/tests/integration/components/template-only-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/template-only-components-test.js @@ -13,8 +13,7 @@ moduleFor( class extends TemplateOnlyComponentsTest { constructor() { super(); - this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = - ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; + this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true; } @@ -38,7 +37,7 @@ moduleFor( this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', - bar: 'bar' + bar: 'bar', }); this.assertInnerHTML('|foo|bar|'); @@ -53,9 +52,7 @@ moduleFor( this.assertInnerHTML('|FOO|BAR|'); - this.runTask(() => - this.context.setProperties({ foo: 'foo', bar: 'bar' }) - ); + this.runTask(() => this.context.setProperties({ foo: 'foo', bar: 'bar' })); this.assertInnerHTML('|foo|bar|'); } @@ -65,7 +62,7 @@ moduleFor( this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', - bar: 'bar' + bar: 'bar', }); this.assertInnerHTML('|||'); @@ -80,9 +77,7 @@ moduleFor( this.assertInnerHTML('|||'); - this.runTask(() => - this.context.setProperties({ foo: 'foo', bar: 'bar' }) - ); + this.runTask(() => this.context.setProperties({ foo: 'foo', bar: 'bar' })); this.assertInnerHTML('|||'); } @@ -91,7 +86,7 @@ moduleFor( this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar tagName="p" class=class}}', { - class: 'foo bar' + class: 'foo bar', }); this.assertInnerHTML('hello'); @@ -118,8 +113,7 @@ moduleFor( class extends TemplateOnlyComponentsTest { constructor() { super(); - this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = - ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; + this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = false; } @@ -143,7 +137,7 @@ moduleFor( this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', - bar: 'bar' + bar: 'bar', }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); @@ -158,9 +152,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { content: '|FOO|BAR|' }); - this.runTask(() => - this.context.setProperties({ foo: 'foo', bar: 'bar' }) - ); + this.runTask(() => this.context.setProperties({ foo: 'foo', bar: 'bar' })); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); } @@ -170,7 +162,7 @@ moduleFor( this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', - bar: 'bar' + bar: 'bar', }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); @@ -185,9 +177,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { content: '|FOO||' }); - this.runTask(() => - this.context.setProperties({ foo: 'foo', bar: 'bar' }) - ); + this.runTask(() => this.context.setProperties({ foo: 'foo', bar: 'bar' })); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); } @@ -196,13 +186,13 @@ moduleFor( this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar tagName="p" class=class}}', { - class: 'foo bar' + class: 'foo bar', }); this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: classes('foo bar ember-view') }, - content: 'hello' + content: 'hello', }); this.assertStableRerender(); @@ -212,7 +202,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: classes('foo ember-view') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.context.set('class', null)); @@ -220,7 +210,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: classes('ember-view') }, - content: 'hello' + content: 'hello', }); this.runTask(() => this.context.set('class', 'foo bar')); @@ -228,7 +218,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: classes('foo bar ember-view') }, - content: 'hello' + content: 'hello', }); } } diff --git a/packages/ember-glimmer/tests/integration/components/to-string-test.js b/packages/ember-glimmer/tests/integration/components/to-string-test.js index 32ddbe52e82..6ab1dc9c7f5 100644 --- a/packages/ember-glimmer/tests/integration/components/to-string-test.js +++ b/packages/ember-glimmer/tests/integration/components/to-string-test.js @@ -1,11 +1,5 @@ import { moduleFor, RenderingTest } from '../../utils/test-case'; -import { - Checkbox, - Component, - LinkComponent, - TextArea, - TextField -} from 'ember-glimmer'; +import { Checkbox, Component, LinkComponent, TextArea, TextField } from 'ember-glimmer'; moduleFor( 'built-in component toString', @@ -27,10 +21,7 @@ moduleFor( } '@test LinkTo has the correct toString value'(assert) { - assert.strictEqual( - LinkComponent.toString(), - '@ember/routing/link-component' - ); + assert.strictEqual(LinkComponent.toString(), '@ember/routing/link-component'); } } ); diff --git a/packages/ember-glimmer/tests/integration/components/utils-test.js b/packages/ember-glimmer/tests/integration/components/utils-test.js index f1c67220040..7e3a649cd95 100644 --- a/packages/ember-glimmer/tests/integration/components/utils-test.js +++ b/packages/ember-glimmer/tests/integration/components/utils-test.js @@ -4,13 +4,9 @@ import { getChildViews, getViewBounds, getViewClientRects, - getViewBoundingClientRect + getViewBoundingClientRect, } from 'ember-views'; -import { - moduleFor, - ApplicationTest, - RenderingTest -} from '../../utils/test-case'; +import { moduleFor, ApplicationTest, RenderingTest } from '../../utils/test-case'; import { Component } from '../../utils/helpers'; moduleFor( @@ -21,11 +17,10 @@ moduleFor( this.addComponent('x-tagless', { ComponentClass: Component.extend({ - tagName: '' + tagName: '', }), - template: - '
[{{id}}] {{#if isShowing}}{{yield}}{{/if}}
' + template: '
[{{id}}] {{#if isShowing}}{{yield}}{{/if}}
', }); this.addComponent('x-toggle', { @@ -35,10 +30,10 @@ moduleFor( click() { this.toggleProperty('isExpanded'); return false; - } + }, }), - template: '[{{id}}] {{#if isExpanded}}{{yield}}{{/if}}' + template: '[{{id}}] {{#if isExpanded}}{{yield}}{{/if}}', }); let ToggleController = Controller.extend({ @@ -47,8 +42,8 @@ moduleFor( actions: { toggle: function() { this.toggleProperty('isExpanded'); - } - } + }, + }, }); this.add('controller:application', ToggleController); @@ -79,7 +74,7 @@ moduleFor( this.add( 'controller:index', ToggleController.extend({ - isExpanded: false + isExpanded: false, }) ); @@ -140,13 +135,7 @@ moduleFor( ['@test getRootViews']() { return this.visit('/') .then(() => { - this.assertRootViews([ - 'root-1', - 'root-2', - 'root-3', - 'root-4', - 'root-5' - ]); + this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5']); this.runTask(() => this.$('#toggle-application').click()); @@ -157,38 +146,17 @@ moduleFor( this.$('#toggle-index').click(); }); - this.assertRootViews([ - 'root-1', - 'root-2', - 'root-3', - 'root-4', - 'root-5', - 'root-6' - ]); + this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); return this.visit('/zomg/lol'); }) .then(() => { - this.assertRootViews([ - 'root-1', - 'root-2', - 'root-3', - 'root-7', - 'root-8', - 'root-9' - ]); + this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-7', 'root-8', 'root-9']); return this.visit('/'); }) .then(() => { - this.assertRootViews([ - 'root-1', - 'root-2', - 'root-3', - 'root-4', - 'root-5', - 'root-6' - ]); + this.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']); }); } @@ -320,9 +288,9 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: `

Hi, mom!

` + template: `

Hi, mom!

`, }); this.render(`{{hi-mom}}`); @@ -354,9 +322,9 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: `Hi, mom!` + template: `Hi, mom!`, }); this.render(`{{hi-mom}}`); @@ -395,9 +363,9 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: `

Hi, mom!

` + template: `

Hi, mom!

`, }); this.render(`{{hi-mom}}`); @@ -420,9 +388,9 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: `

Hi, mom!

` + template: `

Hi, mom!

`, }); this.render(`{{hi-mom}}`); diff --git a/packages/ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js b/packages/ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js index 43291bdd1aa..b9f19cab8d6 100644 --- a/packages/ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js +++ b/packages/ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js @@ -11,44 +11,28 @@ moduleFor( let FooBarComponent = Component.extend({ didInsertElement() { didInsertElementCount++; - assert.notEqual( - this.element.parentNode, - null, - 'precond component is in DOM' - ); + assert.notEqual(this.element.parentNode, null, 'precond component is in DOM'); }, willDestroyElement() { willDestroyElementCount++; - assert.notEqual( - this.element.parentNode, - null, - 'has not been removed from DOM yet' - ); - } + assert.notEqual(this.element.parentNode, null, 'has not been removed from DOM yet'); + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); this.render('{{#if switch}}{{foo-bar}}{{/if}}', { switch: true }); - assert.equal( - didInsertElementCount, - 1, - 'didInsertElement was called once' - ); + assert.equal(didInsertElementCount, 1, 'didInsertElement was called once'); this.assertComponentElement(this.firstChild, { content: 'hello' }); this.runTask(() => set(this.context, 'switch', false)); - assert.equal( - willDestroyElementCount, - 1, - 'willDestroyElement was called once' - ); + assert.equal(willDestroyElementCount, 1, 'willDestroyElement was called once'); this.assertText(''); } diff --git a/packages/ember-glimmer/tests/integration/content-test.js b/packages/ember-glimmer/tests/integration/content-test.js index 9213fcf2b6d..7aedd6313b4 100644 --- a/packages/ember-glimmer/tests/integration/content-test.js +++ b/packages/ember-glimmer/tests/integration/content-test.js @@ -146,9 +146,7 @@ class DynamicContentTest extends RenderingTest { this.assertStableRerender(); - this.runTask(() => - set(this.context, 'CaptializedPath', 'still no deprecation') - ); + this.runTask(() => set(this.context, 'CaptializedPath', 'still no deprecation')); this.assertContent('still no deprecation'); this.assertInvariants(); @@ -177,7 +175,7 @@ class DynamicContentTest extends RenderingTest { ['@test it can render a deeply nested dynamic path']() { this.renderPath('a.b.c.d.e.f', { - a: { b: { c: { d: { e: { f: 'hello' } } } } } + a: { b: { c: { d: { e: { f: 'hello' } } } } }, }); this.assertContent('hello'); @@ -206,7 +204,7 @@ class DynamicContentTest extends RenderingTest { let Formatter = EmberObject.extend({ formattedMessage: computed('message', function() { return this.get('message').toUpperCase(); - }) + }), }); let m = Formatter.create({ message: 'hello' }); @@ -222,9 +220,7 @@ class DynamicContentTest extends RenderingTest { this.assertContent('GOODBYE'); this.assertInvariants(); - this.runTask(() => - set(this.context, 'm', Formatter.create({ message: 'hello' })) - ); + this.runTask(() => set(this.context, 'm', Formatter.create({ message: 'hello' }))); this.assertContent('HELLO'); this.assertInvariants(); @@ -234,7 +230,7 @@ class DynamicContentTest extends RenderingTest { let Formatter = EmberObject.extend({ formattedMessage: computed('messenger.message', function() { return this.get('messenger.message').toUpperCase(); - }) + }), }); let m = Formatter.create({ messenger: { message: 'hello' } }); @@ -251,11 +247,7 @@ class DynamicContentTest extends RenderingTest { this.assertInvariants(); this.runTask(() => - set( - this.context, - 'm', - Formatter.create({ messenger: { message: 'hello' } }) - ) + set(this.context, 'm', Formatter.create({ messenger: { message: 'hello' } })) ); this.assertContent('HELLO'); @@ -264,7 +256,7 @@ class DynamicContentTest extends RenderingTest { ['@test it can read from a proxy object']() { this.renderPath('proxy.name', { - proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }) + proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }), }); this.assertContent('Tom Dale'); @@ -276,9 +268,7 @@ class DynamicContentTest extends RenderingTest { this.assertContent('Yehuda Katz'); this.assertInvariants(); - this.runTask(() => - set(this.context, 'proxy.content', { name: 'Godfrey Chan' }) - ); + this.runTask(() => set(this.context, 'proxy.content', { name: 'Godfrey Chan' })); this.assertContent('Godfrey Chan'); this.assertInvariants(); @@ -293,11 +283,7 @@ class DynamicContentTest extends RenderingTest { this.assertIsEmpty(); this.runTask(() => - set( - this.context, - 'proxy', - ObjectProxy.create({ content: { name: 'Tom Dale' } }) - ) + set(this.context, 'proxy', ObjectProxy.create({ content: { name: 'Tom Dale' } })) ); this.assertContent('Tom Dale'); @@ -307,8 +293,8 @@ class DynamicContentTest extends RenderingTest { ['@test it can read from a nested path in a proxy object']() { this.renderPath('proxy.name.last', { proxy: ObjectProxy.create({ - content: { name: { first: 'Tom', last: 'Dale' } } - }) + content: { name: { first: 'Tom', last: 'Dale' } }, + }), }); this.assertContent('Dale'); @@ -324,25 +310,21 @@ class DynamicContentTest extends RenderingTest { this.assertStableRerender(); - this.runTask(() => - set(this.context, 'proxy.content.name', { first: 'Yehuda', last: 'Katz' }) - ); + this.runTask(() => set(this.context, 'proxy.content.name', { first: 'Yehuda', last: 'Katz' })); this.assertContent('Katz'); this.assertInvariants(); this.runTask(() => set(this.context, 'proxy.content', { - name: { first: 'Godfrey', last: 'Chan' } + name: { first: 'Godfrey', last: 'Chan' }, }) ); this.assertContent('Chan'); this.assertInvariants(); - this.runTask(() => - set(this.context, 'proxy.name', { first: 'Stefan', last: 'Penner' }) - ); + this.runTask(() => set(this.context, 'proxy.name', { first: 'Stefan', last: 'Penner' })); this.assertContent('Penner'); this.assertInvariants(); @@ -356,7 +338,7 @@ class DynamicContentTest extends RenderingTest { this.context, 'proxy', ObjectProxy.create({ - content: { name: { first: 'Tom', last: 'Dale' } } + content: { name: { first: 'Tom', last: 'Dale' } }, }) ) ); @@ -368,8 +350,8 @@ class DynamicContentTest extends RenderingTest { ['@test it can read from a path flipping between a proxy and a real object']() { this.renderPath('proxyOrObject.name.last', { proxyOrObject: ObjectProxy.create({ - content: { name: { first: 'Tom', last: 'Dale' } } - }) + content: { name: { first: 'Tom', last: 'Dale' } }, + }), }); this.assertContent('Dale'); @@ -378,7 +360,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'proxyOrObject', { - name: { first: 'Tom', last: 'Dale' } + name: { first: 'Tom', last: 'Dale' }, }) ); @@ -395,7 +377,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'proxyOrObject', { - name: { first: 'Yehuda', last: 'Katz' } + name: { first: 'Yehuda', last: 'Katz' }, }) ); @@ -407,7 +389,7 @@ class DynamicContentTest extends RenderingTest { this.context, 'proxyOrObject', ObjectProxy.create({ - content: { name: { first: 'Godfrey', last: 'Chan' } } + content: { name: { first: 'Godfrey', last: 'Chan' } }, }) ) ); @@ -418,7 +400,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'proxyOrObject.content.name', { first: 'Stefan', - last: 'Penner' + last: 'Penner', }) ); @@ -434,7 +416,7 @@ class DynamicContentTest extends RenderingTest { this.context, 'proxyOrObject', ObjectProxy.create({ - content: { name: { first: 'Tom', last: 'Dale' } } + content: { name: { first: 'Tom', last: 'Dale' } }, }) ) ); @@ -445,7 +427,7 @@ class DynamicContentTest extends RenderingTest { ['@test it can read from a path flipping between a real object and a proxy']() { this.renderPath('objectOrProxy.name.last', { - objectOrProxy: { name: { first: 'Tom', last: 'Dale' } } + objectOrProxy: { name: { first: 'Tom', last: 'Dale' } }, }); this.assertContent('Dale'); @@ -457,29 +439,25 @@ class DynamicContentTest extends RenderingTest { this.context, 'objectOrProxy', ObjectProxy.create({ - content: { name: { first: 'Tom', last: 'Dale' } } + content: { name: { first: 'Tom', last: 'Dale' } }, }) ) ); this.assertStableRerender(); - this.runTask(() => - set(this.context, 'objectOrProxy.content.name.last', 'Cruise') - ); + this.runTask(() => set(this.context, 'objectOrProxy.content.name.last', 'Cruise')); this.assertContent('Cruise'); this.assertInvariants(); - this.runTask(() => - set(this.context, 'objectOrProxy.content.name.first', 'Suri') - ); + this.runTask(() => set(this.context, 'objectOrProxy.content.name.first', 'Suri')); this.assertStableRerender(); this.runTask(() => set(this.context, 'objectOrProxy.content', { - name: { first: 'Yehuda', last: 'Katz' } + name: { first: 'Yehuda', last: 'Katz' }, }) ); @@ -488,7 +466,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'objectOrProxy', { - name: { first: 'Godfrey', last: 'Chan' } + name: { first: 'Godfrey', last: 'Chan' }, }) ); @@ -498,7 +476,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'objectOrProxy.name', { first: 'Stefan', - last: 'Penner' + last: 'Penner', }) ); @@ -511,7 +489,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'objectOrProxy', { - name: { first: 'Tom', last: 'Dale' } + name: { first: 'Tom', last: 'Dale' }, }) ); @@ -545,15 +523,15 @@ class DynamicContentTest extends RenderingTest { ['@test it can render a readOnly property of a path']() { let Messenger = EmberObject.extend({ - message: readOnly('a.b.c') + message: readOnly('a.b.c'), }); let messenger = Messenger.create({ a: { b: { - c: 'hello' - } - } + c: 'hello', + }, + }, }); this.renderPath('messenger.message', { messenger }); @@ -569,7 +547,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'messenger.a.b', { - c: 'goodbye' + c: 'goodbye', }) ); @@ -578,7 +556,7 @@ class DynamicContentTest extends RenderingTest { this.runTask(() => set(this.context, 'messenger', { - message: 'hello' + message: 'hello', }) ); @@ -636,7 +614,7 @@ class ContentTestGenerator { this.runTask(() => set(this.context, 'value', value)); this.assertIsEmpty(); - } + }, }; } else { return { @@ -655,7 +633,7 @@ class ContentTestGenerator { this.assertContent(expected); this.assertInvariants(); - } + }, }; } } @@ -682,42 +660,34 @@ const SharedContentTestCases = new ContentTestGenerator([ { toString() { return 'foo'; - } + }, }, 'foo', - 'an object with a custom toString function' + 'an object with a custom toString function', ], [ { valueOf() { return 1; - } + }, }, '[object Object]', - 'an object with a custom valueOf function' + 'an object with a custom valueOf function', ], // Escaping tests - ['MaxJames', 'MaxJames'] + ['MaxJames', 'MaxJames'], ]); let GlimmerContentTestCases = new ContentTestGenerator([ - [Object.create(null), EMPTY, 'an object with no toString'] + [Object.create(null), EMPTY, 'an object with no toString'], ]); if (typeof Symbol !== 'undefined') { - GlimmerContentTestCases.cases.push([ - Symbol('debug'), - 'Symbol(debug)', - 'a symbol' - ]); + GlimmerContentTestCases.cases.push([Symbol('debug'), 'Symbol(debug)', 'a symbol']); } -applyMixins( - DynamicContentTest, - SharedContentTestCases, - GlimmerContentTestCases -); +applyMixins(DynamicContentTest, SharedContentTestCases, GlimmerContentTestCases); moduleFor( 'Dynamic content tests (content position)', @@ -727,11 +697,7 @@ moduleFor( } assertContent(content) { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one text node' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); this.assertTextNode(this.firstChild, content); // this.takeSnapshot(); } @@ -746,11 +712,7 @@ moduleFor( } assertContent(content) { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one text node' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node'); this.assertTextNode(this.firstChild, content); } } @@ -764,21 +726,13 @@ moduleFor( } assertIsEmpty() { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one

tag' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

tag'); this.assertElement(this.firstChild, { tagName: 'p' }); this.assertText(''); } assertContent(content) { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one

tag' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one

tag'); this.assertElement(this.firstChild, { tagName: 'p' }); this.assertText(content); } @@ -793,24 +747,16 @@ moduleFor( } assertIsEmpty() { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one

tag' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
tag'); this.assertElement(this.firstChild, { tagName: 'div', content: '' }); } assertContent(content) { - this.assert.strictEqual( - this.nodesCount, - 1, - 'It should render exactly one
tag' - ); + this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one
tag'); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': content }, - content: '' + content: '', }); } } @@ -847,7 +793,7 @@ moduleFor( ['@test updating trusted curlies']() { this.render('{{{htmlContent}}}{{{nested.htmlContent}}}', { htmlContent: 'Max', - nested: { htmlContent: 'James' } + nested: { htmlContent: 'James' }, }); this.assertContent('MaxJames'); @@ -856,9 +802,7 @@ moduleFor( this.assertStableRerender(); - this.runTask(() => - set(this.context, 'htmlContent', 'Max') - ); + this.runTask(() => set(this.context, 'htmlContent', 'Max')); this.assertContent('MaxJames'); @@ -932,7 +876,7 @@ moduleFor( `; this.render(template, { - framework: 'Ember.js' + framework: 'Ember.js', }); this.assertHTML(ember); @@ -951,7 +895,7 @@ moduleFor( ['@test it should evaluate to nothing if part of the path is `undefined`']() { this.render('{{foo.bar.baz.bizz}}', { - foo: {} + foo: {}, }); this.assertText(''); @@ -962,7 +906,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: { baz: { bizz: 'Hey!' } } + bar: { baz: { bizz: 'Hey!' } }, }) ); @@ -974,7 +918,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: { baz: { bizz: 'Hello!' } } + bar: { baz: { bizz: 'Hello!' } }, }) ); @@ -987,7 +931,7 @@ moduleFor( ['@test it should evaluate to nothing if part of the path is a primative']() { this.render('{{foo.bar.baz.bizz}}', { - foo: { bar: true } + foo: { bar: true }, }); this.assertText(''); @@ -998,7 +942,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: false + bar: false, }) ); @@ -1006,7 +950,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: 'Haha' + bar: 'Haha', }) ); @@ -1014,7 +958,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: null + bar: null, }) ); @@ -1022,7 +966,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: undefined + bar: undefined, }) ); @@ -1030,7 +974,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: 1 + bar: 1, }) ); @@ -1038,7 +982,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: { baz: { bizz: 'Hello!' } } + bar: { baz: { bizz: 'Hello!' } }, }) ); @@ -1046,7 +990,7 @@ moduleFor( this.runTask(() => set(this.context, 'foo', { - bar: true + bar: true, }) ); @@ -1056,14 +1000,14 @@ moduleFor( ['@test can set dynamic href']() { this.render('Example', { model: { - url: 'http://example.com' - } + url: 'http://example.com', + }, }); this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', - attrs: { href: 'http://example.com' } + attrs: { href: 'http://example.com' }, }); this.runTask(() => this.rerender()); @@ -1071,7 +1015,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', - attrs: { href: 'http://example.com' } + attrs: { href: 'http://example.com' }, }); this.runTask(() => set(this.context, 'model.url', 'http://linkedin.com')); @@ -1079,29 +1023,27 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', - attrs: { href: 'http://linkedin.com' } + attrs: { href: 'http://linkedin.com' }, }); - this.runTask(() => - set(this.context, 'model', { url: 'http://example.com' }) - ); + this.runTask(() => set(this.context, 'model', { url: 'http://example.com' })); this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', - attrs: { href: 'http://example.com' } + attrs: { href: 'http://example.com' }, }); } ['@test quoteless class attributes update correctly']() { this.render('
hello
', { - fooBar: true + fooBar: true, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); this.runTask(() => this.rerender()); @@ -1109,7 +1051,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); this.runTask(() => set(this.context, 'fooBar', false)); @@ -1121,19 +1063,19 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); } ['@test quoted class attributes update correctly'](assert) { this.render('
hello
', { - fooBar: true + fooBar: true, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); this.runTask(() => this.rerender()); @@ -1141,7 +1083,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); this.runTask(() => set(this.context, 'fooBar', false)); @@ -1153,21 +1095,21 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo-bar') } + attrs: { class: classes('foo-bar') }, }); } ['@test unquoted class attribute can contain multiple classes']() { this.render('
hello
', { model: { - classes: 'foo bar baz' - } + classes: 'foo bar baz', + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); this.runTask(() => this.rerender()); @@ -1175,7 +1117,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); this.runTask(() => set(this.context, 'model.classes', 'fizz bizz')); @@ -1183,31 +1125,29 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz bizz') } + attrs: { class: classes('fizz bizz') }, }); - this.runTask(() => - set(this.context, 'model', { classes: 'foo bar baz' }) - ); + this.runTask(() => set(this.context, 'model', { classes: 'foo bar baz' })); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); } ['@test unquoted class attribute']() { this.render('
hello
', { model: { - foo: 'foo' - } + foo: 'foo', + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); this.runTask(() => this.rerender()); @@ -1215,7 +1155,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); this.runTask(() => set(this.context, 'model.foo', 'fizz')); @@ -1223,7 +1163,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz') } + attrs: { class: classes('fizz') }, }); this.runTask(() => set(this.context, 'model', { foo: 'foo' })); @@ -1231,21 +1171,21 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); } ['@test quoted class attribute']() { this.render('
hello
', { model: { - foo: 'foo' - } + foo: 'foo', + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); this.runTask(() => this.rerender()); @@ -1253,7 +1193,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); this.runTask(() => set(this.context, 'model.foo', 'fizz')); @@ -1261,7 +1201,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz') } + attrs: { class: classes('fizz') }, }); this.runTask(() => set(this.context, 'model', { foo: 'foo' })); @@ -1269,21 +1209,21 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo') } + attrs: { class: classes('foo') }, }); } ['@test quoted class attribute can contain multiple classes']() { this.render('
hello
', { model: { - classes: 'foo bar baz' - } + classes: 'foo bar baz', + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); this.runTask(() => this.rerender()); @@ -1291,7 +1231,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); this.runTask(() => set(this.context, 'model.classes', 'fizz bizz')); @@ -1299,36 +1239,31 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz bizz') } + attrs: { class: classes('fizz bizz') }, }); - this.runTask(() => - set(this.context, 'model', { classes: 'foo bar baz' }) - ); + this.runTask(() => set(this.context, 'model', { classes: 'foo bar baz' })); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar baz') } + attrs: { class: classes('foo bar baz') }, }); } ['@test class attribute concats bound values']() { - this.render( - '
hello
', - { - model: { - foo: 'foo', - bar: 'bar', - bizz: 'bizz' - } - } - ); + this.render('
hello
', { + model: { + foo: 'foo', + bar: 'bar', + bizz: 'bizz', + }, + }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar bizz') } + attrs: { class: classes('foo bar bizz') }, }); this.runTask(() => this.rerender()); @@ -1336,7 +1271,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar bizz') } + attrs: { class: classes('foo bar bizz') }, }); this.runTask(() => set(this.context, 'model.foo', 'fizz')); @@ -1344,7 +1279,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz bar bizz') } + attrs: { class: classes('fizz bar bizz') }, }); this.runTask(() => set(this.context, 'model.bar', null)); @@ -1352,21 +1287,21 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('fizz bizz') } + attrs: { class: classes('fizz bizz') }, }); this.runTask(() => set(this.context, 'model', { foo: 'foo', bar: 'bar', - bizz: 'bizz' + bizz: 'bizz', }) ); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar bizz') } + attrs: { class: classes('foo bar bizz') }, }); } @@ -1378,15 +1313,15 @@ moduleFor( size: 'large', hasSize: true, hasShape: false, - shape: 'round' - } + shape: 'round', + }, } ); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('large') } + attrs: { class: classes('large') }, }); this.runTask(() => this.rerender()); @@ -1394,7 +1329,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('large') } + attrs: { class: classes('large') }, }); this.runTask(() => set(this.context, 'model.hasShape', true)); @@ -1402,7 +1337,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('large round') } + attrs: { class: classes('large round') }, }); this.runTask(() => set(this.context, 'model.hasSize', false)); @@ -1410,7 +1345,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('round') } + attrs: { class: classes('round') }, }); this.runTask(() => @@ -1418,14 +1353,14 @@ moduleFor( size: 'large', hasSize: true, hasShape: false, - shape: 'round' + shape: 'round', }) ); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('large') } + attrs: { class: classes('large') }, }); } @@ -1437,15 +1372,15 @@ moduleFor( foo: 'foo', bar: 'bar', fizz: 'fizz', - baz: 'baz' - } + baz: 'baz', + }, } ); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar fizz baz') } + attrs: { class: classes('foo bar fizz baz') }, }); this.runTask(() => this.rerender()); @@ -1453,7 +1388,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar fizz baz') } + attrs: { class: classes('foo bar fizz baz') }, }); this.runTask(() => { @@ -1464,7 +1399,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('bar baz') } + attrs: { class: classes('bar baz') }, }); this.runTask(() => { @@ -1472,32 +1407,29 @@ moduleFor( foo: 'foo', bar: 'bar', fizz: 'fizz', - baz: 'baz' + baz: 'baz', }); }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: classes('foo bar fizz baz') } + attrs: { class: classes('foo bar fizz baz') }, }); } ['@test classes are ordered: See issue #9912']() { - this.render( - '
hello
', - { - model: { - foo: 'foo', - bar: 'bar' - } - } - ); + this.render('
hello
', { + model: { + foo: 'foo', + bar: 'bar', + }, + }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: 'foo static bar' } + attrs: { class: 'foo static bar' }, }); this.runTask(() => this.rerender()); @@ -1505,7 +1437,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: 'foo static bar' } + attrs: { class: 'foo static bar' }, }); this.runTask(() => { @@ -1515,20 +1447,20 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: 'foo static ' } + attrs: { class: 'foo static ' }, }); this.runTask(() => { set(this.context, 'model', { foo: 'foo', - bar: 'bar' + bar: 'bar', }); }); this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', - attrs: { class: 'foo static bar' } + attrs: { class: 'foo static bar' }, }); } } @@ -1567,14 +1499,14 @@ moduleFor( ['@test can set dynamic style']() { this.render('
', { model: { - style: htmlSafe('width: 60px;') - } + style: htmlSafe('width: 60px;'), + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); this.runTask(() => this.rerender()); @@ -1582,7 +1514,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); this.runTask(() => set(this.context, 'model.style', 'height: 60px;')); @@ -1590,7 +1522,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'height: 60px;' } + attrs: { style: 'height: 60px;' }, }); this.runTask(() => set(this.context, 'model.style', null)); @@ -1598,7 +1530,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: {} + attrs: {}, }); this.runTask(() => set(this.context, 'model', { style: 'width: 60px;' })); @@ -1606,21 +1538,21 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); } ['@test can set dynamic style with -html-safe']() { this.render('
', { model: { - style: htmlSafe('width: 60px;') - } + style: htmlSafe('width: 60px;'), + }, }); this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); this.runTask(() => this.rerender()); @@ -1628,7 +1560,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); this.runTask(() => set(this.context, 'model.style', 'height: 60px;')); @@ -1636,7 +1568,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'height: 60px;' } + attrs: { style: 'height: 60px;' }, }); this.runTask(() => set(this.context, 'model', { style: 'width: 60px;' })); @@ -1644,7 +1576,7 @@ moduleFor( this.assertElement(this.firstChild, { tagName: 'div', content: '', - attrs: { style: 'width: 60px;' } + attrs: { style: 'width: 60px;' }, }); } } @@ -1657,7 +1589,7 @@ if (!EmberDev.runningProdBuild) { ['@test specifying
generates a warning']() { let userValue = 'width: 42px'; this.render('
', { - userValue + userValue, }); this.assertStyleWarning(userValue); @@ -1665,16 +1597,16 @@ if (!EmberDev.runningProdBuild) { ['@test specifying `attributeBindings: ["style"]` generates a warning']() { let FooBarComponent = Component.extend({ - attributeBindings: ['style'] + attributeBindings: ['style'], }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: 'hello' + template: 'hello', }); let userValue = 'width: 42px'; this.render('{{foo-bar style=userValue}}', { - userValue + userValue, }); this.assertStyleWarning(userValue); @@ -1682,7 +1614,7 @@ if (!EmberDev.runningProdBuild) { ['@test specifying `
` works properly without a warning']() { this.render('
', { - userValue: 'width: 42px' + userValue: 'width: 42px', }); this.assertNoWarning(); @@ -1690,7 +1622,7 @@ if (!EmberDev.runningProdBuild) { ['@test specifying `
` works properly with a SafeString']() { this.render('
', { - userValue: new SafeString('width: 42px') + userValue: new SafeString('width: 42px'), }); this.assertNoWarning(); @@ -1698,7 +1630,7 @@ if (!EmberDev.runningProdBuild) { ['@test null value do not generate htmlsafe warning']() { this.render('
', { - userValue: null + userValue: null, }); this.assertNoWarning(); @@ -1712,7 +1644,7 @@ if (!EmberDev.runningProdBuild) { ['@test no warnings are triggered when using `-html-safe`']() { this.render('
', { - userValue: 'width: 42px' + userValue: 'width: 42px', }); this.assertNoWarning(); @@ -1720,7 +1652,7 @@ if (!EmberDev.runningProdBuild) { ['@test no warnings are triggered when a safe string is quoted']() { this.render('
', { - userValue: new SafeString('width: 42px') + userValue: new SafeString('width: 42px'), }); this.assertNoWarning(); @@ -1729,7 +1661,7 @@ if (!EmberDev.runningProdBuild) { ['@test binding warning is triggered when an unsafe string is quoted']() { let userValue = 'width: 42px'; this.render('
', { - userValue + userValue, }); this.assertStyleWarning(userValue); @@ -1738,7 +1670,7 @@ if (!EmberDev.runningProdBuild) { ['@test binding warning is triggered when a safe string for a complete property is concatenated in place']() { let userValue = 'width: 42px'; this.render('
', { - userValue: new SafeString('width: 42px') + userValue: new SafeString('width: 42px'), }); this.assertStyleWarning(`color: green; ${userValue}`); @@ -1747,7 +1679,7 @@ if (!EmberDev.runningProdBuild) { ['@test binding warning is triggered when a safe string for a value is concatenated in place']() { let userValue = '42px'; this.render('
', { - userValue: new SafeString(userValue) + userValue: new SafeString(userValue), }); this.assertStyleWarning(`color: green; width: ${userValue}`); @@ -1755,12 +1687,9 @@ if (!EmberDev.runningProdBuild) { ['@test binding warning is triggered when a safe string for a property name is concatenated in place']() { let userValue = 'width'; - this.render( - '
', - { - userProperty: new SafeString(userValue) - } - ); + this.render('
', { + userProperty: new SafeString(userValue), + }); this.assertStyleWarning(`color: green; ${userValue}: 42px`); } diff --git a/packages/ember-glimmer/tests/integration/custom-component-manager-test.js b/packages/ember-glimmer/tests/integration/custom-component-manager-test.js index 978f802b499..3e391827f6a 100644 --- a/packages/ember-glimmer/tests/integration/custom-component-manager-test.js +++ b/packages/ember-glimmer/tests/integration/custom-component-manager-test.js @@ -34,14 +34,14 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { return component; }, - update() {} + update() {}, }, overrides ); this.owner.register(`component-manager:${MANAGER_ID}`, options, { singleton: true, - instantiate: false + instantiate: false, }); } @@ -52,12 +52,12 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { this.registerCustomComponentManager(); let ComponentClass = CustomComponent.extend({ - greeting: 'hello' + greeting: 'hello', }); this.registerComponent('foo-bar', { template: `

{{greeting}} world

`, - ComponentClass + ComponentClass, }); this.render('{{foo-bar}}'); @@ -71,23 +71,23 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { // not the component instance. ['@test it can customize the template context']() { let customContext = { - greeting: 'goodbye' + greeting: 'goodbye', }; this.registerCustomComponentManager({ getContext() { return customContext; - } + }, }); let ComponentClass = CustomComponent.extend({ greeting: 'hello', - count: 1234 + count: 1234, }); this.registerComponent('foo-bar', { template: `

{{greeting}} world {{count}}

`, - ComponentClass + ComponentClass, }); this.render('{{foo-bar}}'); @@ -103,18 +103,18 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { this.registerCustomComponentManager({ create({ ComponentClass, args }) { return ComponentClass.create({ args }); - } + }, }); let ComponentClass = CustomComponent.extend({ salutation: computed('args.firstName', 'args.lastName', function() { return this.get('args.firstName') + ' ' + this.get('args.lastName'); - }) + }), }); this.registerComponent('foo-bar', { template: `

{{salutation}}

`, - ComponentClass + ComponentClass, }); this.render('{{foo-bar firstName="Yehuda" lastName="Katz"}}'); @@ -130,23 +130,23 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { update(component, args) { set(component, 'args', args); - } + }, }); let ComponentClass = CustomComponent.extend({ salutation: computed('args.firstName', 'args.lastName', function() { return this.get('args.firstName') + ' ' + this.get('args.lastName'); - }) + }), }); this.registerComponent('foo-bar', { template: `

{{salutation}}

`, - ComponentClass + ComponentClass, }); this.render('{{foo-bar firstName=firstName lastName=lastName}}', { firstName: 'Yehuda', - lastName: 'Katz' + lastName: 'Katz', }); this.assertHTML(strip`

Yehuda Katz

`); @@ -154,56 +154,41 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { this.runTask(() => setProperties(this.context, { firstName: 'Chad', - lastName: 'Hietala' + lastName: 'Hietala', }) ); this.assertHTML(strip`

Chad Hietala

`); } - [`@test custom components appear in parent view's childViews array`]( - assert - ) { + [`@test custom components appear in parent view's childViews array`](assert) { this.registerCustomComponentManager(); let ComponentClass = CustomComponent.extend({ - isCustomComponent: true + isCustomComponent: true, }); this.registerComponent('turbo-component', { template: `

turbo

`, - ComponentClass + ComponentClass, }); this.registerComponent('curly-component', { template: `
curly
`, ComponentClass: Component.extend({ - isClassicComponent: true - }) + isClassicComponent: true, + }), }); - this.render( - '{{#if showTurbo}}{{turbo-component}}{{/if}} {{curly-component}}', - { - showTurbo: true - } - ); + this.render('{{#if showTurbo}}{{turbo-component}}{{/if}} {{curly-component}}', { + showTurbo: true, + }); let { childViews } = this.context; - assert.equal( - childViews.length, - 2, - 'root component has two child views' - ); - assert.ok( - childViews[0].isCustomComponent, - 'first child view is custom component' - ); - assert.ok( - childViews[1].isClassicComponent, - 'second child view is classic component' - ); + assert.equal(childViews.length, 2, 'root component has two child views'); + assert.ok(childViews[0].isCustomComponent, 'first child view is custom component'); + assert.ok(childViews[1].isClassicComponent, 'second child view is classic component'); this.runTask(() => set(this.context, 'showTurbo', false)); @@ -215,39 +200,26 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { 1, "turbo component is removed from parent's child views array" ); - assert.ok( - childViews[0].isClassicComponent, - 'first child view is classic component' - ); + assert.ok(childViews[0].isClassicComponent, 'first child view is classic component'); this.runTask(() => set(this.context, 'showTurbo', true)); childViews = this.context.childViews; - assert.equal( - childViews.length, - 2, - 'root component has two child views' - ); - assert.ok( - childViews[0].isClassicComponent, - 'first child view is classic component' - ); - assert.ok( - childViews[1].isCustomComponent, - 'second child view is custom component' - ); + assert.equal(childViews.length, 2, 'root component has two child views'); + assert.ok(childViews[0].isClassicComponent, 'first child view is classic component'); + assert.ok(childViews[1].isCustomComponent, 'second child view is custom component'); } ['@test can invoke classic components in custom components'](assert) { this.registerCustomComponentManager(); let ComponentClass = CustomComponent.extend({ - isCustomComponent: true + isCustomComponent: true, }); this.registerComponent('turbo-component', { template: `

turbo

{{curly-component}}`, - ComponentClass + ComponentClass, }); let classicComponent; @@ -260,29 +232,26 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { classicComponent = this; }, - isClassicComponent: true - }) + isClassicComponent: true, + }), }); this.render('{{turbo-component}}'); this.assertElement(this.firstChild, { tagName: 'P', - content: 'turbo' + content: 'turbo', }); this.assertComponentElement(this.firstChild.nextSibling, { tagName: 'DIV', - content: '
curly
' + content: '
curly
', }); let { childViews } = this.context; assert.equal(childViews.length, 1, 'root component has one child view'); - assert.ok( - childViews[0].isCustomComponent, - 'root child view is custom component' - ); + assert.ok(childViews[0].isCustomComponent, 'root child view is custom component'); let customComponent = childViews[0]; @@ -293,11 +262,7 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { ); childViews = getChildViews(customComponent); - assert.equal( - childViews.length, - 1, - 'custom component has one child view' - ); + assert.equal(childViews.length, 1, 'custom component has one child view'); assert.ok( childViews[0].isClassicComponent, 'custom component child view is classic component' diff --git a/packages/ember-glimmer/tests/integration/event-dispatcher-test.js b/packages/ember-glimmer/tests/integration/event-dispatcher-test.js index 7063264cbdd..4ac575ef3c5 100644 --- a/packages/ember-glimmer/tests/integration/event-dispatcher-test.js +++ b/packages/ember-glimmer/tests/integration/event-dispatcher-test.js @@ -4,7 +4,7 @@ import { instrumentationSubscribe, instrumentationReset, run, - getCurrentRunLoop + getCurrentRunLoop, } from 'ember-metal'; import { EMBER_IMPROVED_INSTRUMENTATION } from 'ember/features'; @@ -27,9 +27,9 @@ moduleFor( ComponentClass: Component.extend({ change(event) { receivedEvent = event; - } + }, }), - template: `` + template: ``, }); this.render(`{{x-foo}}`); @@ -46,16 +46,16 @@ moduleFor( ComponentClass: Component.extend({ change(event) { receivedEvent = event; - } + }, }), - template: `{{yield}}` + template: `{{yield}}`, }); this.registerComponent('x-bar', { ComponentClass: Component.extend({ - change() {} + change() {}, }), - template: `` + template: ``, }); this.render(`{{#x-foo}}{{x-bar}}{{/x-foo}}`); @@ -72,18 +72,18 @@ moduleFor( ComponentClass: Component.extend({ change() { hasReceivedEvent = true; - } + }, }), - template: `{{yield}}` + template: `{{yield}}`, }); this.registerComponent('x-bar', { ComponentClass: Component.extend({ change() { return false; - } + }, }), - template: `` + template: ``, }); this.render(`{{#x-foo}}{{x-bar}}{{/x-foo}}`); @@ -97,9 +97,9 @@ moduleFor( ComponentClass: Component.extend({ change() { assert.ok(getCurrentRunLoop(), 'a run loop should have started'); - } + }, }), - template: `` + template: ``, }); this.render(`{{x-foo}}`); @@ -128,9 +128,9 @@ moduleFor( ComponentClass: Component.extend({ myEvent() { assert.ok(true, 'custom event was triggered'); - } + }, }), - template: `

Hello!

` + template: `

Hello!

`, }); this.render(`{{x-foo}}`); @@ -143,15 +143,8 @@ moduleFor( // this.$().append('
'); this.dispatcher.setup({ myevent: 'myEvent' }, '#app'); - assert.ok( - this.$('#app').hasClass('ember-application'), - 'custom rootElement was used' - ); - assert.equal( - this.dispatcher.rootElement, - '#app', - 'the dispatchers rootElement was updated' - ); + assert.ok(this.$('#app').hasClass('ember-application'), 'custom rootElement was used'); + assert.equal(this.dispatcher.rootElement, '#app', 'the dispatchers rootElement was updated'); } ['@test default events can be disabled via `customEvents`'](assert) { @@ -169,10 +162,10 @@ moduleFor( doubleClick() { assert.ok(true, 'a non-disabled event is still handled properly'); - } + }, }), - template: `

Hello!

` + template: `

Hello!

`, }); this.render(`{{x-foo}}`); @@ -205,9 +198,9 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { ComponentClass: Component.extend({ click() { clicked++; - } + }, }), - template: `

hello

` + template: `

hello

`, }); this.render(`{{x-foo}}`); @@ -225,7 +218,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { after() { clickInstrumented++; assert.equal(clicked, 2, 'invoked after event is handled'); - } + }, }); let keypressInstrumented = 0; @@ -235,18 +228,14 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { }, after() { keypressInstrumented++; - } + }, }); this.$('div').trigger('click'); this.$('div').trigger('change'); assert.equal(clicked, 2, 'precond - The click handler was invoked'); assert.equal(clickInstrumented, 2, 'The click was instrumented'); - assert.strictEqual( - keypressInstrumented, - 0, - 'The keypress was not instrumented' - ); + assert.strictEqual(keypressInstrumented, 0, 'The keypress was not instrumented'); } } ); @@ -262,8 +251,8 @@ if (canDataTransfer) { ComponentClass: Component.extend({ drop(event) { receivedEvent = event; - } - }) + }, + }), }); this.render(`{{x-foo}}`); diff --git a/packages/ember-glimmer/tests/integration/helpers/-class-test.js b/packages/ember-glimmer/tests/integration/helpers/-class-test.js index 8af88a213f9..98217e3268f 100644 --- a/packages/ember-glimmer/tests/integration/helpers/-class-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/-class-test.js @@ -8,33 +8,33 @@ moduleFor( ['@test casts binding to dasherized class']() { this.registerComponent('foo-bar', { template: '' }); this.render(`{{foo-bar class=(-class someTruth "someTruth")}}`, { - someTruth: true + someTruth: true, }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); this.runTask(() => set(this.context, 'someTruth', false)); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); this.runTask(() => set(this.context, 'someTruth', true)); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); } @@ -42,34 +42,34 @@ moduleFor( this.registerComponent('foo-bar', { template: '' }); this.render(`{{foo-bar class=(-class model.someTruth "someTruth")}}`, { model: { - someTruth: true - } + someTruth: true, + }, }); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); this.runTask(() => this.rerender()); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); this.runTask(() => set(this.context, 'model.someTruth', false)); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('ember-view') } + attrs: { class: classes('ember-view') }, }); this.runTask(() => set(this.context, 'model', { someTruth: true })); this.assertComponentElement(this.firstChild, { tagName: 'div', - attrs: { class: classes('some-truth ember-view') } + attrs: { class: classes('some-truth ember-view') }, }); } } diff --git a/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js b/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js index 95c23a3dd3e..be47dbf93d8 100644 --- a/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js @@ -3,7 +3,7 @@ import { set, computed, instrumentationSubscribe, - instrumentationUnsubscribe + instrumentationUnsubscribe, } from 'ember-metal'; import { EMBER_IMPROVED_INSTRUMENTATION } from 'ember/features'; import { RenderingTest, moduleFor } from '../../utils/test-case'; @@ -35,23 +35,22 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { actions: { fireAction() { this.attrs.submit(actionParam); - } - } + }, + }, }); let OuterComponent = Component.extend({ - outerSubmit() {} + outerSubmit() {}, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: - '' + template: '', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.subscribe('interaction.ember-action', { @@ -60,7 +59,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { }, after(name, timestamp, payload) { afterParameters.push(payload.args); - } + }, }); this.render(`{{outer-component}}`); @@ -90,24 +89,23 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { actions: { fireAction() { this.attrs.submit(); - } - } + }, + }, }); let OuterComponent = Component.extend({ myProperty: 'outer-thing', - outerSubmit() {} + outerSubmit() {}, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: - '' + template: '', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.subscribe('interaction.ember-action', { @@ -116,7 +114,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { }, after(name, timestamp, payload) { afterParameters.push(payload.target.get('myProperty')); - } + }, }); this.render(`{{outer-component}}`); @@ -145,30 +143,29 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { actions: { fireAction() { actualReturnedValue = this.attrs.submit(); - } - } + }, + }, }); let OuterComponent = Component.extend({ outerSubmit() { return returnedValue; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: - '' + template: '', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.subscribe('interaction.ember-action', { before() {}, - after() {} + after() {}, }); this.render(`{{outer-component}}`); @@ -177,11 +174,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { this.$('#instrument-button').trigger('click'); }); - this.assert.equal( - actualReturnedValue, - returnedValue, - 'action can return to caller' - ); + this.assert.equal(actualReturnedValue, returnedValue, 'action can return to caller'); } } ); @@ -201,22 +194,22 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ outerSubmit() { outerActionCalled = true; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.render('{{outer-component}}'); @@ -230,10 +223,10 @@ moduleFor( ['@test an error is triggered when bound action function is undefined']() { this.registerComponent('inner-component', { - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { - template: '{{inner-component submit=(action somethingThatIsUndefined)}}' + template: '{{inner-component submit=(action somethingThatIsUndefined)}}', }); expectAssertion(() => { @@ -243,13 +236,13 @@ moduleFor( ['@test an error is triggered when bound action being passed in is a non-function']() { this.registerComponent('inner-component', { - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: Component.extend({ - nonFunctionThing: {} + nonFunctionThing: {}, }), - template: '{{inner-component submit=(action nonFunctionThing)}}' + template: '{{inner-component submit=(action nonFunctionThing)}}', }); expectAssertion(() => { @@ -260,11 +253,11 @@ moduleFor( ['@test [#12718] a nice error is shown when a bound action function is undefined and it is passed as attrs.foo']() { this.registerComponent('inner-component', { template: - '' + '', }); this.registerComponent('outer-component', { - template: '{{inner-component}}' + template: '{{inner-component}}', }); expectAssertion(() => { @@ -284,23 +277,23 @@ moduleFor( }, fireAction() { returnedValue = this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ outerSubmit() { return expectedValue; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.render('{{outer-component}}'); @@ -309,11 +302,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.equal( - returnedValue, - expectedValue, - 'action can return to caller' - ); + this.assert.equal(returnedValue, expectedValue, 'action can return to caller'); } ['@test action should be called on the correct scope']() { @@ -328,7 +317,7 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ @@ -339,17 +328,17 @@ moduleFor( isOuterComponent: true, outerSubmit() { actualComponent = this; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action outerSubmit)}}' + template: '{{inner-component submit=(action outerSubmit)}}', }); this.render('{{outer-component}}'); @@ -358,15 +347,8 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.equal( - actualComponent, - outerComponent, - 'action has the correct context' - ); - this.assert.ok( - actualComponent.isOuterComponent, - 'action has the correct context' - ); + this.assert.equal(actualComponent, outerComponent, 'action has the correct context'); + this.assert.ok(actualComponent.isOuterComponent, 'action has the correct context'); } ['@test arguments to action are passed, curry']() { @@ -385,7 +367,7 @@ moduleFor( }, fireAction() { this.attrs.submit(fourth); - } + }, }); let OuterComponent = Component.extend({ @@ -393,17 +375,17 @@ moduleFor( outerSubmit() { // eslint-disable-line no-unused-vars actualArgs = [...arguments]; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action (action outerSubmit "${first}") "${second}" third)}}` + template: `{{inner-component submit=(action (action outerSubmit "${first}") "${second}" third)}}`, }); this.render('{{outer-component}}'); @@ -431,7 +413,7 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ @@ -442,17 +424,17 @@ moduleFor( actions: { outerAction(incomingValue) { value = incomingValue; - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: '{{inner-component submit=(action "outerAction" this)}}' + template: '{{inner-component submit=(action "outerAction" this)}}', }); this.render('{{outer-component}}'); @@ -461,11 +443,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.strictEqual( - value, - component, - 'the component is passed at `this`' - ); + this.assert.strictEqual(value, component, 'the component is passed at `this`'); } ['@test arguments to action are bound']() { @@ -482,7 +460,7 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ @@ -493,17 +471,17 @@ moduleFor( value: '', outerSubmit(incomingValue) { actualArg = incomingValue; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action outerSubmit value)}}` + template: `{{inner-component submit=(action outerSubmit value)}}`, }); this.render('{{outer-component}}'); @@ -512,11 +490,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.strictEqual( - actualArg, - '', - 'action has the correct first arg' - ); + this.assert.strictEqual(actualArg, '', 'action has the correct first arg'); this.runTask(() => { outerComponent.set('value', value); @@ -526,11 +500,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.strictEqual( - actualArg, - value, - 'action has the correct first arg' - ); + this.assert.strictEqual(actualArg, value, 'action has the correct first arg'); } ['@test array arguments are passed correctly to action']() { @@ -552,7 +522,7 @@ moduleFor( }, fireAction() { this.attrs.submit(second, third); - } + }, }); let OuterComponent = Component.extend({ @@ -564,17 +534,17 @@ moduleFor( actualFirst = incomingFirst; actualSecond = incomingSecond; actualThird = incomingThird; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action outerSubmit first)}}` + template: `{{inner-component submit=(action outerSubmit first)}}`, }); this.render('{{outer-component}}'); @@ -589,11 +559,7 @@ moduleFor( }); this.assert.equal(actualFirst, first, 'action has the correct first arg'); - this.assert.equal( - actualSecond, - second, - 'action has the correct second arg' - ); + this.assert.equal(actualSecond, second, 'action has the correct second arg'); this.assert.equal(actualThird, third, 'action has the correct third arg'); } @@ -610,7 +576,7 @@ moduleFor( }, fireAction() { this.attrs.submit(newValue); - } + }, }); let OuterComponent = Component.extend({ @@ -618,17 +584,17 @@ moduleFor( this._super(...arguments); outerComponent = this; }, - outerMut: 'patient peter' + outerMut: 'patient peter', }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action (mut outerMut))}}` + template: `{{inner-component submit=(action (mut outerMut))}}`, }); this.render('{{outer-component}}'); @@ -637,11 +603,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.equal( - outerComponent.get('outerMut'), - newValue, - 'mut value is set' - ); + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); } ['@test mut values can be wrapped in actions, are settable with a curry']() { @@ -657,7 +619,7 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ @@ -665,17 +627,17 @@ moduleFor( this._super(...arguments); outerComponent = this; }, - outerMut: 'patient peter' + outerMut: 'patient peter', }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action (mut outerMut) '${newValue}')}}` + template: `{{inner-component submit=(action (mut outerMut) '${newValue}')}}`, }); this.render('{{outer-component}}'); @@ -684,11 +646,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.equal( - outerComponent.get('outerMut'), - newValue, - 'mut value is set' - ); + this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set'); } ['@test action can create closures over actions']() { @@ -709,7 +667,7 @@ moduleFor( }, fireAction() { actualReturnedValue = this.attrs.submit(second); - } + }, }); let OuterComponent = Component.extend({ @@ -718,18 +676,18 @@ moduleFor( actualFirst = incomingFirst; actualSecond = incomingSecond; return returnValue; - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'outerAction' '${first}')}}` + template: `{{inner-component submit=(action 'outerAction' '${first}')}}`, }); this.render('{{outer-component}}'); @@ -738,11 +696,7 @@ moduleFor( innerComponent.fireAction(); }); - this.assert.equal( - actualReturnedValue, - returnValue, - 'return value is present' - ); + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); this.assert.equal(actualFirst, first, 'first argument is correct'); this.assert.equal(actualSecond, second, 'second argument is correct'); } @@ -756,18 +710,18 @@ moduleFor( // this is present to ensure `actions` hash is present // a different error is triggered if `actions` is missing // completely - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'doesNotExist')}}` + template: `{{inner-component submit=(action 'doesNotExist')}}`, }); expectAssertion(() => { @@ -782,12 +736,12 @@ moduleFor( this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'doesNotExist')}}` + template: `{{inner-component submit=(action 'doesNotExist')}}`, }); expectAssertion(() => { @@ -806,7 +760,7 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ @@ -815,20 +769,20 @@ moduleFor( actions: { outerAction() { actionCalled = true; - } - } + }, + }, }; - }) + }), }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'outerAction' target=otherComponent)}}` + template: `{{inner-component submit=(action 'outerAction' target=otherComponent)}}`, }); this.render('{{outer-component}}'); @@ -853,30 +807,30 @@ moduleFor( }, fireAction() { this.attrs.submit({ - readProp: newValue + readProp: newValue, }); - } + }, }); let OuterComponent = Component.extend({ outerContent: { - readProp: newValue + readProp: newValue, }, actions: { outerAction(incomingValue) { actualValue = incomingValue; - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'outerAction' value="readProp")}}` + template: `{{inner-component submit=(action 'outerAction' value="readProp")}}`, }); this.render('{{outer-component}}'); @@ -901,25 +855,25 @@ moduleFor( }, fireAction() { this.attrs.submit({ - readProp: newValue + readProp: newValue, }); - } + }, }); let OuterComponent = Component.extend({ outerAction(incomingValue) { actualValue = incomingValue; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action outerAction value="readProp")}}` + template: `{{inner-component submit=(action outerAction value="readProp")}}`, }); this.render('{{outer-component}}'); @@ -944,26 +898,26 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ objectArgument: { - readProp: newValue + readProp: newValue, }, outerAction(incomingValue) { actualValue = incomingValue; - } + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action outerAction objectArgument value="readProp")}}` + template: `{{inner-component submit=(action outerAction objectArgument value="readProp")}}`, }); this.render('{{outer-component}}'); @@ -1003,7 +957,7 @@ moduleFor( ); return submitReturnValue; - } + }, }); let MiddleComponent = Component.extend({}); @@ -1014,23 +968,23 @@ moduleFor( actualFirst = incomingFirst; actualSecond = incomingSecond; return returnValue; - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('middle-component', { ComponentClass: MiddleComponent, - template: `{{inner-component attrs-submit=attrs.submit submit=submit}}` + template: `{{inner-component attrs-submit=attrs.submit submit=submit}}`, }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{middle-component submit=(action 'outerAction' '${first}')}}` + template: `{{middle-component submit=(action 'outerAction' '${first}')}}`, }); this.render('{{outer-component}}'); @@ -1041,11 +995,7 @@ moduleFor( this.assert.equal(actualFirst, first, 'first argument is correct'); this.assert.equal(actualSecond, second, 'second argument is correct'); - this.assert.equal( - actualReturnedValue, - returnValue, - 'return value is present' - ); + this.assert.equal(actualReturnedValue, returnValue, 'return value is present'); } ['@test action should be called within a run loop']() { @@ -1059,25 +1009,25 @@ moduleFor( }, fireAction() { this.attrs.submit(); - } + }, }); let OuterComponent = Component.extend({ actions: { submit() { capturedRunLoop = getCurrentRunLoop(); - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action 'submit')}}` + template: `{{inner-component submit=(action 'submit')}}`, }); this.render('{{outer-component}}'); @@ -1101,7 +1051,7 @@ moduleFor( }, fireAction() { actionArgs = this.attrs.submit(4, 5, 6); - } + }, }); let OuterComponent = Component.extend({ @@ -1111,19 +1061,19 @@ moduleFor( [INVOKE]: (...args) => { invokableArgs = args; return this.foo; - } + }, }; - }) + }), }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: 'inner' + template: 'inner', }); this.registerComponent('outer-component', { ComponentClass: OuterComponent, - template: `{{inner-component submit=(action submitTask 1 2 3)}}` + template: `{{inner-component submit=(action submitTask 1 2 3)}}`, }); this.render('{{outer-component}}'); @@ -1144,13 +1094,13 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - '' + '', }); this.render('{{example-component}}'); @@ -1199,11 +1149,11 @@ moduleFor( didReceiveAttrs() { didReceiveAttrsFired++; - } + }, }); this.registerComponent('click-me', { - ComponentClass: ClickMeComponent + ComponentClass: ClickMeComponent, }); let outer; @@ -1214,14 +1164,14 @@ moduleFor( actions: { 'on-click': function() { this.incrementProperty('clicked'); - } + }, }, init() { this._super(); outer = this; this.set('onClick', () => this.incrementProperty('clicked')); - } + }, }); this.registerComponent('outer-component', { @@ -1232,7 +1182,7 @@ moduleFor( {{click-me id="string-action" onClick=(action "on-click")}} {{click-me id="function-action" onClick=(action onClick)}} {{click-me id="mut-action" onClick=(action (mut clicked))}} - ` + `, }); this.render('{{outer-component foo=foo}}', { foo: 1 }); diff --git a/packages/ember-glimmer/tests/integration/helpers/concat-test.js b/packages/ember-glimmer/tests/integration/helpers/concat-test.js index a81896f1678..0c8adc7f2d8 100644 --- a/packages/ember-glimmer/tests/integration/helpers/concat-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/concat-test.js @@ -11,7 +11,7 @@ moduleFor( ['@test it updates for bound arguments']() { this.render(`{{concat model.first model.second}}`, { - model: { first: 'one', second: 'two' } + model: { first: 'one', second: 'two' }, }); this.assertText('onetwo'); @@ -28,9 +28,7 @@ moduleFor( this.assertText('threefour'); - this.runTask(() => - set(this.context, 'model', { first: 'one', second: 'two' }) - ); + this.runTask(() => set(this.context, 'model', { first: 'one', second: 'two' })); this.assertText('onetwo'); } @@ -43,8 +41,8 @@ moduleFor( first: 'one', second: 'two', third: 'three', - fourth: 'four' - } + fourth: 'four', + }, } ); @@ -70,7 +68,7 @@ moduleFor( first: 'one', second: 'two', third: 'three', - fourth: 'four' + fourth: 'four', }); }); @@ -85,8 +83,8 @@ moduleFor( { model: { first: 'one', - second: 'two' - } + second: 'two', + }, } ); @@ -100,9 +98,7 @@ moduleFor( this.assertText('False'); - this.runTask(() => - set(this.context, 'model', { first: 'one', second: 'two' }) - ); + this.runTask(() => set(this.context, 'model', { first: 'one', second: 'two' })); this.assertText('Truthy!'); } diff --git a/packages/ember-glimmer/tests/integration/helpers/custom-helper-test.js b/packages/ember-glimmer/tests/integration/helpers/custom-helper-test.js index afeef1ec86b..dbf952ed31f 100644 --- a/packages/ember-glimmer/tests/integration/helpers/custom-helper-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/custom-helper-test.js @@ -33,8 +33,8 @@ moduleFor( this.render('{{hello.world}}', { hello: { - world: '' - } + world: '', + }, }); this.assertText(''); @@ -49,7 +49,7 @@ moduleFor( this.runTask(() => { set(this.context, 'hello', { - world: '' + world: '', }); }); @@ -60,13 +60,13 @@ moduleFor( this.registerHelper('hello', { compute() { return 'hello'; - } + }, }); this.registerHelper('hello-world', { compute() { return 'hello world'; - } + }, }); this.render('{{hello}} | {{hello-world}}'); @@ -80,7 +80,7 @@ moduleFor( ['@test throws if `this._super` is not called from `init`']() { this.registerHelper('hello-world', { - init() {} + init() {}, }); expectAssertion(() => { @@ -104,7 +104,7 @@ moduleFor( destroy() { destroyCount++; this._super(); - } + }, }); this.render('{{hello-world}}'); @@ -119,11 +119,7 @@ moduleFor( this.assertText('2'); - assert.strictEqual( - destroyCount, - 0, - 'destroy is not called on recomputation' - ); + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); } ['@test class-based helper with static arguments can recompute a new value']() { @@ -142,7 +138,7 @@ moduleFor( destroy() { destroyCount++; this._super(); - } + }, }); this.render('{{hello-world "whut"}}'); @@ -157,11 +153,7 @@ moduleFor( this.assertText('2'); - assert.strictEqual( - destroyCount, - 0, - 'destroy is not called on recomputation' - ); + assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation'); } ['@test helper params can be returned']() { @@ -169,12 +161,9 @@ moduleFor( return values; }); - this.render( - '{{#each (hello-world model) as |item|}}({{item}}){{/each}}', - { - model: ['bob'] - } - ); + this.render('{{#each (hello-world model) as |item|}}({{item}}){{/each}}', { + model: ['bob'], + }); this.assertText('(bob)'); } @@ -185,7 +174,7 @@ moduleFor( }); this.render(`{{get (hello-world model=model) 'name'}}`, { - model: { name: 'bob' } + model: { name: 'bob' }, }); this.assertText('bob'); @@ -200,7 +189,7 @@ moduleFor( }); this.render('{{hello-world model.name}}', { - model: { name: 'bob' } + model: { name: 'bob' }, }); this.assertText('bob-value'); @@ -238,11 +227,11 @@ moduleFor( compute([value]) { computeCount++; return `${value}-value`; - } + }, }); this.render('{{hello-world model.name}}', { - model: { name: 'bob' } + model: { name: 'bob' }, }); this.assertText('bob-value'); @@ -271,103 +260,73 @@ moduleFor( ['@test simple helper receives params, hash']() { this.registerHelper('hello-world', (_params, _hash) => { - return `params: ${JSON.stringify(_params)}, hash: ${JSON.stringify( - _hash - )}`; + return `params: ${JSON.stringify(_params)}, hash: ${JSON.stringify(_hash)}`; }); - this.render( - '{{hello-world model.name "rich" first=model.age last="sam"}}', - { - model: { - name: 'bob', - age: 42 - } - } - ); + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42, + }, + }); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => this.rerender()); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => set(this.context, 'model.name', 'sal')); - this.assertText( - 'params: ["sal","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => set(this.context, 'model.age', 28)); - this.assertText( - 'params: ["sal","rich"], hash: {"first":28,"last":"sam"}' - ); + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); this.runTask(() => set(this.context, 'model', { name: 'bob', age: 42 })); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); } ['@test class-based helper receives params, hash']() { this.registerHelper('hello-world', { compute(_params, _hash) { - return `params: ${JSON.stringify(_params)}, hash: ${JSON.stringify( - _hash - )}`; - } + return `params: ${JSON.stringify(_params)}, hash: ${JSON.stringify(_hash)}`; + }, }); - this.render( - '{{hello-world model.name "rich" first=model.age last="sam"}}', - { - model: { - name: 'bob', - age: 42 - } - } - ); + this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', { + model: { + name: 'bob', + age: 42, + }, + }); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => this.rerender()); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => set(this.context, 'model.name', 'sal')); - this.assertText( - 'params: ["sal","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}'); this.runTask(() => set(this.context, 'model.age', 28)); - this.assertText( - 'params: ["sal","rich"], hash: {"first":28,"last":"sam"}' - ); + this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}'); this.runTask(() => set(this.context, 'model', { name: 'bob', age: 42 })); - this.assertText( - 'params: ["bob","rich"], hash: {"first":42,"last":"sam"}' - ); + this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}'); } ['@test class-based helper usable in subexpressions']() { this.registerHelper('join-words', { compute(params) { return params.join(' '); - } + }, }); this.render( @@ -387,9 +346,7 @@ moduleFor( this.runTask(() => set(this.context, 'model.reason', 'Nickleback')); - this.assertText( - 'Who overcomes by Nickleback hath overcome but half his foe' - ); + this.assertText('Who overcomes by Nickleback hath overcome but half his foe'); this.runTask(() => set(this.context, 'model', { reason: 'force' })); @@ -434,7 +391,7 @@ moduleFor( ['@test class-based helper not usable with a block']() { this.registerHelper('some-helper', { - compute() {} + compute() {}, }); expectAssertion(() => { @@ -452,7 +409,7 @@ moduleFor( ['@test class-based helper not usable within element']() { this.registerHelper('some-helper', { - compute() {} + compute() {}, }); this.assert.throws(() => { @@ -470,7 +427,7 @@ moduleFor( }, compute() { return 'must define a compute'; - } + }, }); this.render(`{{some-helper}}`); @@ -491,13 +448,13 @@ moduleFor( }, compute() { return phrase; - } + }, }); this.registerHelper('join-words', { compute(params) { return params.join(' '); - } + }, }); this.render( @@ -538,17 +495,17 @@ moduleFor( }, compute() { return phrase; - } + }, }); this.registerHelper('join-words', { compute(params) { return params.join(' '); - } + }, }); this.registerComponent('some-component', { - template: '{{first}} {{second}} {{third}} {{fourth}} {{fifth}}' + template: '{{first}} {{second}} {{third}} {{fourth}} {{fifth}}', }); this.render( @@ -592,13 +549,13 @@ moduleFor( destroy() { destroyCount++; this._super(...arguments); - } + }, }); this.registerHelper('join-words', { compute(params) { return params.join(' '); - } + }, }); this.render( @@ -611,11 +568,7 @@ moduleFor( runDestroy(this.component); - assert.equal( - destroyCount, - 1, - 'destroy is called after a view is destroyed' - ); + assert.equal(destroyCount, 1, 'destroy is called after a view is destroyed'); } ['@test simple helper can be invoked manually via `owner.factoryFor(...).create().compute()']( @@ -628,11 +581,7 @@ moduleFor( let instance = this.owner.factoryFor('helper:some-helper').create(); - assert.equal( - typeof instance.compute, - 'function', - 'expected instance.compute to be present' - ); + assert.equal(typeof instance.compute, 'function', 'expected instance.compute to be present'); assert.equal(instance.compute(), 'lolol', 'can invoke `.compute`'); } @@ -641,16 +590,12 @@ moduleFor( compute() { assert.ok(true, 'some-helper helper invoked'); return 'lolol'; - } + }, }); let instance = this.owner.factoryFor('helper:some-helper').create(); - assert.equal( - typeof instance.compute, - 'function', - 'expected instance.compute to be present' - ); + assert.equal(typeof instance.compute, 'function', 'expected instance.compute to be present'); assert.equal(instance.compute(), 'lolol', 'can invoke `.compute`'); } } @@ -706,7 +651,7 @@ if (!EmberDev.runningProdBuild) { let compute = this.buildCompute(); this.registerHelper('test-helper', { - compute + compute, }); } } diff --git a/packages/ember-glimmer/tests/integration/helpers/element-action-test.js b/packages/ember-glimmer/tests/integration/helpers/element-action-test.js index ae7d594cdd6..058f8ca30a3 100644 --- a/packages/ember-glimmer/tests/integration/helpers/element-action-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/element-action-test.js @@ -1,11 +1,7 @@ import { RenderingTest, moduleFor } from '../../utils/test-case'; import { strip } from '../../utils/abstract-test-case'; import { Component } from '../../utils/helpers'; -import { - set, - instrumentationSubscribe, - instrumentationReset -} from 'ember-metal'; +import { set, instrumentationSubscribe, instrumentationReset } from 'ember-metal'; import { EMBER_IMPROVED_INSTRUMENTATION } from 'ember/features'; import { Object as EmberObject, A as emberA } from 'ember-runtime'; @@ -50,13 +46,13 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { let ExampleComponent = Component.extend({ actions: { - foo() {} - } + foo() {}, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); instrumentationSubscribe('interaction.ember-action', { @@ -65,44 +61,24 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { }, after(name, time, payload) { subscriberPayload = payload; - } + }, }); this.render('{{example-component}}'); - this.assert.equal( - subscriberCallCount, - 0, - 'subscriber has not been called' - ); + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); this.runTask(() => this.rerender()); - this.assert.equal( - subscriberCallCount, - 0, - 'subscriber has not been called' - ); + this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called'); this.runTask(() => { this.$('button').click(); }); - this.assert.equal( - subscriberCallCount, - 1, - 'subscriber has been called 1 time' - ); - this.assert.equal( - subscriberPayload.name, - 'foo', - 'subscriber called with correct name' - ); - this.assert.equal( - subscriberPayload.args[0], - 'bar', - 'subscriber called with correct args' - ); + this.assert.equal(subscriberCallCount, 1, 'subscriber has been called 1 time'); + this.assert.equal(subscriberPayload.name, 'foo', 'subscriber called with correct name'); + this.assert.equal(subscriberPayload.args[0], 'bar', 'subscriber called with correct args'); } } ); @@ -118,13 +94,13 @@ moduleFor( actions: { foo() { fooCallCount++; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -161,13 +137,13 @@ moduleFor( actions: { foo(thing) { fooArgs.push(thing); - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -192,11 +168,7 @@ moduleFor( this.$('button').click(); }); - this.assert.deepEqual( - fooArgs, - ['a', 'b'], - 'foo has been called with an updated value' - ); + this.assert.deepEqual(fooArgs, ['a', 'b'], 'foo has been called with an updated value'); } ['@test it should output a marker attribute with a guid']() { @@ -223,13 +195,13 @@ moduleFor( actions: { show() { showCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '
' + template: '
', }); this.render('{{example-component}}'); @@ -249,21 +221,21 @@ moduleFor( actions: { wat() { targetWatted = true; - } - } + }, + }, }); let InnerComponent = Component.extend({ actions: { wat() { innerWatted = true; - } - } + }, + }, }); this.registerComponent('inner-component', { ComponentClass: InnerComponent, - template: '{{yield}}' + template: '{{yield}}', }); this.registerComponent('target-component', { @@ -272,7 +244,7 @@ moduleFor( {{#inner-component}} {{/inner-component}} - ` + `, }); this.render('{{target-component}}'); @@ -292,20 +264,20 @@ moduleFor( actions: { wat() { targetWatted = true; - } - } + }, + }, }); let OtherComponent = Component.extend({}); this.registerComponent('target-component', { ComponentClass: TargetComponent, - template: '{{yield this}}' + template: '{{yield this}}', }); this.registerComponent('other-component', { ComponentClass: OtherComponent, - template: 'Wat?' + template: 'Wat?', }); this.render(strip` @@ -329,13 +301,13 @@ moduleFor( let first = { edit() { firstEdit++; - } + }, }; let second = { edit() { secondEdit++; - } + }, }; let ExampleComponent = Component.extend({ @@ -343,12 +315,12 @@ moduleFor( this._super(...arguments); component = this; }, - theTarget: first + theTarget: first, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'Edit' + template: 'Edit', }); this.render('{{example-component}}'); @@ -382,14 +354,14 @@ moduleFor( }, shortcut() { shortcutHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - 'click me
click me too
' + 'click me
click me too
', }); this.render('{{example-component}}'); @@ -398,11 +370,7 @@ moduleFor( this.$('a[data-ember-action]').trigger('click', { altKey: true }); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the event handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); this.runTask(() => { this.$('div[data-ember-action]').trigger('click', { ctrlKey: true }); @@ -428,14 +396,14 @@ moduleFor( }, shortcut() { shortcutHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - 'click me
click me too
' + 'click me
click me too
', }); this.render('{{example-component}}'); @@ -444,11 +412,7 @@ moduleFor( this.$('a[data-ember-action]').trigger('click', { altKey: true }); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the event handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); this.runTask(() => { this.$('div[data-ember-action]').trigger('click', { ctrlKey: true }); @@ -474,14 +438,13 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - 'click me' + template: 'click me', }); this.render('{{example-component}}'); @@ -490,11 +453,7 @@ moduleFor( this.$('a[data-ember-action]').trigger('click', { altKey: true }); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the event handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); editHandlerWasCalled = false; @@ -506,11 +465,7 @@ moduleFor( this.$('div[data-ember-action]').click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the event handler was not called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the event handler was not called'); } ['@test should be able to use action more than once for the same event within a view']() { @@ -530,17 +485,17 @@ moduleFor( }, delete() { deleteHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - 'editdelete' + 'editdelete', }); this.render('{{example-component}}'); @@ -549,16 +504,8 @@ moduleFor( this.$('#edit').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the edit action was called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); this.assert.equal( originalHandlerWasCalled, true, @@ -571,16 +518,8 @@ moduleFor( this.$('#delete').click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - true, - 'the delete action was called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); this.assert.equal( originalHandlerWasCalled, true, @@ -593,21 +532,9 @@ moduleFor( this.wrap(component.element).click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); - this.assert.equal( - originalHandlerWasCalled, - true, - 'the click handler was called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); } ['@test the event should not bubble if `bubbles=false` is passed']() { @@ -627,17 +554,17 @@ moduleFor( }, delete() { deleteHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - 'editdelete' + 'editdelete', }); this.render('{{example-component}}'); @@ -646,21 +573,9 @@ moduleFor( this.$('#edit').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the edit action was called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); - this.assert.equal( - originalHandlerWasCalled, - false, - 'the click handler was not called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; @@ -668,21 +583,9 @@ moduleFor( this.$('#delete').click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - true, - 'the delete action was called' - ); - this.assert.equal( - originalHandlerWasCalled, - false, - 'the click handler was not called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; @@ -690,21 +593,9 @@ moduleFor( this.wrap(component.element).click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); - this.assert.equal( - originalHandlerWasCalled, - true, - 'the click handler was called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); } ['@test the event should not bubble if `bubbles=false` is passed bound']() { @@ -725,17 +616,17 @@ moduleFor( }, delete() { deleteHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - 'editdelete' + 'editdelete', }); this.render('{{example-component}}'); @@ -744,21 +635,9 @@ moduleFor( this.$('#edit').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the edit action was called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); - this.assert.equal( - originalHandlerWasCalled, - false, - 'the click handler was not called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; @@ -766,21 +645,9 @@ moduleFor( this.$('#delete').click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - true, - 'the delete action was called' - ); - this.assert.equal( - originalHandlerWasCalled, - false, - 'the click handler was not called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false; @@ -788,21 +655,9 @@ moduleFor( this.wrap(component.element).click(); }); - this.assert.equal( - editHandlerWasCalled, - false, - 'the edit action was not called' - ); - this.assert.equal( - deleteHandlerWasCalled, - false, - 'the delete action was not called' - ); - this.assert.equal( - originalHandlerWasCalled, - true, - 'the click handler was called' - ); + this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called'); + this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); } ['@test the bubbling depends on the bound parameter']() { @@ -819,17 +674,16 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - 'edit' + template: 'edit', }); this.render('{{example-component}}'); @@ -838,16 +692,8 @@ moduleFor( this.$('#edit').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the edit action was called' - ); - this.assert.equal( - originalHandlerWasCalled, - false, - 'the click handler was not called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called'); editHandlerWasCalled = originalHandlerWasCalled = false; @@ -859,16 +705,8 @@ moduleFor( this.$('#edit').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the edit action was called' - ); - this.assert.equal( - originalHandlerWasCalled, - true, - 'the click handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the edit action was called'); + this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called'); } ['@test it should work properly in an #each block']() { @@ -879,14 +717,13 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - '{{#each items as |item|}}click me{{/each}}' + template: '{{#each items as |item|}}click me{{/each}}', }); this.render('{{example-component}}'); @@ -895,11 +732,7 @@ moduleFor( this.$('a').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the event handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); } ['@test it should work properly in a {{#with foo as |bar|}} block']() { @@ -910,14 +743,14 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - '{{#with something as |somethingElse|}}click me{{/with}}' + '{{#with something as |somethingElse|}}click me{{/with}}', }); this.render('{{example-component}}'); @@ -926,87 +759,52 @@ moduleFor( this.$('a').click(); }); - this.assert.equal( - editHandlerWasCalled, - true, - 'the event handler was called' - ); + this.assert.equal(editHandlerWasCalled, true, 'the event handler was called'); } - ['@test it should unregister event handlers when an element action is removed']( - assert - ) { + ['@test it should unregister event handlers when an element action is removed'](assert) { let ExampleComponent = Component.extend({ actions: { - edit() {} - } + edit() {}, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - '{{#if isActive}}click me{{/if}}' + template: '{{#if isActive}}click me{{/if}}', }); this.render('{{example-component isActive=isActive}}', { - isActive: true + isActive: true, }); - assert.equal( - this.$('a[data-ember-action]').length, - 1, - 'The element is rendered' - ); + assert.equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); let actionId; actionId = getActionIds(this.$('a[data-ember-action]')[0])[0]; - assert.ok( - ActionManager.registeredActions[actionId], - 'An action is registered' - ); + assert.ok(ActionManager.registeredActions[actionId], 'An action is registered'); this.runTask(() => this.rerender()); - assert.equal( - this.$('a[data-ember-action]').length, - 1, - 'The element is still present' - ); + assert.equal(this.$('a[data-ember-action]').length, 1, 'The element is still present'); - assert.ok( - ActionManager.registeredActions[actionId], - 'The action is still registered' - ); + assert.ok(ActionManager.registeredActions[actionId], 'The action is still registered'); this.runTask(() => set(this.context, 'isActive', false)); - assert.strictEqual( - this.$('a[data-ember-action]').length, - 0, - 'The element is removed' - ); + assert.strictEqual(this.$('a[data-ember-action]').length, 0, 'The element is removed'); - assert.ok( - !ActionManager.registeredActions[actionId], - 'The action is unregistered' - ); + assert.ok(!ActionManager.registeredActions[actionId], 'The action is unregistered'); this.runTask(() => set(this.context, 'isActive', true)); - assert.equal( - this.$('a[data-ember-action]').length, - 1, - 'The element is rendered' - ); + assert.equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered'); actionId = getActionIds(this.$('a[data-ember-action]')[0])[0]; - assert.ok( - ActionManager.registeredActions[actionId], - 'A new action is registered' - ); + assert.ok(ActionManager.registeredActions[actionId], 'A new action is registered'); } ['@test it should capture events from child elements and allow them to trigger the action']() { @@ -1016,13 +814,13 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '
' + template: '
', }); this.render('{{example-component}}'); @@ -1045,16 +843,16 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'click me' + template: 'click me', }); this.render('{{example-component}}'); @@ -1077,16 +875,16 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } + }, }, click() { originalHandlerWasCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'click me' + template: 'click me', }); this.render('{{example-component}}'); @@ -1095,14 +893,8 @@ moduleFor( this.$('a').click(); }); - this.assert.ok( - editHandlerWasCalled, - 'the child event handler was called' - ); - this.assert.notOk( - originalHandlerWasCalled, - 'the parent handler was not called' - ); + this.assert.ok(editHandlerWasCalled, 'the child event handler was called'); + this.assert.notOk(originalHandlerWasCalled, 'the parent handler was not called'); } ['@test it should allow "send" as the action name (#594)']() { @@ -1112,13 +904,13 @@ moduleFor( actions: { send() { sendHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'click me' + template: 'click me', }); this.render('{{example-component}}'); @@ -1144,8 +936,8 @@ moduleFor( edit(context) { passedTarget = this === targetThis; passedContext = context; - } - } + }, + }, }); let aContext; @@ -1154,12 +946,12 @@ moduleFor( init() { this._super(...arguments); aContext = this; - } + }, }); this.registerComponent('target-component', { ComponentClass: TargetComponent, - template: '{{yield this}}' + template: '{{yield this}}', }); this.registerComponent('example-component', { @@ -1168,7 +960,7 @@ moduleFor( {{#target-component as |aTarget|}} click me {{/target-component}} - ` + `, }); this.render('{{example-component}}'); @@ -1177,15 +969,8 @@ moduleFor( this.$('#edit').click(); }); - this.assert.ok( - passedTarget, - 'the action is called with the target as this' - ); - this.assert.strictEqual( - passedContext, - aContext, - 'the parameter is passed along' - ); + this.assert.ok(passedTarget, 'the action is called with the target as this'); + this.assert.strictEqual(passedContext, aContext, 'the parameter is passed along'); } ['@test it should only trigger actions for the event they were registered on']() { @@ -1195,13 +980,13 @@ moduleFor( actions: { edit() { editHandlerWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'click me' + template: 'click me', }); this.render('{{example-component}}'); @@ -1210,10 +995,7 @@ moduleFor( this.$('a').click(); }); - this.assert.ok( - editHandlerWasCalled, - 'the event handler was called on click' - ); + this.assert.ok(editHandlerWasCalled, 'the event handler was called on click'); editHandlerWasCalled = false; @@ -1221,10 +1003,7 @@ moduleFor( this.$('a').trigger('mouseover'); }); - this.assert.notOk( - editHandlerWasCalled, - 'the event handler was not called on mouseover' - ); + this.assert.notOk(editHandlerWasCalled, 'the event handler was not called on mouseover'); } ['@test it should allow multiple contexts to be specified']() { @@ -1237,13 +1016,13 @@ moduleFor( actions: { edit(...args) { passedContexts = args; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -1268,13 +1047,13 @@ moduleFor( actions: { edit(...args) { passedContexts = args; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -1302,13 +1081,13 @@ moduleFor( actions: { show() { showCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -1328,10 +1107,7 @@ moduleFor( assert.ok(event.defaultPrevented, 'should prevent default'); } } else { - assert.notOk( - showCalled, - `should not call action with ${prop}:${value}` - ); + assert.notOk(showCalled, `should not call action with ${prop}:${value}`); assert.notOk(event.defaultPrevented, 'should not prevent default'); } }; @@ -1355,13 +1131,13 @@ moduleFor( actions: { show() { showCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: '' + template: '', }); this.render('{{example-component}}'); @@ -1396,14 +1172,13 @@ moduleFor( scissors() { lastAction = 'scissors'; actionOrder.push('scissors'); - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - 'Whistle tips go woop woooop' + template: 'Whistle tips go woop woooop', }); this.render('{{example-component}}'); @@ -1421,11 +1196,7 @@ moduleFor( .click(); }); - test.assert.ok( - lastAction, - propertyValue, - `lastAction set to ${propertyValue}` - ); + test.assert.ok(lastAction, propertyValue, `lastAction set to ${propertyValue}`); }; testBoundAction('rock'); @@ -1452,7 +1223,7 @@ moduleFor( allactions: emberA([ { title: 'Rock', name: 'rock' }, { title: 'Paper', name: 'paper' }, - { title: 'Scissors', name: 'scissors' } + { title: 'Scissors', name: 'scissors' }, ]), actions: { rock() { @@ -1466,14 +1237,14 @@ moduleFor( scissors() { lastAction = 'scissors'; actionOrder.push('scissors'); - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - '{{#each allactions as |allaction|}}{{allaction.title}}{{/each}}' + '{{#each allactions as |allaction|}}{{allaction.title}}{{/each}}', }); this.render('{{example-component}}'); @@ -1487,11 +1258,7 @@ moduleFor( .click(); }); - test.assert.ok( - lastAction, - propertyValue, - `lastAction set to ${propertyValue}` - ); + test.assert.ok(lastAction, propertyValue, `lastAction set to ${propertyValue}`); }; testBoundAction('rock'); @@ -1515,12 +1282,12 @@ moduleFor( submit(actualArg) { incomingArg = actualArg; submitCalled = true; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: `Hi` + template: `Hi`, }); this.render('{{example-component}}'); @@ -1536,13 +1303,13 @@ moduleFor( ['@test a quoteless parameter that does not resolve to a value asserts']() { let ExampleComponent = Component.extend({ actions: { - ohNoeNotValid() {} - } + ohNoeNotValid() {}, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'Hi' + template: 'Hi', }); expectAssertion(() => { @@ -1561,8 +1328,8 @@ moduleFor( }, doubleClicked() { doubleClickActionWasCalled = true; - } - } + }, + }, }); this.registerComponent('example-component', { @@ -1571,7 +1338,7 @@ moduleFor( click me` + >click me`, }); this.render('{{example-component}}'); @@ -1586,22 +1353,19 @@ moduleFor( this.$('a').trigger('dblclick'); }); - this.assert.ok( - doubleClickActionWasCalled, - 'the doubleClicked action was called' - ); + this.assert.ok(doubleClickActionWasCalled, 'the doubleClicked action was called'); } ['@test it should respect preventDefault option if provided']() { let ExampleComponent = Component.extend({ actions: { - show() {} - } + show() {}, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: 'Hi' + template: 'Hi', }); this.render('{{example-component}}'); @@ -1612,11 +1376,7 @@ moduleFor( event = this.$('a').click()[0]; }); - this.assert.equal( - event.defaultPrevented, - false, - 'should not preventDefault' - ); + this.assert.equal(event.defaultPrevented, false, 'should not preventDefault'); } ['@test it should respect preventDefault option if provided bound']() { @@ -1629,14 +1389,13 @@ moduleFor( component = this; }, actions: { - show() {} - } + show() {}, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, - template: - 'Hi' + template: 'Hi', }); this.render('{{example-component}}'); @@ -1647,11 +1406,7 @@ moduleFor( event = this.$('a').trigger(event)[0]; }); - this.assert.equal( - event.defaultPrevented, - false, - 'should not preventDefault' - ); + this.assert.equal(event.defaultPrevented, false, 'should not preventDefault'); this.runTask(() => { component.set('shouldPreventDefault', true); @@ -1660,11 +1415,7 @@ moduleFor( // IE11 does not allow simulated events to have a valid `defaultPrevented` if (!isIE11) { - this.assert.equal( - event.defaultPrevented, - true, - 'should preventDefault' - ); + this.assert.equal(event.defaultPrevented, true, 'should preventDefault'); } } @@ -1676,8 +1427,8 @@ moduleFor( actions: { hey() { outerActionCalled = true; - } - } + }, + }, }); let MiddleComponent = Component.extend({}); @@ -1686,7 +1437,7 @@ moduleFor( click() { innerClickCalled = true; this.sendAction(); - } + }, }); this.registerComponent('outer-component', { @@ -1695,12 +1446,12 @@ moduleFor( {{#middle-component}} {{inner-component action="hey"}} {{/middle-component}} - ` + `, }); this.registerComponent('middle-component', { ComponentClass: MiddleComponent, - template: '{{yield}}' + template: '{{yield}}', }); this.registerComponent('inner-component', { @@ -1708,7 +1459,7 @@ moduleFor( template: strip` {{yield}} - ` + `, }); this.render('{{outer-component}}'); @@ -1717,10 +1468,7 @@ moduleFor( this.$('button').click(); }); - this.assert.ok( - outerActionCalled, - 'the action fired on the proper target' - ); + this.assert.ok(outerActionCalled, 'the action fired on the proper target'); this.assert.ok(innerClickCalled, 'the click was triggered'); } @@ -1732,13 +1480,13 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - '' + '', }); this.render('{{example-component}}'); @@ -1805,14 +1553,14 @@ moduleFor( toggleSelected() { actionCount++; this.toggleProperty('selected'); - } - } + }, + }, }); this.registerComponent('example-component', { ComponentClass: ExampleComponent, template: - '' + '', }); this.render('{{example-component}}'); diff --git a/packages/ember-glimmer/tests/integration/helpers/get-test.js b/packages/ember-glimmer/tests/integration/helpers/get-test.js index 0ebf4f6a35f..ca7a0cbf18d 100644 --- a/packages/ember-glimmer/tests/integration/helpers/get-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/get-test.js @@ -6,12 +6,9 @@ moduleFor( 'Helpers test: {{get}}', class extends RenderingTest { ['@test should be able to get an object value with a static key']() { - this.render( - `[{{get colors 'apple'}}] [{{if true (get colors 'apple')}}]`, - { - colors: { apple: 'red' } - } - ); + this.render(`[{{get colors 'apple'}}] [{{if true (get colors 'apple')}}]`, { + colors: { apple: 'red' }, + }); this.assertText('[red] [red]'); @@ -25,7 +22,7 @@ moduleFor( this.runTask(() => set(this.context, 'colors', { - apple: 'red' + apple: 'red', }) ); @@ -33,16 +30,13 @@ moduleFor( } ['@test should be able to get an object value with nested static key']() { - this.render( - `[{{get colors "apple.gala"}}] [{{if true (get colors "apple.gala")}}]`, - { - colors: { - apple: { - gala: 'red and yellow' - } - } - } - ); + this.render(`[{{get colors "apple.gala"}}] [{{if true (get colors "apple.gala")}}]`, { + colors: { + apple: { + gala: 'red and yellow', + }, + }, + }); this.assertText('[red and yellow] [red and yellow]'); @@ -50,15 +44,11 @@ moduleFor( this.assertText('[red and yellow] [red and yellow]'); - this.runTask(() => - set(this.context, 'colors.apple.gala', 'yellow and red striped') - ); + this.runTask(() => set(this.context, 'colors.apple.gala', 'yellow and red striped')); this.assertText('[yellow and red striped] [yellow and red striped]'); - this.runTask(() => - set(this.context, 'colors', { apple: { gala: 'red and yellow' } }) - ); + this.runTask(() => set(this.context, 'colors', { apple: { gala: 'red and yellow' } })); this.assertText('[red and yellow] [red and yellow]'); } @@ -69,8 +59,8 @@ moduleFor( items: { 1: 'First', 2: 'Second', - 3: 'Third' - } + 3: 'Third', + }, }); this.assertText('[First][Second][Third]'); @@ -83,16 +73,14 @@ moduleFor( this.assertText('[Qux][Second][Third]'); - this.runTask(() => - set(this.context, 'items', { 1: 'First', 2: 'Second', 3: 'Third' }) - ); + this.runTask(() => set(this.context, 'items', { 1: 'First', 2: 'Second', 3: 'Third' })); this.assertText('[First][Second][Third]'); } ['@test should be able to get an array value with a number']() { this.render(`[{{get numbers 0}}][{{get numbers 1}}][{{get numbers 2}}]`, { - numbers: [1, 2, 3] + numbers: [1, 2, 3], }); this.assertText('[1][2][3]'); @@ -111,17 +99,14 @@ moduleFor( } ['@test should be able to get an object value with a path evaluating to a number']() { - this.render( - `{{#each indexes as |index|}}[{{get items index}}]{{/each}}`, - { - indexes: [1, 2, 3], - items: { - 1: 'First', - 2: 'Second', - 3: 'Third' - } - } - ); + this.render(`{{#each indexes as |index|}}[{{get items index}}]{{/each}}`, { + indexes: [1, 2, 3], + items: { + 1: 'First', + 2: 'Second', + 3: 'Third', + }, + }); this.assertText('[First][Second][Third]'); @@ -133,20 +118,15 @@ moduleFor( this.assertText('[Qux][Second][Third]'); - this.runTask(() => - set(this.context, 'items', { 1: 'First', 2: 'Second', 3: 'Third' }) - ); + this.runTask(() => set(this.context, 'items', { 1: 'First', 2: 'Second', 3: 'Third' })); this.assertText('[First][Second][Third]'); } ['@test should be able to get an array value with a path evaluating to a number']() { - this.render( - `{{#each numbers as |num index|}}[{{get numbers index}}]{{/each}}`, - { - numbers: [1, 2, 3] - } - ); + this.render(`{{#each numbers as |num index|}}[{{get numbers index}}]{{/each}}`, { + numbers: [1, 2, 3], + }); this.assertText('[1][2][3]'); @@ -162,7 +142,7 @@ moduleFor( ['@test should be able to get an object value with a bound/dynamic key']() { this.render(`[{{get colors key}}] [{{if true (get colors key)}}]`, { colors: { apple: 'red', banana: 'yellow' }, - key: 'apple' + key: 'apple', }); this.assertText('[red] [red]'); @@ -196,11 +176,11 @@ moduleFor( colors: { apple: { gala: 'red and yellow', - mcintosh: 'red' + mcintosh: 'red', }, - banana: 'yellow' + banana: 'yellow', }, - key: 'apple.gala' + key: 'apple.gala', }); this.assertText('[red and yellow] [red and yellow]'); @@ -229,10 +209,10 @@ moduleFor( colors: { apple: { gala: 'red and yellow', - mcintosh: 'red' - } + mcintosh: 'red', + }, }, - key: 'apple.gala' + key: 'apple.gala', } ); @@ -242,15 +222,11 @@ moduleFor( this.assertText('[red and yellow] [red and yellow]'); - this.runTask(() => - set(this.context, 'colors.apple.gala', 'yellow and red striped') - ); + this.runTask(() => set(this.context, 'colors.apple.gala', 'yellow and red striped')); this.assertText('[yellow and red striped] [yellow and red striped]'); - this.runTask(() => - set(this.context, 'colors.apple.gala', 'yellow-redish') - ); + this.runTask(() => set(this.context, 'colors.apple.gala', 'yellow-redish')); this.assertText('[yellow-redish] [yellow-redish]'); @@ -258,8 +234,8 @@ moduleFor( set(this.context, 'colors', { apple: { gala: 'red and yellow', - mcintosh: 'red' - } + mcintosh: 'red', + }, }) ); @@ -272,7 +248,7 @@ moduleFor( { colors: { apple: 'red', banana: 'yellow' }, key: 'key1', - possibleKeys: { key1: 'apple', key2: 'banana' } + possibleKeys: { key1: 'apple', key2: 'banana' }, } ); @@ -297,9 +273,7 @@ moduleFor( this.assertText('[green] [green]'); - this.runTask(() => - set(this.context, 'colors', { apple: 'red', banana: 'yellow' }) - ); + this.runTask(() => set(this.context, 'colors', { apple: 'red', banana: 'yellow' })); this.assertText('[red] [red]'); } @@ -310,10 +284,10 @@ moduleFor( { possibleValues: { colors1: { apple: 'red', banana: 'yellow' }, - colors2: { apple: 'green', banana: 'purple' } + colors2: { apple: 'green', banana: 'purple' }, }, objectKey: 'colors1', - key: 'apple' + key: 'apple', } ); @@ -352,14 +326,14 @@ moduleFor( { possibleValues: { colors1: { apple: 'red', banana: 'yellow' }, - colors2: { apple: 'green', banana: 'purple' } + colors2: { apple: 'green', banana: 'purple' }, }, objectKey: 'colors1', possibleKeys: { key1: 'apple', - key2: 'banana' + key2: 'banana', }, - key: 'key1' + key: 'key1', } ); @@ -400,22 +374,19 @@ moduleFor( this._super(); fooBarInstance = this; this.mcintosh = 'red'; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: `{{yield (get colors mcintosh)}}` + template: `{{yield (get colors mcintosh)}}`, }); - this.render( - `{{#foo-bar colors=colors as |value|}}{{value}}{{/foo-bar}}`, - { - colors: { - red: 'banana' - } - } - ); + this.render(`{{#foo-bar colors=colors as |value|}}{{value}}{{/foo-bar}}`, { + colors: { + red: 'banana', + }, + }); this.assertText('banana'); @@ -439,12 +410,9 @@ moduleFor( } ['@test should handle object values as nulls']() { - this.render( - `[{{get colors 'apple'}}] [{{if true (get colors 'apple')}}]`, - { - colors: null - } - ); + this.render(`[{{get colors 'apple'}}] [{{if true (get colors 'apple')}}]`, { + colors: null, + }); this.assertText('[] []'); @@ -452,9 +420,7 @@ moduleFor( this.assertText('[] []'); - this.runTask(() => - set(this.context, 'colors', { apple: 'green', banana: 'purple' }) - ); + this.runTask(() => set(this.context, 'colors', { apple: 'green', banana: 'purple' })); this.assertText('[green] [green]'); @@ -467,9 +433,9 @@ moduleFor( this.render(`[{{get colors key}}] [{{if true (get colors key)}}]`, { colors: { apple: 'red', - banana: 'yellow' + banana: 'yellow', }, - key: null + key: null, }); this.assertText('[] []'); @@ -490,23 +456,18 @@ moduleFor( ['@test should handle object values and keys as nulls']() { this.render(`[{{get colors 'apple'}}] [{{if true (get colors key)}}]`, { colors: null, - key: null + key: null, }); this.assertText('[] []'); } - ['@test get helper value should be updatable using {{input}} and (mut) - static key']( - assert - ) { - this.render( - `{{input type='text' value=(mut (get source 'banana')) id='get-input'}}`, - { - source: { - banana: 'banana' - } - } - ); + ['@test get helper value should be updatable using {{input}} and (mut) - static key'](assert) { + this.render(`{{input type='text' value=(mut (get source 'banana')) id='get-input'}}`, { + source: { + banana: 'banana', + }, + }); assert.strictEqual(this.$('#get-input').val(), 'banana'); @@ -532,19 +493,14 @@ moduleFor( assert.strictEqual(this.$('#get-input').val(), 'banana'); } - ['@test get helper value should be updatable using {{input}} and (mut) - dynamic key']( - assert - ) { - this.render( - `{{input type='text' value=(mut (get source key)) id='get-input'}}`, - { - source: { - apple: 'apple', - banana: 'banana' - }, - key: 'banana' - } - ); + ['@test get helper value should be updatable using {{input}} and (mut) - dynamic key'](assert) { + this.render(`{{input type='text' value=(mut (get source key)) id='get-input'}}`, { + source: { + apple: 'apple', + banana: 'banana', + }, + key: 'banana', + }); assert.strictEqual(this.$('#get-input').val(), 'banana'); @@ -589,19 +545,16 @@ moduleFor( ['@test get helper value should be updatable using {{input}} and (mut) - dynamic nested key']( assert ) { - this.render( - `{{input type='text' value=(mut (get source key)) id='get-input'}}`, - { - source: { - apple: { - gala: 'gala', - mcintosh: 'mcintosh' - }, - banana: 'banana' + this.render(`{{input type='text' value=(mut (get source key)) id='get-input'}}`, { + source: { + apple: { + gala: 'gala', + mcintosh: 'mcintosh', }, - key: 'apple.mcintosh' - } - ); + banana: 'banana', + }, + key: 'apple.mcintosh', + }); assert.strictEqual(this.$('#get-input').val(), 'mcintosh'); @@ -620,10 +573,7 @@ moduleFor( ); assert.strictEqual(this.$('#get-input').val(), 'some value'); - assert.strictEqual( - get(this.context, 'source.apple.mcintosh'), - 'some value' - ); + assert.strictEqual(get(this.context, 'source.apple.mcintosh'), 'some value'); this.runTask(() => set(this.context, 'key', 'apple.gala')); @@ -636,10 +586,7 @@ moduleFor( ); assert.strictEqual(this.$('#get-input').val(), 'some other value'); - assert.strictEqual( - get(this.context, 'source.apple.gala'), - 'some other value' - ); + assert.strictEqual(get(this.context, 'source.apple.gala'), 'some other value'); this.runTask(() => set(this.context, 'key', 'banana')); @@ -652,19 +599,16 @@ moduleFor( ); assert.strictEqual(this.$('#get-input').val(), 'yet another value'); - assert.strictEqual( - get(this.context, 'source.banana'), - 'yet another value' - ); + assert.strictEqual(get(this.context, 'source.banana'), 'yet another value'); this.runTask(() => { set(this.context, 'key', 'apple.mcintosh'); set(this.context, 'source', { apple: { gala: 'gala', - mcintosh: 'mcintosh' + mcintosh: 'mcintosh', }, - banana: 'banana' + banana: 'banana', }); }); diff --git a/packages/ember-glimmer/tests/integration/helpers/hash-test.js b/packages/ember-glimmer/tests/integration/helpers/hash-test.js index 5894a18dd7e..e2406186363 100644 --- a/packages/ember-glimmer/tests/integration/helpers/hash-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/hash-test.js @@ -6,9 +6,7 @@ moduleFor( 'Helpers test: {{hash}}', class extends RenderingTest { ['@test returns a hash with the right key-value']() { - this.render( - `{{#with (hash name=\"Sergio\") as |person|}}{{person.name}}{{/with}}` - ); + this.render(`{{#with (hash name=\"Sergio\") as |person|}}{{person.name}}{{/with}}`); this.assertText('Sergio'); @@ -34,8 +32,8 @@ moduleFor( `{{#with (hash name=model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}`, { model: { - firstName: 'Marisa' - } + firstName: 'Marisa', + }, } ); @@ -60,8 +58,8 @@ moduleFor( { model: { firstName: 'Marisa', - lastName: 'Arbeo' - } + lastName: 'Arbeo', + }, } ); @@ -82,7 +80,7 @@ moduleFor( this.runTask(() => set(this.context, 'model', { firstName: 'Marisa', - lastName: 'Arbeo' + lastName: 'Arbeo', }) ); @@ -93,7 +91,7 @@ moduleFor( this.render( `{{#with (hash person=(hash name=model.firstName)) as |ctx|}}{{ctx.person.name}}{{/with}}`, { - model: { firstName: 'Balint' } + model: { firstName: 'Balint' }, } ); @@ -119,12 +117,12 @@ moduleFor( this._super(); fooBarInstance = this; this.model = { firstName: 'Chad' }; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: `{{yield (hash firstName=model.firstName)}}` + template: `{{yield (hash firstName=model.firstName)}}`, }); this.render(`{{#foo-bar as |values|}}{{values.firstName}}{{/foo-bar}}`); @@ -151,18 +149,18 @@ moduleFor( this._super(); fooBarInstance = this; this.model = { firstName: 'Chad' }; - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: `{{yield (hash firstName=model.firstName lastName=lastName)}}` + template: `{{yield (hash firstName=model.firstName lastName=lastName)}}`, }); this.render( `{{#foo-bar lastName=model.lastName as |values|}}{{values.firstName}} {{values.lastName}}{{/foo-bar}}`, { - model: { lastName: 'Hietala' } + model: { lastName: 'Hietala' }, } ); diff --git a/packages/ember-glimmer/tests/integration/helpers/input-test.js b/packages/ember-glimmer/tests/integration/helpers/input-test.js index bc7794976bd..92b0c6025a2 100644 --- a/packages/ember-glimmer/tests/integration/helpers/input-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/input-test.js @@ -18,58 +18,31 @@ class InputRenderingTest extends RenderingTest { } assertNotDisabled() { - this.assert.ok( - this.$('input').is(':not(:disabled)'), - 'The input is not disabled' - ); + this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled'); } assertInputId(expectedId) { - this.assert.equal( - this.inputID(), - expectedId, - 'the input id should be `expectedId`' - ); + this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`'); } assertSingleInput() { - this.assert.equal( - this.$('input').length, - 1, - 'A single text field was inserted' - ); + this.assert.equal(this.$('input').length, 1, 'A single text field was inserted'); } assertSingleCheckbox() { - this.assert.equal( - this.$('input[type=checkbox]').length, - 1, - 'A single checkbox is added' - ); + this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added'); } assertCheckboxIsChecked() { - this.assert.equal( - this.$input().prop('checked'), - true, - 'the checkbox is checked' - ); + this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked'); } assertCheckboxIsNotChecked() { - this.assert.equal( - this.$input().prop('checked'), - false, - 'the checkbox is not checked' - ); + this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked'); } assertValue(expected) { - this.assert.equal( - this.$input().val(), - expected, - `the input value should be ${expected}` - ); + this.assert.equal(this.$input().val(), expected, `the input value should be ${expected}`); } assertAttr(name, expected) { @@ -86,16 +59,8 @@ class InputRenderingTest extends RenderingTest { assertSelectionRange(start, end) { let input = this.$input()[0]; - this.assert.equal( - input.selectionStart, - start, - `the cursor start position should be ${start}` - ); - this.assert.equal( - input.selectionEnd, - end, - `the cursor end position should be ${end}` - ); + this.assert.equal(input.selectionStart, start, `the cursor start position should be ${start}`); + this.assert.equal(input.selectionEnd, end, `the cursor end position should be ${end}`); } triggerEvent(type, options) { @@ -171,7 +136,7 @@ moduleFor( maxlength: 10, minlength: 5, size: 20, - tabindex: 30 + tabindex: 30, } ); @@ -306,27 +271,23 @@ moduleFor( // this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) } - ['@test sends an action with `{{input enter="foo"}}` when is pressed']( - assert - ) { + ['@test sends an action with `{{input enter="foo"}}` when is pressed'](assert) { assert.expect(1); this.render(`{{input enter='foo'}}`, { actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keyup', { - keyCode: 13 + keyCode: 13, }); } - ['@test sends an action with `{{input key-press="foo"}}` is pressed']( - assert - ) { + ['@test sends an action with `{{input key-press="foo"}}` is pressed'](assert) { assert.expect(1); this.render(`{{input value=value key-press='foo'}}`, { @@ -335,29 +296,27 @@ moduleFor( actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keypress', { - keyCode: 65 + keyCode: 65, }); } - ['@test sends an action to the parent level when `bubbles=true` is provided']( - assert - ) { + ['@test sends an action to the parent level when `bubbles=true` is provided'](assert) { assert.expect(1); let ParentComponent = Component.extend({ change() { assert.ok(true, 'bubbled upwards'); - } + }, }); this.registerComponent('x-parent', { ComponentClass: ParentComponent, - template: `{{input bubbles=true}}` + template: `{{input bubbles=true}}`, }); this.render(`{{x-parent}}`); @@ -371,8 +330,8 @@ moduleFor( actions: { foo() { wasFocused = true; - } - } + }, + }, }); this.runTask(() => { @@ -389,66 +348,60 @@ moduleFor( actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keyup', { - keyCode: 13 + keyCode: 13, }); } - ['@test sends an action with `{{input escape-press="foo"}}` when is pressed']( - assert - ) { + ['@test sends an action with `{{input escape-press="foo"}}` when is pressed'](assert) { assert.expect(1); this.render(`{{input escape-press='foo'}}`, { actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keyup', { - keyCode: 27 + keyCode: 27, }); } - ['@test sends an action with `{{input key-down="foo"}}` when a key is pressed']( - assert - ) { + ['@test sends an action with `{{input key-down="foo"}}` when a key is pressed'](assert) { assert.expect(1); this.render(`{{input key-down='foo'}}`, { actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keydown', { - keyCode: 65 + keyCode: 65, }); } - ['@test sends an action with `{{input key-up="foo"}}` when a key is pressed']( - assert - ) { + ['@test sends an action with `{{input key-up="foo"}}` when a key is pressed'](assert) { assert.expect(1); this.render(`{{input key-up='foo'}}`, { actions: { foo() { assert.ok(true, 'action was triggered'); - } - } + }, + }, }); this.triggerEvent('keyup', { - keyCode: 65 + keyCode: 65, }); } @@ -486,7 +439,7 @@ moduleFor( this.render(`{{input type=(if isTruthy trueType falseType)}}`, { isTruthy: true, trueType: 'text', - falseType: 'password' + falseType: 'password', }); this.assertAttr('type', 'text'); @@ -506,16 +459,13 @@ moduleFor( ['@test GH16256 input macro does not modify params in place']() { this.registerComponent('my-input', { - template: `{{input type=inputType}}` + template: `{{input type=inputType}}`, }); - this.render( - `{{my-input inputType=firstType}}{{my-input inputType=secondType}}`, - { - firstType: 'password', - secondType: 'email' - } - ); + this.render(`{{my-input inputType=firstType}}{{my-input inputType=secondType}}`, { + firstType: 'password', + secondType: 'email', + }); let inputs = this.element.querySelectorAll('input'); this.assert.equal(inputs.length, 2, 'there are two inputs'); @@ -541,7 +491,7 @@ moduleFor( disabled: false, name: 'original-name', checked: false, - tabindex: 10 + tabindex: 10, } ); @@ -583,7 +533,7 @@ moduleFor( ['@test `value` property assertion']() { expectAssertion(() => { this.render(`{{input type="checkbox" value=value}}`, { - value: 'value' + value: 'value', }); }, /you must use `checked=/); } @@ -591,7 +541,7 @@ moduleFor( ['@test with a bound type']() { this.render(`{{input type=inputType checked=isChecked}}`, { inputType: 'checkbox', - isChecked: true + isChecked: true, }); this.assertSingleCheckbox(); @@ -647,14 +597,7 @@ moduleFor( `Helpers test: {{input type='text'}}`, class extends InputRenderingTest { ['@test null values']() { - let attributes = [ - 'disabled', - 'placeholder', - 'name', - 'maxlength', - 'size', - 'tabindex' - ]; + let attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex']; this.render( ` @@ -674,7 +617,7 @@ moduleFor( name: null, maxlength: null, size: null, - tabindex: null + tabindex: null, } ); @@ -733,7 +676,7 @@ moduleFor( 'min="-5" max="50" type="range" value="%x"', 'min="-5" max="50" value="%x" type="range"', 'value="%x" min="-5" max="50" type="range"', - 'value="%x" type="range" min="-5" max="50"' + 'value="%x" type="range" min="-5" max="50"', ].forEach(attrs => { moduleFor( `[GH#15675] Helpers test: {{input ${attrs}}}`, diff --git a/packages/ember-glimmer/tests/integration/helpers/loc-test.js b/packages/ember-glimmer/tests/integration/helpers/loc-test.js index a3bb131fb66..a8e9e92eb8e 100644 --- a/packages/ember-glimmer/tests/integration/helpers/loc-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/loc-test.js @@ -9,7 +9,7 @@ moduleFor( super(); setStrings({ 'Hello Friend': 'Hallo Freund', - Hello: 'Hallo, %@' + Hello: 'Hallo, %@', }); } @@ -22,41 +22,29 @@ moduleFor( this.render(`{{loc "Hiya buddy!"}}`); this.assertText('Hiya buddy!', 'the unlocalized string is correct'); this.runTask(() => this.rerender()); - this.assertText( - 'Hiya buddy!', - 'the unlocalized string is correct after rerender' - ); + this.assertText('Hiya buddy!', 'the unlocalized string is correct after rerender'); } ['@test it localizes a simple string']() { this.render(`{{loc "Hello Friend"}}`); this.assertText('Hallo Freund', 'the localized string is correct'); this.runTask(() => this.rerender()); - this.assertText( - 'Hallo Freund', - 'the localized string is correct after rerender' - ); + this.assertText('Hallo Freund', 'the localized string is correct after rerender'); } ['@test it takes passed formats into an account']() { this.render(`{{loc "%@, %@" "Hello" "Mr. Pitkin"}}`); this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct'); this.runTask(() => this.rerender()); - this.assertText( - 'Hello, Mr. Pitkin', - 'the formatted string is correct after rerender' - ); + this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct after rerender'); } ['@test it updates when bound params change']() { this.render(`{{loc simple}} - {{loc personal 'Mr. Pitkin'}}`, { simple: 'Hello Friend', - personal: 'Hello' + personal: 'Hello', }); - this.assertText( - 'Hallo Freund - Hallo, Mr. Pitkin', - 'the bound value is correct' - ); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); this.runTask(() => this.rerender()); this.assertText( @@ -65,32 +53,20 @@ moduleFor( ); this.runTask(() => set(this.context, 'simple', "G'day mate")); - this.assertText( - "G'day mate - Hallo, Mr. Pitkin", - 'the bound value is correct after update' - ); + this.assertText("G'day mate - Hallo, Mr. Pitkin", 'the bound value is correct after update'); this.runTask(() => set(this.context, 'simple', 'Hello Friend')); - this.assertText( - 'Hallo Freund - Hallo, Mr. Pitkin', - 'the bound value is correct after reset' - ); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after reset'); } ['@test it updates when nested bound params change']() { - this.render( - `{{loc greetings.simple}} - {{loc greetings.personal 'Mr. Pitkin'}}`, - { - greetings: { - simple: 'Hello Friend', - personal: 'Hello' - } - } - ); - this.assertText( - 'Hallo Freund - Hallo, Mr. Pitkin', - 'the bound value is correct' - ); + this.render(`{{loc greetings.simple}} - {{loc greetings.personal 'Mr. Pitkin'}}`, { + greetings: { + simple: 'Hello Friend', + personal: 'Hello', + }, + }); + this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct'); this.runTask(() => this.rerender()); this.assertText( @@ -107,7 +83,7 @@ moduleFor( this.runTask(() => set(this.context, 'greetings', { simple: 'Hello Friend', - personal: 'Hello' + personal: 'Hello', }) ); this.assertText( @@ -119,7 +95,7 @@ moduleFor( ['@test it can be overriden']() { this.registerHelper('loc', () => 'Yup'); this.render(`{{loc greeting}}`, { - greeting: 'Hello Friend' + greeting: 'Hello Friend', }); this.assertText('Yup', 'the localized string is correct'); } diff --git a/packages/ember-glimmer/tests/integration/helpers/log-test.js b/packages/ember-glimmer/tests/integration/helpers/log-test.js index ac88a71f555..a9402728f19 100644 --- a/packages/ember-glimmer/tests/integration/helpers/log-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/log-test.js @@ -38,7 +38,7 @@ moduleFor( ['@test correctly logs a property']() { this.render(`{{log value}}`, { - value: 'one' + value: 'one', }); this.assertLog(['one']); @@ -46,7 +46,7 @@ moduleFor( ['@test correctly logs multiple arguments']() { this.render(`{{log "my variable:" value}}`, { - value: 'one' + value: 'one', }); this.assertLog(['my variable:', 'one']); diff --git a/packages/ember-glimmer/tests/integration/helpers/mut-test.js b/packages/ember-glimmer/tests/integration/helpers/mut-test.js index 5785545f9c8..3e293b7b85f 100644 --- a/packages/ember-glimmer/tests/integration/helpers/mut-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/mut-test.js @@ -13,17 +13,17 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { bottom = this; - } + }, }), - template: '{{setMe}}' + template: '{{setMe}}', }); this.registerComponent('middle-mut', { - template: '{{bottom-mut setMe=value}}' + template: '{{bottom-mut setMe=value}}', }); this.render('{{middle-mut value=(mut val)}}', { - val: 12 + val: 12, }); this.assertText('12', 'the data propagated downwards'); @@ -33,40 +33,16 @@ moduleFor( this.runTask(() => bottom.attrs.setMe.update(13)); this.assertText('13', 'the set took effect'); - this.assert.strictEqual( - get(bottom, 'setMe'), - 13, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 13, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 13, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 13, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(this.context, 'val'), 13, 'the set propagated back up'); this.runTask(() => set(bottom, 'setMe', 14)); this.assertText('14', 'the set took effect'); - this.assert.strictEqual( - get(bottom, 'setMe'), - 14, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 14, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 14, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 14, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(this.context, 'val'), 14, 'the set propagated back up'); this.runTask(() => set(this.context, 'val', 12)); @@ -80,22 +56,22 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { bottom = this; - } + }, }), - template: '{{setMe}}' + template: '{{setMe}}', }); this.registerComponent('middle-mut', { ComponentClass: Component.extend({ didInsertElement() { middle = this; - } + }, }), - template: '{{bottom-mut setMe=(mut value)}}' + template: '{{bottom-mut setMe=(mut value)}}', }); this.render('{{middle-mut value=(mut val)}}', { - val: 12 + val: 12, }); this.assertText('12', 'the data propagated downwards'); @@ -105,60 +81,20 @@ moduleFor( this.runTask(() => bottom.attrs.setMe.update(13)); this.assertText('13', 'the set took effect'); - this.assert.strictEqual( - get(bottom, 'setMe'), - 13, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 13, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(middle, 'value'), - 13, - "the set propagated to middle's prop" - ); - this.assert.strictEqual( - middle.attrs.value.value, - 13, - "the set propagated to middle's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 13, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 13, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(middle, 'value'), 13, "the set propagated to middle's prop"); + this.assert.strictEqual(middle.attrs.value.value, 13, "the set propagated to middle's attr"); + this.assert.strictEqual(get(this.context, 'val'), 13, 'the set propagated back up'); this.runTask(() => set(bottom, 'setMe', 14)); this.assertText('14', 'the set took effect'); - this.assert.strictEqual( - get(bottom, 'setMe'), - 14, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 14, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(middle, 'value'), - 14, - "the set propagated to middle's prop" - ); - this.assert.strictEqual( - middle.attrs.value.value, - 14, - "the set propagated to middle's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 14, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 14, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(middle, 'value'), 14, "the set propagated to middle's prop"); + this.assert.strictEqual(middle.attrs.value.value, 14, "the set propagated to middle's attr"); + this.assert.strictEqual(get(this.context, 'val'), 14, 'the set propagated back up'); this.runTask(() => set(this.context, 'val', 12)); @@ -189,13 +125,13 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { bottom = this; - } + }, }), - template: '{{stuff}}' + template: '{{stuff}}', }); this.registerComponent('middle-mut', { - template: '{{bottom-mut stuff=value}}' + template: '{{bottom-mut stuff=value}}', }); this.render('{{middle-mut value="foo"}}'); @@ -215,22 +151,22 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { bottom = this; - } + }, }), - template: '{{setMe}}' + template: '{{setMe}}', }); this.registerComponent('middle-mut', { ComponentClass: Component.extend({ didInsertElement() { middle = this; - } + }, }), - template: '{{bottom-mut setMe=(readonly value)}}' + template: '{{bottom-mut setMe=(readonly value)}}', }); this.render('{{middle-mut value=(mut val)}}', { - val: 12 + val: 12, }); this.assertText('12'); @@ -239,40 +175,20 @@ moduleFor( this.runTask(() => middle.attrs.value.update(13)); - this.assert.strictEqual( - get(middle, 'value'), - 13, - "the set took effect on middle's prop" - ); - this.assert.strictEqual( - middle.attrs.value.value, - 13, - "the set took effect on middle's attr" - ); + this.assert.strictEqual(get(middle, 'value'), 13, "the set took effect on middle's prop"); + this.assert.strictEqual(middle.attrs.value.value, 13, "the set took effect on middle's attr"); this.runTask(() => set(middle, 'value', 14)); - this.assert.strictEqual( - get(middle, 'value'), - 14, - "the set took effect on middle's prop" - ); - this.assert.strictEqual( - middle.attrs.value.value, - 14, - "the set took effect on middle's attr" - ); + this.assert.strictEqual(get(middle, 'value'), 14, "the set took effect on middle's prop"); + this.assert.strictEqual(middle.attrs.value.value, 14, "the set took effect on middle's attr"); this.assert.strictEqual( bottom.attrs.setMe, 14, 'the mutable binding has been converted to an immutable cell' ); this.assertText('14'); - this.assert.strictEqual( - get(this.context, 'val'), - 14, - 'the set propagated back up' - ); + this.assert.strictEqual(get(this.context, 'val'), 14, 'the set propagated back up'); this.runTask(() => set(this.context, 'val', 12)); @@ -281,15 +197,15 @@ moduleFor( ['@test mutable bindings work inside of yielded content']() { this.registerComponent('bottom-mut', { - template: '{{yield}}' + template: '{{yield}}', }); this.registerComponent('middle-mut', { - template: '{{#bottom-mut}}{{model.name}}{{/bottom-mut}}' + template: '{{#bottom-mut}}{{model.name}}{{/bottom-mut}}', }); this.render('{{middle-mut model=(mut model)}}', { - model: { name: 'Matthew Beale' } + model: { name: 'Matthew Beale' }, }); this.assertText('Matthew Beale'); @@ -318,17 +234,17 @@ moduleFor( didInsertElement() { didInsert.push(get(this, 'setMe')); bottom = this; - } + }, }), - template: '{{setMe}}' + template: '{{setMe}}', }); this.registerComponent('middle-mut', { - template: '{{bottom-mut setMe=(mut value)}}' + template: '{{bottom-mut setMe=(mut value)}}', }); this.render('{{middle-mut value=(mut val)}}', { - val: 12 + val: 12, }); this.assert.deepEqual(willRender, [12], 'willReceive is [12]'); @@ -343,39 +259,15 @@ moduleFor( this.runTask(() => bottom.attrs.setMe.update(13)); - this.assert.strictEqual( - get(bottom, 'setMe'), - 13, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 13, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 13, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 13, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 13, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(this.context, 'val'), 13, 'the set propagated back up'); this.runTask(() => set(bottom, 'setMe', 14)); - this.assert.strictEqual( - get(bottom, 'setMe'), - 14, - "the set took effect on bottom's prop" - ); - this.assert.strictEqual( - bottom.attrs.setMe.value, - 14, - "the set took effect on bottom's attr" - ); - this.assert.strictEqual( - get(this.context, 'val'), - 14, - 'the set propagated back up' - ); + this.assert.strictEqual(get(bottom, 'setMe'), 14, "the set took effect on bottom's prop"); + this.assert.strictEqual(bottom.attrs.setMe.value, 14, "the set took effect on bottom's attr"); + this.assert.strictEqual(get(this.context, 'val'), 14, 'the set propagated back up'); this.runTask(() => set(this.context, 'val', 12)); @@ -390,9 +282,9 @@ moduleFor( thingy: null, didInsertElement() { bottom = this; - } + }, }), - template: '{{thingy}}' + template: '{{thingy}}', }); this.registerComponent('middle-mut', { @@ -403,9 +295,9 @@ moduleFor( }), didInsertElement() { middle = this; - } + }, }), - template: '{{bottom-mut thingy=(mut val)}}' + template: '{{bottom-mut thingy=(mut val)}}', }); this.render('{{middle-mut}}'); @@ -442,13 +334,13 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { inner = this; - } + }, }), - template: '{{foo}}' + template: '{{foo}}', }); this.registerComponent('x-outer', { - template: '{{x-inner foo=bar}}' + template: '{{x-inner foo=bar}}', }); this.render('{{x-outer bar=baz}}', { baz: 'foo' }); @@ -475,13 +367,13 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { inner = this; - } + }, }), - template: '{{model}}' + template: '{{model}}', }); this.registerComponent('x-outer', { - template: '{{x-inner model=nonexistent}}' + template: '{{x-inner model=nonexistent}}', }); this.render('{{x-outer}}'); @@ -508,13 +400,13 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { inner = this; - } + }, }), - template: 'hello{{model}}' + template: 'hello{{model}}', }); this.registerComponent('x-outer', { - template: '{{x-inner model=x}}' + template: '{{x-inner model=x}}', }); this.render('{{x-outer x="foo"}}'); @@ -546,8 +438,8 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { input = this; - } - }) + }, + }), }); this.registerComponent('x-output', { @@ -560,19 +452,19 @@ moduleFor( let height = this.get('height'); return htmlSafe(`height: ${height}px;`); }), - height: 20 + height: 20, }), - template: '{{height}}' + template: '{{height}}', }); this.render('{{x-output height=height}}{{x-input height=(mut height)}}', { - height: 60 + height: 60, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 60px;') }, - content: '60' + content: '60', }); this.assertStableRerender(); @@ -580,29 +472,21 @@ moduleFor( this.runTask(() => input.attrs.height.update(35)); this.assert.strictEqual(get(output, 'height'), 35, 'the set took effect'); - this.assert.strictEqual( - get(this.context, 'height'), - 35, - 'the set propagated back up' - ); + this.assert.strictEqual(get(this.context, 'height'), 35, 'the set propagated back up'); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 35px;') }, - content: '35' + content: '35', }); this.runTask(() => set(input, 'height', 36)); this.assert.strictEqual(get(output, 'height'), 36, 'the set took effect'); - this.assert.strictEqual( - get(this.context, 'height'), - 36, - 'the set propagated back up' - ); + this.assert.strictEqual(get(this.context, 'height'), 36, 'the set propagated back up'); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 36px;') }, - content: '36' + content: '36', }); this.runTask(() => set(this.context, 'height', 60)); @@ -610,7 +494,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 60px;') }, - content: '60' + content: '60', }); this.assert.strictEqual(get(input, 'height'), 60); } @@ -622,8 +506,8 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { input = this; - } - }) + }, + }), }); this.registerComponent('x-output', { @@ -645,20 +529,20 @@ moduleFor( set(keyName, width) { this.set('height', width / 2); return width; - } - }) + }, + }), }), - template: '{{width}}x{{height}}' + template: '{{width}}x{{height}}', }); this.render('{{x-output width=width}}{{x-input width=(mut width)}}', { - width: 70 + width: 70, }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 35px; width: 70px;') }, - content: '70x35' + content: '70x35', }); this.assertStableRerender(); @@ -666,29 +550,21 @@ moduleFor( this.runTask(() => set(input, 'width', 80)); this.assert.strictEqual(get(output, 'width'), 80, 'the set took effect'); - this.assert.strictEqual( - get(this.context, 'width'), - 80, - 'the set propagated back up' - ); + this.assert.strictEqual(get(this.context, 'width'), 80, 'the set propagated back up'); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 40px; width: 80px;') }, - content: '80x40' + content: '80x40', }); this.runTask(() => input.attrs.width.update(90)); this.assert.strictEqual(get(output, 'width'), 90, 'the set took effect'); - this.assert.strictEqual( - get(this.context, 'width'), - 90, - 'the set propagated back up' - ); + this.assert.strictEqual(get(this.context, 'width'), 90, 'the set propagated back up'); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 45px; width: 90px;') }, - content: '90x45' + content: '90x45', }); this.runTask(() => set(this.context, 'width', 70)); @@ -696,7 +572,7 @@ moduleFor( this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: styles('height: 35px; width: 70px;') }, - content: '70x35' + content: '70x35', }); this.assert.strictEqual(get(input, 'width'), 70); } diff --git a/packages/ember-glimmer/tests/integration/helpers/partial-test.js b/packages/ember-glimmer/tests/integration/helpers/partial-test.js index a24a7b610c4..f9c9aa714c1 100644 --- a/packages/ember-glimmer/tests/integration/helpers/partial-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/partial-test.js @@ -9,9 +9,7 @@ moduleFor( ['@test should render other templates registered with the container']() { this.registerPartial('_subTemplateFromContainer', 'sub-template'); - this.render( - `This {{partial "subTemplateFromContainer"}} is pretty great.` - ); + this.render(`This {{partial "subTemplateFromContainer"}} is pretty great.`); this.assertStableRerender(); @@ -21,9 +19,7 @@ moduleFor( ['@test should render other slash-separated templates registered with the container']() { this.registerPartial('child/_subTemplateFromContainer', 'sub-template'); - this.render( - `This {{partial "child/subTemplateFromContainer"}} is pretty great.` - ); + this.render(`This {{partial "child/subTemplateFromContainer"}} is pretty great.`); this.assertStableRerender(); @@ -31,16 +27,13 @@ moduleFor( } ['@test should use the current context']() { - this.registerPartial( - '_person_name', - '{{model.firstName}} {{model.lastName}}' - ); + this.registerPartial('_person_name', '{{model.firstName}} {{model.lastName}}'); this.render('Who is {{partial "person_name"}}?', { model: { firstName: 'Kris', - lastName: 'Selden' - } + lastName: 'Selden', + }, }); this.assertStableRerender(); @@ -51,9 +44,7 @@ moduleFor( this.assertText('Who is Kelly Selden?'); - this.runTask(() => - set(this.context, 'model', { firstName: 'Kris', lastName: 'Selden' }) - ); + this.runTask(() => set(this.context, 'model', { firstName: 'Kris', lastName: 'Selden' })); this.assertText('Who is Kris Selden?'); } @@ -65,7 +56,7 @@ moduleFor( this.render( 'This {{partial templates.partialName}} is pretty {{partial nonexistent}}great.', { - templates: { partialName: 'subTemplate' } + templates: { partialName: 'subTemplate' }, } ); @@ -73,9 +64,7 @@ moduleFor( this.assertText('This sub-template is pretty great.'); - this.runTask(() => - set(this.context, 'templates.partialName', 'otherTemplate') - ); + this.runTask(() => set(this.context, 'templates.partialName', 'otherTemplate')); this.assertText('This other-template is pretty great.'); @@ -83,9 +72,7 @@ moduleFor( this.assertText('This is pretty great.'); - this.runTask(() => - set(this.context, 'templates', { partialName: 'subTemplate' }) - ); + this.runTask(() => set(this.context, 'templates', { partialName: 'subTemplate' })); this.assertText('This sub-template is pretty great.'); } @@ -100,8 +87,8 @@ moduleFor( {{/each}}`, { model: { - items: emberA(['apple', 'orange', 'banana']) - } + items: emberA(['apple', 'orange', 'banana']), + }, } ); @@ -111,13 +98,11 @@ moduleFor( this.runTask(() => this.context.model.items.pushObject('strawberry')); - this.assertText( - 'apple: apple |orange: orange |banana: banana |strawberry: strawberry |' - ); + this.assertText('apple: apple |orange: orange |banana: banana |strawberry: strawberry |'); this.runTask(() => set(this.context, 'model', { - items: emberA(['apple', 'orange', 'banana']) + items: emberA(['apple', 'orange', 'banana']), }) ); @@ -133,7 +118,7 @@ moduleFor( {{item.name}}: {{partial 'show-id'}} {{/with}}`, { - model: { id: 1, name: 'foo' } + model: { id: 1, name: 'foo' }, } ); @@ -163,7 +148,7 @@ moduleFor( {{item.id}}: {{partial 'show-item'}} | {{/each}}`, { - items: emberA([{ id: 1 }, { id: 2 }, { id: 3 }]) + items: emberA([{ id: 1 }, { id: 2 }, { id: 3 }]), } ); @@ -175,9 +160,7 @@ moduleFor( this.assertText('1: 1 |2: 2 |3: 3 |4: 4 |'); - this.runTask(() => - set(this.context, 'items', emberA([{ id: 1 }, { id: 2 }, { id: 3 }])) - ); + this.runTask(() => set(this.context, 'items', emberA([{ id: 1 }, { id: 2 }, { id: 3 }]))); this.assertText('1: 1 |2: 2 |3: 3 |'); } @@ -191,7 +174,7 @@ moduleFor( {{item}}: {{partial 'show-item'}} | {{/each}}`, { - items: emberA(['apple', null, 'orange', 'banana']) + items: emberA(['apple', null, 'orange', 'banana']), } ); @@ -201,13 +184,9 @@ moduleFor( this.runTask(() => this.context.items.pushObject('strawberry')); - this.assertText( - 'apple: apple |: |orange: orange |banana: banana |strawberry: strawberry |' - ); + this.assertText('apple: apple |: |orange: orange |banana: banana |strawberry: strawberry |'); - this.runTask(() => - set(this.context, 'items', emberA(['apple', null, 'orange', 'banana'])) - ); + this.runTask(() => set(this.context, 'items', emberA(['apple', null, 'orange', 'banana']))); this.assertText('apple: apple |: |orange: orange |banana: banana |'); } @@ -228,15 +207,13 @@ moduleFor( {{i}}: {{partial 'outer-partial'}} {{/each}}`, { - names: emberA(['Alex', 'Ben']) + names: emberA(['Alex', 'Ben']), } ); this.assertStableRerender(); - this.assertText( - '0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]' - ); + this.assertText('0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]'); this.runTask(() => this.context.names.pushObject('Sophie')); @@ -246,9 +223,7 @@ moduleFor( this.runTask(() => set(this.context, 'names', emberA(['Alex', 'Ben']))); - this.assertText( - '0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]' - ); + this.assertText('0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]'); } ['@test nested partials within nested `{{#with}}` blocks']() { @@ -318,8 +293,8 @@ moduleFor( { model: { items: ['even', 'odd', 'even', 'odd'], - type: 'number' - } + type: 'number', + }, } ); @@ -334,7 +309,7 @@ moduleFor( this.runTask(() => set(this.context, 'model', { items: ['even', 'odd', 'even', 'odd'], - type: 'number' + type: 'number', }) ); @@ -352,7 +327,7 @@ moduleFor( Nothing! {{/with}}`, { - item: { thing: false } + item: { thing: false }, } ); @@ -371,12 +346,11 @@ moduleFor( ['@test partials which contain contextual components']() { this.registerComponent('outer-component', { - template: - '{{yield (hash inner=(component "inner-component" name=name))}}' + template: '{{yield (hash inner=(component "inner-component" name=name))}}', }); this.registerComponent('inner-component', { - template: '{{yield (hash name=name)}}' + template: '{{yield (hash name=name)}}', }); this.registerPartial( diff --git a/packages/ember-glimmer/tests/integration/helpers/readonly-test.js b/packages/ember-glimmer/tests/integration/helpers/readonly-test.js index 226b4a73503..4020d42810e 100644 --- a/packages/ember-glimmer/tests/integration/helpers/readonly-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/readonly-test.js @@ -12,13 +12,13 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { component = this; - } + }, }), - template: '{{value}}' + template: '{{value}}', }); this.render('{{foo-bar value=(readonly val)}}', { - val: 12 + val: 12, }); this.assertText('12'); @@ -29,18 +29,12 @@ moduleFor( this.assert.notOk(component.attrs.value.update); this.assertText('13', 'local property is updated'); - this.assert.equal( - get(this.context, 'val'), - 12, - 'upstream attribute is not updated' - ); + this.assert.equal(get(this.context, 'val'), 12, 'upstream attribute is not updated'); // No U-R } - '@test passing an action to {{readonly}} avoids mutable cell wrapping'( - assert - ) { + '@test passing an action to {{readonly}} avoids mutable cell wrapping'(assert) { assert.expect(4); let outer, inner; @@ -49,8 +43,8 @@ moduleFor( init() { this._super(...arguments); inner = this; - } - }) + }, + }), }); this.registerComponent('x-outer', { @@ -58,15 +52,15 @@ moduleFor( init() { this._super(...arguments); outer = this; - } + }, }), - template: '{{x-inner onClick=(readonly onClick)}}' + template: '{{x-inner onClick=(readonly onClick)}}', }); this.render('{{x-outer onClick=(action doIt)}}', { doIt() { assert.ok(true, 'action was called'); - } + }, }); assert.equal( @@ -92,13 +86,13 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }), - template: '{{value}}' + template: '{{value}}', }); this.render('{{foo-bar value=(readonly thing)}}', { - thing: 'initial' + thing: 'initial', }); this.assertText('initial'); @@ -112,16 +106,8 @@ moduleFor( this.runTask(() => set(this.context, 'thing', 'updated!')); this.assertText('updated!'); - assert.strictEqual( - component.attrs.value, - 'updated!', - 'passed down value was set in attrs' - ); - assert.strictEqual( - get(component, 'value'), - 'updated!', - 'passed down value was set' - ); + assert.strictEqual(component.attrs.value, 'updated!', 'passed down value was set in attrs'); + assert.strictEqual(get(component, 'value'), 'updated!', 'passed down value was set'); this.runTask(() => set(this.context, 'thing', 'initial')); @@ -135,15 +121,15 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { component = this; - } + }, }), - template: '{{value.prop}}' + template: '{{value.prop}}', }); this.render('{{foo-bar value=(readonly thing)}}', { thing: { - prop: 'initial' - } + prop: 'initial', + }, }); this.assertText('initial'); @@ -172,9 +158,9 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { component = this; - } + }, }), - template: '{{value}}' + template: '{{value}}', }); this.render('{{foo-bar value=(readonly "12")}}'); @@ -203,38 +189,30 @@ moduleFor( ComponentClass: Component.extend({ didInsertElement() { bottom = this; - } + }, }), - template: '{{bar}}' + template: '{{bar}}', }); this.registerComponent('x-middle', { ComponentClass: Component.extend({ didInsertElement() { middle = this; - } + }, }), - template: '{{foo}} {{x-bottom bar=(mut foo)}}' + template: '{{foo}} {{x-bottom bar=(mut foo)}}', }); this.render('{{x-middle foo=(readonly val)}}', { - val: 12 + val: 12, }); this.assertText('12 12'); this.assertStableRerender(); - this.assert.equal( - get(bottom, 'bar'), - 12, - "bottom's local bar received the value" - ); - this.assert.equal( - get(middle, 'foo'), - 12, - "middle's local foo received the value" - ); + this.assert.equal(get(bottom, 'bar'), 12, "bottom's local bar received the value"); + this.assert.equal(get(middle, 'foo'), 12, "middle's local foo received the value"); // updating the mut-cell directly this.runTask(() => bottom.attrs.bar.update(13)); @@ -250,11 +228,7 @@ moduleFor( "middle's local foo was updated after set of bottom's bar" ); this.assertText('13 13'); - this.assert.equal( - get(this.context, 'val'), - 12, - 'But context val is not updated' - ); + this.assert.equal(get(this.context, 'val'), 12, 'But context val is not updated'); this.runTask(() => set(bottom, 'bar', 14)); @@ -269,34 +243,19 @@ moduleFor( "middle's local foo was updated after set of bottom's bar" ); this.assertText('14 14'); - this.assert.equal( - get(this.context, 'val'), - 12, - 'But context val is not updated' - ); + this.assert.equal(get(this.context, 'val'), 12, 'But context val is not updated'); - this.assert.notOk( - middle.attrs.foo.update, - "middle's foo attr is not a mutable cell" - ); + this.assert.notOk(middle.attrs.foo.update, "middle's foo attr is not a mutable cell"); this.runTask(() => set(middle, 'foo', 15)); this.assertText('15 15'); - this.assert.equal( - get(middle, 'foo'), - 15, - "set of middle's foo took effect" - ); + this.assert.equal(get(middle, 'foo'), 15, "set of middle's foo took effect"); this.assert.equal( get(bottom, 'bar'), 15, "bottom's local bar was updated after set of middle's foo" ); - this.assert.equal( - get(this.context, 'val'), - 12, - 'Context val remains unchanged' - ); + this.assert.equal(get(this.context, 'val'), 12, 'Context val remains unchanged'); this.runTask(() => set(this.context, 'val', 10)); diff --git a/packages/ember-glimmer/tests/integration/helpers/render-test.js b/packages/ember-glimmer/tests/integration/helpers/render-test.js index e3348ab29a7..4ab884f3e69 100644 --- a/packages/ember-glimmer/tests/integration/helpers/render-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/render-test.js @@ -31,7 +31,7 @@ moduleFor( this.owner.register( 'controller:basic', Controller.extend({ - isBasicController: true + isBasicController: true, }) ); this.registerTemplate('home', '{{isBasicController}}'); @@ -54,10 +54,7 @@ moduleFor( } ['@test should use controller with the same name as template if present']() { - this.owner.register( - 'controller:home', - Controller.extend({ name: 'home' }) - ); + this.owner.register('controller:home', Controller.extend({ name: 'home' })); this.registerTemplate('home', '{{name}}

BYE

'); expectDeprecation(() => { @@ -101,7 +98,7 @@ moduleFor( Controller.extend({ init() { this.set('title', `It's Simple Made Easy`); - } + }, }) ); this.registerTemplate('post', '

{{title}}

'); @@ -140,56 +137,39 @@ moduleFor( willDestroy() { this._super(...arguments); willDestroyFired++; - } + }, }) ); this.registerTemplate('post', '

{{title}}

'); expectDeprecation(() => { - this.render( - `{{#if showPost}}{{render 'post'}}{{else}}Nothing here{{/if}}`, - { showPost: false } - ); + this.render(`{{#if showPost}}{{render 'post'}}{{else}}Nothing here{{/if}}`, { + showPost: false, + }); }, /Please refactor [\w\{\}"` ]+ to a component/); this.assertText(`Nothing here`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => this.rerender()); this.assertText(`Nothing here`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => set(this.context, 'showPost', true)); this.assertText(`It's Simple Made Easy`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => set(this.context, 'showPost', false)); this.assertText(`Nothing here`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); } ['@test should render given template with a supplied model']() { @@ -199,8 +179,8 @@ moduleFor( expectDeprecation(() => { this.render(`

HI

{{render 'post' post}}`, { post: { - title: `It's Simple Made Easy` - } + title: `It's Simple Made Easy`, + }, }); }, /Please refactor [\w\{\}"` ]+ to a component/); @@ -214,9 +194,7 @@ moduleFor( this.assertText(`HIRails is omakase`); - this.runTask(() => - set(this.context, 'post', { title: `It's Simple Made Easy` }) - ); + this.runTask(() => set(this.context, 'post', { title: `It's Simple Made Easy` })); this.assertText(`HIIt's Simple Made Easy`); } @@ -230,51 +208,36 @@ moduleFor( willDestroy() { this._super(...arguments); willDestroyFired++; - } + }, }) ); this.registerTemplate('post', '

{{model.title}}

'); expectDeprecation(() => { - this.render( - `{{#if showPost}}{{render 'post' post}}{{else}}Nothing here{{/if}}`, - { - showPost: false, - post: { - title: `It's Simple Made Easy` - } - } - ); + this.render(`{{#if showPost}}{{render 'post' post}}{{else}}Nothing here{{/if}}`, { + showPost: false, + post: { + title: `It's Simple Made Easy`, + }, + }); }, /Please refactor [\w\{\}"` ]+ to a component/); this.assertText(`Nothing here`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => this.rerender()); this.assertText(`Nothing here`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => set(this.context, 'showPost', true)); this.assertText(`It's Simple Made Easy`); - assert.strictEqual( - willDestroyFired, - 0, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller'); this.runTask(() => set(this.context, 'showPost', false)); @@ -286,11 +249,7 @@ moduleFor( this.assertText(`It's Simple Made Easy`); - assert.strictEqual( - willDestroyFired, - 1, - 'it did not destroy the controller' - ); + assert.strictEqual(willDestroyFired, 1, 'it did not destroy the controller'); this.runTask(() => set(this.context, 'showPost', false)); @@ -299,9 +258,7 @@ moduleFor( assert.strictEqual(willDestroyFired, 2, 'it did destroy the controller'); } - ['@test with a supplied model should not fire observers on the controller']( - assert - ) { + ['@test with a supplied model should not fire observers on the controller'](assert) { this.owner.register('controller:post', Controller.extend()); this.registerTemplate('post', '

{{model.title}}

'); @@ -312,8 +269,8 @@ moduleFor( postDidChange++; }), post: { - title: `It's Simple Made Easy` - } + title: `It's Simple Made Easy`, + }, }); }, /Please refactor [\w\{\}"` ]+ to a component/); @@ -349,7 +306,7 @@ moduleFor( this._super(...arguments); this.uniqueId = id++; this.set('model', model); - } + }, }) ); @@ -377,17 +334,14 @@ moduleFor( this.registerTemplate('post', '

{{model.title}}

'); expectDeprecation(() => { - this.render( - `

HI

{{render 'post' post1}} {{render 'post' post2}}`, - { - post1: { - title: 'Me First' - }, - post2: { - title: 'Then me' - } - } - ); + this.render(`

HI

{{render 'post' post1}} {{render 'post' post2}}`, { + post1: { + title: 'Me First', + }, + post2: { + title: 'Then me', + }, + }); }, /Please refactor [\w\{\}"` ]+ to a component/); this.assertText('HI Me First Then me'); @@ -405,24 +359,16 @@ moduleFor( this.assertText('HI Me First Then me'); } - ['@test should not treat invocations with falsy contexts as context-less']( - assert - ) { - this.registerTemplate( - 'post', - '

{{#unless model.zero}}NOTHING{{/unless}}

' - ); + ['@test should not treat invocations with falsy contexts as context-less'](assert) { + this.registerTemplate('post', '

{{#unless model.zero}}NOTHING{{/unless}}

'); this.owner.register('controller:post', Controller.extend()); expectDeprecation(() => { - this.render( - `

HI

{{render 'post' zero}} {{render 'post' nonexistent}}`, - { - model: { - zero: false - } - } - ); + this.render(`

HI

{{render 'post' zero}} {{render 'post' nonexistent}}`, { + model: { + zero: false, + }, + }); }, /Please refactor [\w\{\}"` ]+ to a component/); assert.ok( @@ -437,11 +383,11 @@ moduleFor( this.owner.register('controller:post', Controller.extend()); let post = { - title: 'Rails is omakase' + title: 'Rails is omakase', }; expectDeprecation(() => { this.render(`

HI

{{render 'post'}} {{render 'post' post}}`, { - post + post, }); }, /Please refactor [\w\{\}"` ]+ to a component/); @@ -467,9 +413,7 @@ moduleFor( .match(/^HI ?Title: ?Title:Simple Made Easy$/) ); - this.runTask(() => - set(this.context, 'post', { title: 'Rails is omakase' }) - ); + this.runTask(() => set(this.context, 'post', { title: 'Rails is omakase' })); assert.ok( this.$() @@ -488,7 +432,7 @@ moduleFor( init() { this._super(...arguments); this.uniqueId = id++; - } + }, }) ); @@ -512,8 +456,8 @@ moduleFor( expectAssertion(() => { this.render('

HI

{{render "home" "model"}}', { model: { - title: 'Simple Made Easy' - } + title: 'Simple Made Easy', + }, }); }, 'The second argument of {{render}} must be a path, e.g. {{render "post" post}}.'); } @@ -529,7 +473,7 @@ moduleFor( init() { this._super(...arguments); postController = this; - } + }, }) ); @@ -537,7 +481,7 @@ moduleFor( send(actionName) { assert.equal(actionName, 'someAction'); assert.ok(true, 'routerStub#send called'); - } + }, }; this.owner.register('router:main', routerStub, { instantiate: false }); @@ -557,7 +501,7 @@ moduleFor( propertyWithError: computed(function() { this.set('model.name', 'this will cause a backtracking error'); return 'foo'; - }) + }), }) ); @@ -566,10 +510,7 @@ moduleFor( expectDeprecation(() => { let person = { name: 'Ben' }; - this.registerTemplate( - 'outer', - `Hi {{model.name}} | {{render 'inner' model}}` - ); + this.registerTemplate('outer', `Hi {{model.name}} | {{render 'inner' model}}`); this.registerTemplate('inner', `Hi {{propertyWithError}}`); expectAssertion(() => { diff --git a/packages/ember-glimmer/tests/integration/helpers/text-area-test.js b/packages/ember-glimmer/tests/integration/helpers/text-area-test.js index bb064e5696a..f1f0b13a070 100644 --- a/packages/ember-glimmer/tests/integration/helpers/text-area-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/text-area-test.js @@ -6,13 +6,10 @@ import { applyMixins } from '../../utils/abstract-test-case'; class TextAreaRenderingTest extends RenderingTest { assertTextArea({ attrs, value } = {}) { - let mergedAttrs = assign( - { class: classes('ember-view ember-text-area') }, - attrs - ); + let mergedAttrs = assign({ class: classes('ember-view ember-text-area') }, attrs); this.assertComponentElement(this.firstChild, { tagName: 'textarea', - attrs: mergedAttrs + attrs: mergedAttrs, }); if (value) { @@ -38,7 +35,7 @@ class BoundTextAreaAttributes { return { [`@test ${attribute}`]() { this.render(`{{textarea ${attribute}=value}}`, { - value: first + value: first, }); this.assertTextArea({ attrs: { [attribute]: first } }); @@ -49,7 +46,7 @@ class BoundTextAreaAttributes { this.runTask(() => set(this.context, 'value', first)); this.assertTextArea({ attrs: { [attribute]: first } }); - } + }, }; } } @@ -63,7 +60,7 @@ applyMixins( { attribute: 'maxlength', first: '1', second: '2' }, { attribute: 'rows', first: '1', second: '2' }, { attribute: 'cols', first: '1', second: '2' }, - { attribute: 'tabindex', first: '1', second: '2' } + { attribute: 'tabindex', first: '1', second: '2' }, ]) ); @@ -80,14 +77,14 @@ moduleFor( ['@test Should respect disabled'](assert) { this.render('{{textarea disabled=disabled}}', { - disabled: true + disabled: true, }); assert.ok(this.$('textarea').is(':disabled')); } ['@test Should respect disabled when false'](assert) { this.render('{{textarea disabled=disabled}}', { - disabled: false + disabled: false, }); assert.ok(this.$('textarea').is(':not(:disabled)')); } @@ -107,7 +104,7 @@ moduleFor( ['@test Should bind its contents to the specified value']() { this.render('{{textarea value=model.val}}', { - model: { val: 'A beautiful day in Seattle' } + model: { val: 'A beautiful day in Seattle' }, }); this.assertTextArea({ value: 'A beautiful day in Seattle' }); @@ -116,9 +113,7 @@ moduleFor( this.runTask(() => set(this.context, 'model.val', 'Auckland')); this.assertTextArea({ value: 'Auckland' }); - this.runTask(() => - set(this.context, 'model', { val: 'A beautiful day in Seattle' }) - ); + this.runTask(() => set(this.context, 'model', { val: 'A beautiful day in Seattle' })); this.assertTextArea({ value: 'A beautiful day in Seattle' }); } @@ -140,7 +135,7 @@ moduleFor( ['@test should update the value for `cut` / `input` / `change` events']() { this.render('{{textarea value=model.val}}', { - model: { val: 'A beautiful day in Seattle' } + model: { val: 'A beautiful day in Seattle' }, }); this.assertTextArea({ value: 'A beautiful day in Seattle' }); @@ -164,9 +159,7 @@ moduleFor( }); this.assertTextArea({ value: 'Boston' }); - this.runTask(() => - set(this.context, 'model', { val: 'A beautiful day in Seattle' }) - ); + this.runTask(() => set(this.context, 'model', { val: 'A beautiful day in Seattle' })); this.assertTextArea({ value: 'A beautiful day in Seattle' }); } } diff --git a/packages/ember-glimmer/tests/integration/helpers/unbound-test.js b/packages/ember-glimmer/tests/integration/helpers/unbound-test.js index 2842928c84a..646c2e18a0e 100644 --- a/packages/ember-glimmer/tests/integration/helpers/unbound-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/unbound-test.js @@ -10,8 +10,8 @@ moduleFor( ['@test should be able to output a property without binding']() { this.render(`
{{unbound content.anUnboundString}}
`, { content: { - anUnboundString: 'No spans here, son.' - } + anUnboundString: 'No spans here, son.', + }, }); this.assertText('No spans here, son.'); @@ -26,7 +26,7 @@ moduleFor( this.runTask(() => set(this.context, 'content', { - anUnboundString: 'No spans here, son.' + anUnboundString: 'No spans here, son.', }) ); @@ -34,12 +34,9 @@ moduleFor( } ['@test should be able to use unbound helper in #each helper']() { - this.render( - `
    {{#each items as |item|}}
  • {{unbound item}}
  • {{/each}}
`, - { - items: emberA(['a', 'b', 'c', 1, 2, 3]) - } - ); + this.render(`
    {{#each items as |item|}}
  • {{unbound item}}
  • {{/each}}
`, { + items: emberA(['a', 'b', 'c', 1, 2, 3]), + }); this.assertText('abc123'); @@ -49,12 +46,9 @@ moduleFor( } ['@test should be able to use unbound helper in #each helper (with objects)']() { - this.render( - `
    {{#each items as |item|}}
  • {{unbound item.wham}}
  • {{/each}}
`, - { - items: emberA([{ wham: 'bam' }, { wham: 1 }]) - } - ); + this.render(`
    {{#each items as |item|}}
  • {{unbound item.wham}}
  • {{/each}}
`, { + items: emberA([{ wham: 'bam' }, { wham: 1 }]), + }); this.assertText('bam1'); @@ -66,9 +60,7 @@ moduleFor( this.assertText('bam1'); - this.runTask(() => - set(this.context, 'items', emberA([{ wham: 'bam' }, { wham: 1 }])) - ); + this.runTask(() => set(this.context, 'items', emberA([{ wham: 'bam' }, { wham: 1 }]))); this.assertText('bam1'); } @@ -77,7 +69,7 @@ moduleFor( let willThrow = () => { this.render(`{{unbound foo bar}}`, { foo: 'BORK', - bar: 'BLOOP' + bar: 'BLOOP', }); }; @@ -89,7 +81,7 @@ moduleFor( ['@test should render on attributes']() { this.render(``, { - model: { foo: 'BORK' } + model: { foo: 'BORK' }, }); this.assertHTML(''); @@ -111,22 +103,22 @@ moduleFor( let unsafeUrls = emberA([ { name: 'Bob', - url: 'javascript:bob-is-cool' // jshint ignore:line + url: 'javascript:bob-is-cool', // jshint ignore:line }, { name: 'James', - url: 'vbscript:james-is-cool' // jshint ignore:line + url: 'vbscript:james-is-cool', // jshint ignore:line }, { name: 'Richard', - url: 'javascript:richard-is-cool' // jshint ignore:line - } + url: 'javascript:richard-is-cool', // jshint ignore:line + }, ]); this.render( ``, { - people: unsafeUrls + people: unsafeUrls, } ); @@ -150,9 +142,7 @@ moduleFor( this.assertHTML(escapedHtml); - this.runTask(() => - this.context.people.setEach('url', 'http://google.com') - ); + this.runTask(() => this.context.people.setEach('url', 'http://google.com')); this.assertHTML(escapedHtml); @@ -163,7 +153,7 @@ moduleFor( ['@skip helper form updates on parent re-render']() { this.render(`{{unbound foo}}`, { - foo: 'BORK' + foo: 'BORK', }); this.assertText('BORK'); @@ -196,7 +186,7 @@ moduleFor( this.registerHelper('capitalize', args => args[0].toUpperCase()); this.render(`{{capitalize (unbound foo)}}`, { - foo: 'bork' + foo: 'bork', }); this.assertText('BORK'); @@ -230,7 +220,7 @@ moduleFor( this.registerHelper('doublize', params => `${params[0]} ${params[0]}`); this.render(`{{capitalize (unbound (doublize foo))}}`, { - foo: 'bork' + foo: 'bork', }); this.assertText('BORK BORK'); @@ -271,7 +261,7 @@ moduleFor( `{{unbound (repeat foo count=bar)}} {{repeat foo count=bar}} {{unbound (repeat foo count=2)}} {{repeat foo count=4}}`, { foo: 'X', - bar: 5 + bar: 5, } ); @@ -291,10 +281,7 @@ moduleFor( } ['@test should be able to render an bound helper invocation mixed with static values']() { - this.registerHelper( - 'surround', - ([prefix, value, suffix]) => `${prefix}-${value}-${suffix}` - ); + this.registerHelper('surround', ([prefix, value, suffix]) => `${prefix}-${value}-${suffix}`); this.render( strip` @@ -303,26 +290,22 @@ moduleFor( model: { prefix: 'before', value: 'core', - suffix: 'after' - } + suffix: 'after', + }, } ); - this.assertText( - 'before-core-bar before-core-bar bar-core-after bar-core-after' - ); + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); this.runTask(() => this.rerender()); - this.assertText( - 'before-core-bar before-core-bar bar-core-after bar-core-after' - ); + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); this.runTask(() => { setProperties(this.context.model, { prefix: 'beforeChanged', value: 'coreChanged', - suffix: 'afterChanged' + suffix: 'afterChanged', }); }); @@ -334,13 +317,11 @@ moduleFor( set(this.context, 'model', { prefix: 'before', value: 'core', - suffix: 'after' + suffix: 'after', }); }); - this.assertText( - 'before-core-bar before-core-bar bar-core-after bar-core-after' - ); + this.assertText('before-core-bar before-core-bar bar-core-after bar-core-after'); } ['@test should be able to render unbound forms of multi-arg helpers']() { @@ -352,8 +333,8 @@ moduleFor( model: { foo: 'a', bar: 'b', - bing: 'c' - } + bing: 'c', + }, } ); @@ -371,7 +352,7 @@ moduleFor( set(this.context, 'model', { foo: 'a', bar: 'b', - bing: 'c' + bing: 'c', }) ); @@ -392,7 +373,7 @@ moduleFor( this.set('value', value); this.addObserver('value.firstName', this, this.recompute); return value ? get(value, 'firstName').toUpperCase() : ''; - } + }, }); this.registerHelper('concatNames', { @@ -411,11 +392,8 @@ moduleFor( this.set('value', value); this.addObserver('value.firstName', this, this.recompute); this.addObserver('value.lastName', this, this.recompute); - return ( - (value ? get(value, 'firstName') : '') + - (value ? get(value, 'lastName') : '') - ); - } + return (value ? get(value, 'firstName') : '') + (value ? get(value, 'lastName') : ''); + }, }); this.render( @@ -423,8 +401,8 @@ moduleFor( { person: { firstName: 'shooby', - lastName: 'taylor' - } + lastName: 'taylor', + }, } ); @@ -441,7 +419,7 @@ moduleFor( this.runTask(() => set(this.context, 'person', { firstName: 'shooby', - lastName: 'taylor' + lastName: 'taylor', }) ); @@ -457,13 +435,13 @@ moduleFor( people: emberA([ { firstName: 'shooby', - lastName: 'taylor' + lastName: 'taylor', }, { firstName: 'cindy', - lastName: 'taylor' - } - ]) + lastName: 'taylor', + }, + ]), } ); @@ -484,12 +462,12 @@ moduleFor( emberA([ { firstName: 'shooby', - lastName: 'taylor' + lastName: 'taylor', }, { firstName: 'cindy', - lastName: 'taylor' - } + lastName: 'taylor', + }, ]) ) ); @@ -511,7 +489,7 @@ moduleFor( this.set('value', value); this.addObserver('value.firstName', this, this.recompute); return value ? get(value, 'firstName').toUpperCase() : ''; - } + }, }); this.registerHelper('concatNames', { @@ -530,11 +508,8 @@ moduleFor( this.set('value', value); this.addObserver('value.firstName', this, this.recompute); this.addObserver('value.lastName', this, this.recompute); - return ( - (value ? get(value, 'firstName') : '') + - (value ? get(value, 'lastName') : '') - ); - } + return (value ? get(value, 'firstName') : '') + (value ? get(value, 'lastName') : ''); + }, }); this.render( @@ -542,8 +517,8 @@ moduleFor( { person: { firstName: 'shooby', - lastName: 'taylor' - } + lastName: 'taylor', + }, } ); @@ -560,7 +535,7 @@ moduleFor( this.runTask(() => set(this.context, 'person', { firstName: 'shooby', - lastName: 'taylor' + lastName: 'taylor', }) ); @@ -582,8 +557,8 @@ moduleFor( model: { foo: true, notfoo: false, - bar: true - } + bar: true, + }, } ); @@ -601,7 +576,7 @@ moduleFor( set(this.context, 'model', { foo: true, notfoo: false, - bar: true + bar: true, }) ); @@ -615,12 +590,12 @@ moduleFor( this._super(...arguments); fooBarInstance = this; }, - model: { foo: 'bork' } + model: { foo: 'bork' }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: `{{yield (unbound model.foo)}}` + template: `{{yield (unbound model.foo)}}`, }); this.render(`{{#foo-bar as |value|}}{{value}}{{/foo-bar}}`); @@ -647,12 +622,12 @@ moduleFor( this._super(...arguments); fooBarInstance = this; }, - model: { foo: 'bork' } + model: { foo: 'bork' }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: `{{yield (unbound (hash foo=model.foo))}}` + template: `{{yield (unbound (hash foo=model.foo))}}`, }); this.render(`{{#foo-bar as |value|}}{{value.foo}}{{/foo-bar}}`); diff --git a/packages/ember-glimmer/tests/integration/helpers/yield-test.js b/packages/ember-glimmer/tests/integration/helpers/yield-test.js index 2a8b35355ea..7d14a6678d7 100644 --- a/packages/ember-glimmer/tests/integration/helpers/yield-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/yield-test.js @@ -7,13 +7,12 @@ moduleFor( class extends RenderingTest { ['@test can yield to block']() { this.registerComponent('yield-comp', { - template: '[In layout:] {{yield}}' + template: '[In layout:] {{yield}}', }); - this.render( - '{{#yield-comp}}[In Block:] {{object.title}}{{/yield-comp}}', - { object: { title: 'Seattle' } } - ); + this.render('{{#yield-comp}}[In Block:] {{object.title}}{{/yield-comp}}', { + object: { title: 'Seattle' }, + }); this.assertText('[In layout:] [In Block:] Seattle'); this.assertStableRerender(); @@ -27,14 +26,14 @@ moduleFor( ['@test templates should yield to block inside a nested component']() { this.registerComponent('outer-comp', { - template: '
[In layout:] {{yield}}
' + template: '
[In layout:] {{yield}}
', }); this.registerComponent('inner-comp', { - template: '{{#outer-comp}}[In Block:] {{object.title}}{{/outer-comp}}' + template: '{{#outer-comp}}[In Block:] {{object.title}}{{/outer-comp}}', }); this.render('{{inner-comp object=object}}', { - object: { title: 'Seattle' } + object: { title: 'Seattle' }, }); this.assertText('[In layout:] [In Block:] Seattle'); @@ -51,11 +50,11 @@ moduleFor( let list = [1, 2, 3]; this.registerComponent('outer-comp', { - template: '{{#each list as |item|}}{{yield}}{{/each}}' + template: '{{#each list as |item|}}{{yield}}{{/each}}', }); this.render('{{#outer-comp list=list}}Hello{{/outer-comp}}', { - list: list + list: list, }); this.assertText('HelloHelloHello'); @@ -70,11 +69,11 @@ moduleFor( ['@test templates should yield to block, when the yield is embedded in a if helper']() { this.registerComponent('outer-comp', { - template: '{{#if boolean}}{{yield}}{{/if}}' + template: '{{#if boolean}}{{yield}}{{/if}}', }); this.render('{{#outer-comp boolean=boolean}}Hello{{/outer-comp}}', { - boolean: true + boolean: true, }); this.assertText('Hello'); @@ -89,7 +88,7 @@ moduleFor( ['@test simple curlies inside of a yielded clock should work when the yield is nested inside of another view']() { this.registerComponent('kiwi-comp', { - template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' + template: '{{#if falsy}}{{else}}{{yield}}{{/if}}', }); this.render('{{#kiwi-comp}}{{text}}{{/kiwi-comp}}', { text: 'ohai' }); @@ -106,14 +105,14 @@ moduleFor( ['@test nested simple curlies inside of a yielded block should work when the yield is nested inside of another view']() { this.registerComponent('parent-comp', { - template: '{{#if falsy}}{{else}}{{yield}}{{/if}}' + template: '{{#if falsy}}{{else}}{{yield}}{{/if}}', }); this.registerComponent('child-comp', { - template: '{{#if falsy}}{{else}}{{text}}{{/if}}' + template: '{{#if falsy}}{{else}}{{text}}{{/if}}', }); this.render('{{#parent-comp}}{{child-comp text=text}}{{/parent-comp}}', { - text: 'ohai' + text: 'ohai', }); this.assertText('ohai'); @@ -129,7 +128,7 @@ moduleFor( ['@test yielding to a non-existent block is not an error']() { this.registerComponent('yielding-comp', { template: 'Hello:{{yield}}' }); this.registerComponent('outer-comp', { - template: '{{yielding-comp}} {{title}}' + template: '{{yielding-comp}} {{title}}', }); this.render('{{outer-comp title=title}}', { title: 'Mr. Selden' }); @@ -150,11 +149,11 @@ moduleFor( this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, - template: '

{{boundText}}

{{yield}}

' + template: '

{{boundText}}

{{yield}}

', }); this.render('{{#kiwi-comp}}{{boundText}}{{/kiwi-comp}}', { - boundText: 'Original' + boundText: 'Original', }); this.assertText('InnerOriginal'); @@ -172,13 +171,12 @@ moduleFor( this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, - template: '

{{boundText}}

{{yield}}

' + template: '

{{boundText}}

{{yield}}

', }); - this.render( - '{{#with boundText as |item|}}{{#kiwi-comp}}{{item}}{{/kiwi-comp}}{{/with}}', - { boundText: 'Outer' } - ); + this.render('{{#with boundText as |item|}}{{#kiwi-comp}}{{item}}{{/kiwi-comp}}{{/with}}', { + boundText: 'Outer', + }); this.assertText('InnerOuter'); this.assertStableRerender(); @@ -195,8 +193,7 @@ moduleFor( this.registerComponent('kiwi-comp', { ComponentClass: KiwiCompComponent, - template: - '{{#with boundText as |item|}}

{{item}}

{{yield}}

{{/with}}' + template: '{{#with boundText as |item|}}

{{item}}

{{yield}}

{{/with}}', }); this.render('{{#kiwi-comp}}{{item}}{{/kiwi-comp}}', { item: 'Outer' }); @@ -213,7 +210,7 @@ moduleFor( ['@test can bind a block param to a component and use it in yield']() { this.registerComponent('kiwi-comp', { - template: '

{{content}}

{{yield}}

' + template: '

{{content}}

{{yield}}

', }); this.render( @@ -241,15 +238,15 @@ moduleFor( let parentView = this.get('parentView'); assert.ok(parentView.get('isParentComponent')); - } + }, }); this.registerComponent('parent-comp', { ComponentClass: ParentCompComponent, - template: '{{yield}}' + template: '{{yield}}', }); this.registerComponent('child-comp', { - ComponentClass: ChildCompComponent + ComponentClass: ChildCompComponent, }); this.render('{{#parent-comp}}{{child-comp}}{{/parent-comp}}'); @@ -258,14 +255,12 @@ moduleFor( ['@test yield with nested components (#3220)']() { this.registerComponent('inner-component', { template: '{{yield}}' }); this.registerComponent('outer-component', { - template: - '{{#inner-component}}{{yield}}{{/inner-component}}' + template: '{{#inner-component}}{{yield}}{{/inner-component}}', }); - this.render( - '{{#outer-component}}Hello {{boundText}}{{/outer-component}}', - { boundText: 'world' } - ); + this.render('{{#outer-component}}Hello {{boundText}}{{/outer-component}}', { + boundText: 'world', + }); this.assertText('Hello world'); this.assertStableRerender(); diff --git a/packages/ember-glimmer/tests/integration/input-test.js b/packages/ember-glimmer/tests/integration/input-test.js index f4570770d3e..fbeb847d944 100644 --- a/packages/ember-glimmer/tests/integration/input-test.js +++ b/packages/ember-glimmer/tests/integration/input-test.js @@ -21,11 +21,7 @@ moduleFor( ); this.setComponentValue(values[1]); - this.assertAttributeHasValue( - attributeName, - values[1], - `${attributeName} is set on rerender` - ); + this.assertAttributeHasValue(attributeName, values[1], `${attributeName} is set on rerender`); this.setComponentValue(values[0]); this.assertAttributeHasValue( @@ -53,11 +49,7 @@ moduleFor( ); this.setComponentValue(values[1]); - this.assertPropertyHasValue( - propertyName, - values[1], - `${propertyName} is set on rerender` - ); + this.assertPropertyHasValue(propertyName, values[1], `${propertyName} is set on rerender`); this.setComponentValue(values[0]); this.assertPropertyHasValue( @@ -71,32 +63,16 @@ moduleFor( let value = 'value'; let template = ``; this.render(template, { value: values[0] }); - this.assertPropertyHasValue( - value, - '', - `${value} is set on initial render` - ); + this.assertPropertyHasValue(value, '', `${value} is set on initial render`); this.runTask(() => this.rerender()); - this.assertPropertyHasValue( - value, - '', - `${value} is set on noop rerender` - ); + this.assertPropertyHasValue(value, '', `${value} is set on noop rerender`); this.setComponentValue(values[1]); - this.assertPropertyHasValue( - value, - values[1], - `${value} is set on rerender` - ); + this.assertPropertyHasValue(value, values[1], `${value} is set on rerender`); this.setComponentValue(values[0]); - this.assertPropertyHasValue( - value, - '', - `${value} can be set back to the initial value` - ); + this.assertPropertyHasValue(value, '', `${value} can be set back to the initial value`); } ['@test input disabled attribute']() { @@ -251,19 +227,11 @@ moduleFor( } assertAttributeHasValue(attribute, value, message) { - this.assert.equal( - this.$inputElement().attr(attribute), - value, - `${attribute} ${message}` - ); + this.assert.equal(this.$inputElement().attr(attribute), value, `${attribute} ${message}`); } assertPropertyHasValue(property, value, message) { - this.assert.equal( - this.$inputElement().prop(property), - value, - `${property} ${message}` - ); + this.assert.equal(this.$inputElement().prop(property), value, `${property} ${message}`); } assertSelectionRange(start, end) { diff --git a/packages/ember-glimmer/tests/integration/mount-test.js b/packages/ember-glimmer/tests/integration/mount-test.js index ff6a11bf640..7a5f59fae82 100644 --- a/packages/ember-glimmer/tests/integration/mount-test.js +++ b/packages/ember-glimmer/tests/integration/mount-test.js @@ -66,7 +66,7 @@ moduleFor( Object.keys(engineRegistrations).forEach(fullName => { this.register(fullName, engineRegistrations[fullName]); }); - } + }, }) ); @@ -89,14 +89,11 @@ moduleFor( init() { this._super(); controller = this; - } + }, }); return this.visit('/').then(() => { - assert.ok( - controller, - "engine's application controller has been instantiated" - ); + assert.ok(controller, "engine's application controller has been instantiated"); let engineInstance = getOwner(controller); assert.strictEqual( @@ -130,22 +127,20 @@ moduleFor( { moduleName: 'my-app/templates/application.hbs' } ); this.engineRegistrations['controller:application'] = Controller.extend({ - person: { name: 'Alex' } + person: { name: 'Alex' }, }); - this.engineRegistrations[ - 'template:components/component-with-backtracking-set' - ] = compile('[component {{person.name}}]', { - moduleName: - 'my-app/templates/components/component-with-backtracking-set.hbs' - }); - this.engineRegistrations[ - 'component:component-with-backtracking-set' - ] = Component.extend({ + this.engineRegistrations['template:components/component-with-backtracking-set'] = compile( + '[component {{person.name}}]', + { + moduleName: 'my-app/templates/components/component-with-backtracking-set.hbs', + } + ); + this.engineRegistrations['component:component-with-backtracking-set'] = Component.extend({ init() { this._super(...arguments); this.set('person.name', 'Ben'); - } + }, }); let expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "template:my-app\/templates\/route-with-mount.hbs" \(in "engine:chat"\) and modified in "component:component-with-backtracking-set" \(in "engine:chat"\)/; @@ -169,7 +164,7 @@ moduleFor( init() { this._super(); controller = this; - } + }, }) ); this.addTemplate('bound-engine-name', '{{mount engineName}}'); @@ -183,10 +178,10 @@ moduleFor( this.register( 'template:application', compile('

Foo Engine

', { - moduleName: 'my-app/templates/application.hbs' + moduleName: 'my-app/templates/application.hbs', }) ); - } + }, }) ); this.add( @@ -198,10 +193,10 @@ moduleFor( this.register( 'template:application', compile('

Bar Engine

', { - moduleName: 'my-app/templates/application.hbs' + moduleName: 'my-app/templates/application.hbs', }) ); - } + }, }) ); @@ -248,7 +243,7 @@ moduleFor( init() { this._super(...arguments); controller = this; - } + }, }) ); this.addTemplate('engine-event-dispatcher-singleton', '{{mount "foo"}}'); @@ -262,7 +257,7 @@ moduleFor( this.register( 'template:application', compile('

Foo Engine: {{tagless-component}}

', { - moduleName: 'my-app/templates/application.hbs' + moduleName: 'my-app/templates/application.hbs', }) ); this.register( @@ -272,25 +267,23 @@ moduleFor( init() { this._super(...arguments); component = this; - } + }, }) ); this.register( 'template:components/tagless-component', compile('Tagless Component', { - moduleName: 'my-app/templates/components/tagless-component.hbs' + moduleName: 'my-app/templates/components/tagless-component.hbs', }) ); - } + }, }) ); return this.visit('/engine-event-dispatcher-singleton').then(() => { this.assertInnerHTML('

Foo Engine: Tagless Component

'); - let controllerOwnerEventDispatcher = getOwner(controller).lookup( - 'event_dispatcher:main' - ); + let controllerOwnerEventDispatcher = getOwner(controller).lookup('event_dispatcher:main'); let taglessComponentOwnerEventDispatcher = getOwner(component).lookup( 'event_dispatcher:main' ); @@ -320,10 +313,10 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { this.register( 'template:application', compile('

Param Engine: {{model.foo}}

', { - moduleName: 'my-app/templates/application.hbs' + moduleName: 'my-app/templates/application.hbs', }) ); - } + }, }) ); } @@ -332,10 +325,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { this.router.map(function() { this.route('engine-params-static'); }); - this.addTemplate( - 'engine-params-static', - '{{mount "paramEngine" model=(hash foo="bar")}}' - ); + this.addTemplate('engine-params-static', '{{mount "paramEngine" model=(hash foo="bar")}}'); return this.visit('/engine-params-static').then(() => { this.assertInnerHTML('

Param Engine: bar

'); @@ -354,7 +344,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { init() { this._super(); controller = this; - } + }, }) ); this.addTemplate( @@ -397,11 +387,11 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { }); this.addComponent('foo-component', { - template: `foo-component rendered! - {{app-bar-component}}` + template: `foo-component rendered! - {{app-bar-component}}`, }); this.addComponent('app-bar-component', { ComponentClass: Component.extend({ tagName: '' }), - template: 'rendered app-bar-component from the app' + template: 'rendered app-bar-component from the app', }); this.add( 'engine:componentParamEngine', @@ -412,10 +402,10 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { this.register( 'template:application', compile('{{model.foo}}', { - moduleName: 'my-app/templates/application.hbs' + moduleName: 'my-app/templates/application.hbs', }) ); - } + }, }) ); this.addTemplate( @@ -425,8 +415,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) { return this.visit('/engine-params-contextual-component').then(() => { this.assertComponentElement(this.firstChild, { - content: - 'foo-component rendered! - rendered app-bar-component from the app' + content: 'foo-component rendered! - rendered app-bar-component from the app', }); }); } diff --git a/packages/ember-glimmer/tests/integration/outlet-test.js b/packages/ember-glimmer/tests/integration/outlet-test.js index 5ef9346831a..69bd75974c1 100644 --- a/packages/ember-glimmer/tests/integration/outlet-test.js +++ b/packages/ember-glimmer/tests/integration/outlet-test.js @@ -21,10 +21,10 @@ moduleFor( outlet: 'main', name: 'application', controller: undefined, - template: undefined + template: undefined, }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -42,10 +42,10 @@ moduleFor( outlet: 'main', name: 'application', controller: undefined, - template: undefined + template: undefined, }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -62,9 +62,9 @@ moduleFor( outlet: 'main', name: 'application', controller: {}, - template: this.owner.lookup('template:application') + template: this.owner.lookup('template:application'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -81,9 +81,9 @@ moduleFor( outlet: 'main', name: 'index', controller: {}, - template: this.owner.lookup('template:index') + template: this.owner.lookup('template:index'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -100,9 +100,9 @@ moduleFor( outlet: 'main', name: 'application', controller: {}, - template: this.owner.lookup('template:application') + template: this.owner.lookup('template:application'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -121,9 +121,9 @@ moduleFor( outlet: 'main', name: 'index', controller: {}, - template: this.owner.lookup('template:index') + template: this.owner.lookup('template:index'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -140,9 +140,9 @@ moduleFor( outlet: 'main', name: 'application', controller: {}, - template: this.owner.lookup('template:application') + template: this.owner.lookup('template:application'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -161,9 +161,9 @@ moduleFor( outlet: 'main', name: 'special', controller: {}, - template: this.owner.lookup('template:special') + template: this.owner.lookup('template:special'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -172,10 +172,7 @@ moduleFor( } ['@test does not default outlet name when positional argument is present']() { - this.registerTemplate( - 'application', - '

HI

{{outlet someUndefinedThing}}' - ); + this.registerTemplate('application', '

HI

{{outlet someUndefinedThing}}'); let outletState = { render: { owner: this.owner, @@ -183,9 +180,9 @@ moduleFor( outlet: 'main', name: 'application', controller: {}, - template: this.owner.lookup('template:application') + template: this.owner.lookup('template:application'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -204,9 +201,9 @@ moduleFor( outlet: 'main', name: 'special', controller: {}, - template: this.owner.lookup('template:special') + template: this.owner.lookup('template:special'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -224,9 +221,9 @@ moduleFor( outlet: 'main', name: 'application', controller, - template: this.owner.lookup('template:application') + template: this.owner.lookup('template:application'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -245,9 +242,9 @@ moduleFor( outlet: 'main', name: 'foo', controller: {}, - template: this.owner.lookup('template:foo') + template: this.owner.lookup('template:foo'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.registerTemplate('bar', '

BAR

'); @@ -258,9 +255,9 @@ moduleFor( outlet: 'main', name: 'bar', controller: {}, - template: this.owner.lookup('template:bar') + template: this.owner.lookup('template:bar'), }, - outlets: Object.create(null) + outlets: Object.create(null), }; this.runTask(() => this.component.setOutletState(outletState)); @@ -292,7 +289,7 @@ moduleFor( outlet: 'main', name: 'outer', controller: {}, - template: this.owner.lookup('template:outer') + template: this.owner.lookup('template:outer'), }, outlets: { main: { @@ -302,11 +299,11 @@ moduleFor( outlet: 'main', name: 'inner', controller: {}, - template: this.owner.lookup('template:inner') + template: this.owner.lookup('template:inner'), }, - outlets: Object.create(null) - } - } + outlets: Object.create(null), + }, + }, }; this.runTask(() => this.component.setOutletState(outletState)); diff --git a/packages/ember-glimmer/tests/integration/svg-test.js b/packages/ember-glimmer/tests/integration/svg-test.js index c33b9b3ffa3..e8fec8734f5 100644 --- a/packages/ember-glimmer/tests/integration/svg-test.js +++ b/packages/ember-glimmer/tests/integration/svg-test.js @@ -10,8 +10,8 @@ moduleFor( this.render('
', { model: { - viewBoxString - } + viewBoxString, + }, }); this.assertInnerHTML(strip` @@ -46,8 +46,8 @@ moduleFor( this.render('
', { model: { - viewBoxString - } + viewBoxString, + }, }); this.assertInnerHTML(strip` @@ -80,14 +80,11 @@ moduleFor( ['@test quoted viewBox property is concat']() { let viewBoxString = '100 100'; - this.render( - '
', - { - model: { - viewBoxString - } - } - ); + this.render('
', { + model: { + viewBoxString, + }, + }); this.assertInnerHTML(strip`
@@ -123,8 +120,8 @@ moduleFor( ['@test class is output']() { this.render("
", { model: { - color: 'blue' - } + color: 'blue', + }, }); this.assertInnerHTML(strip` diff --git a/packages/ember-glimmer/tests/integration/syntax/each-in-test.js b/packages/ember-glimmer/tests/integration/syntax/each-in-test.js index de479407f64..651a482debb 100644 --- a/packages/ember-glimmer/tests/integration/syntax/each-in-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/each-in-test.js @@ -7,7 +7,7 @@ import { applyMixins } from '../../utils/abstract-test-case'; import { TogglingSyntaxConditionalsTest, TruthyGenerator, - FalsyGenerator + FalsyGenerator, } from '../../utils/shared-conditional-tests'; function EmptyFunction() {} @@ -43,7 +43,7 @@ applyMixins( EmberObject.create({ 'Not Empty': 1 }), [1], NonEmptyFunction, - NonEmptyConstructor + NonEmptyConstructor, ]), new FalsyGenerator([ @@ -59,7 +59,7 @@ applyMixins( Object.create(null), Object.create({}), Object.create({ 'Not Empty': 1 }), - EmberObject.create() + EmberObject.create(), ]) ); @@ -75,7 +75,7 @@ applyMixins( ObjectProxy.create({ content: Object.create(null) }), ObjectProxy.create({ content: Object.create({}) }), ObjectProxy.create({ content: Object.create({ 'Not Empty': 1 }) }), - ObjectProxy.create({ content: EmberObject.create() }) + ObjectProxy.create({ content: EmberObject.create() }), ]) ); @@ -114,9 +114,7 @@ class AbstractEachInTest extends RenderingTest { } clear() { - return this.runTask(() => - set(this.context, 'hash', this.createHash({}).hash) - ); + return this.runTask(() => set(this.context, 'hash', this.createHash({}).hash)); } setProp(key, value) { @@ -124,9 +122,7 @@ class AbstractEachInTest extends RenderingTest { } updateNestedValue(key, innerKey, value) { - return this.runTask(() => - this.delegate.updateNestedValue(this.context, key, innerKey, value) - ); + return this.runTask(() => this.delegate.updateNestedValue(this.context, key, innerKey, value)); } render(template, context = {}) { @@ -158,9 +154,7 @@ class EachInTest extends AbstractEachInTest { // Not al backing data structures allow kvo tracking. Maps and Iterables don't this.setProp('Tweets', 100); - this.assertText( - 'Smartphones: 8203JavaScript Frameworks: InfinityTweets: 100' - ); + this.assertText('Smartphones: 8203JavaScript Frameworks: InfinityTweets: 100'); } this.clear(); @@ -171,7 +165,7 @@ class EachInTest extends AbstractEachInTest { [`@test it can render sub-paths of each item`](assert) { this.makeHash({ Smartphones: { reports: { unitsSold: 8203 } }, - 'JavaScript Frameworks': { reports: { unitsSold: Infinity } } + 'JavaScript Frameworks': { reports: { unitsSold: Infinity } }, }); this.render( @@ -185,14 +179,10 @@ class EachInTest extends AbstractEachInTest { if (this.allowsSetProp) { this.setProp('Tweets', { reports: { unitsSold: 100 } }); - this.assertText( - 'Smartphones: 8203JavaScript Frameworks: InfinityTweets: 100' - ); + this.assertText('Smartphones: 8203JavaScript Frameworks: InfinityTweets: 100'); } - this.runTask(() => - this.updateNestedValue('Smartphones', 'reports.unitsSold', 8204) - ); + this.runTask(() => this.updateNestedValue('Smartphones', 'reports.unitsSold', 8204)); assert.ok(this.textValue().indexOf('Smartphones: 8204') > -1); @@ -206,16 +196,14 @@ class EachInTest extends AbstractEachInTest { Smartphones: 8203, Tablets: 8203, 'JavaScript Frameworks': Infinity, - Bugs: Infinity + Bugs: Infinity, }); this.render( `
    {{#each-in hash key='@identity' as |category count|}}
  • {{category}}: {{count}}
  • {{/each-in}}
` ); - this.assertText( - 'Smartphones: 8203Tablets: 8203JavaScript Frameworks: InfinityBugs: Infinity' - ); + this.assertText('Smartphones: 8203Tablets: 8203JavaScript Frameworks: InfinityBugs: Infinity'); this.assertStableRerender(); @@ -235,18 +223,18 @@ class EachInTest extends AbstractEachInTest { [`@test it repeats the given block when the hash is dynamic`]() { let { hash: categories } = this.createHash({ Smartphones: 8203, - 'JavaScript Frameworks': Infinity + 'JavaScript Frameworks': Infinity, }); let { hash: otherCategories } = this.createHash({ Emberinios: 533462, - Tweets: 7323 + Tweets: 7323, }); let context = { hashes: { categories, otherCategories, - type: 'categories' - } + type: 'categories', + }, }; this.render( `
    {{#each-in (get hashes hashes.type) as |category count|}}
  • {{category}}: {{count}}
  • {{else}}Empty!{{/each-in}}
`, @@ -279,9 +267,7 @@ class EachInTest extends AbstractEachInTest { ['@test keying off of `undefined` does not render']() { this.makeHash({}); - this.render( - `{{#each-in hash as |key value|}}{{key}}: {{value.baz}}{{else}}Empty!{{/each-in}}` - ); + this.render(`{{#each-in hash as |key value|}}{{key}}: {{value.baz}}{{else}}Empty!{{/each-in}}`); this.assertText('Empty!'); @@ -315,15 +301,15 @@ moduleFor( updateNestedValue(context, key, innerKey, value) { let target = context.hash[key]; set(target, innerKey, value); - } - } + }, + }, }; } [`@test it only iterates over an object's own properties`]() { let protoCategories = { Smartphones: 8203, - 'JavaScript Frameworks': Infinity + 'JavaScript Frameworks': Infinity, }; let categories = Object.create(protoCategories); @@ -363,8 +349,8 @@ moduleFor( { categories: { Smartphones: 8203, - 'JavaScript Frameworks': Infinity - } + 'JavaScript Frameworks': Infinity, + }, } ); @@ -393,7 +379,7 @@ moduleFor( this.runTask(() => { set(this.context, 'categories', { - Emberinios: 123456 + Emberinios: 123456, }); }); @@ -406,7 +392,7 @@ moduleFor( this.runTask(() => { set(this.context, 'categories', { Smartphones: 8203, - 'JavaScript Frameworks': Infinity + 'JavaScript Frameworks': Infinity, }); }); @@ -488,8 +474,8 @@ moduleFor( updateNestedValue(context, key, innerKey, value) { let target = get(context.hash, key); set(target, innerKey, value); - } - } + }, + }, }; } } @@ -513,20 +499,20 @@ moduleFor( updateNestedValue(context, key, innerKey, value) { let target = get(context.hash, key); set(target, innerKey, value); - } - } + }, + }, }; } ['@test it iterates over the content, not the proxy']() { let content = { Smartphones: 8203, - 'JavaScript Frameworks': Infinity + 'JavaScript Frameworks': Infinity, }; let proxy = ObjectProxy.create({ content, - foo: 'bar' + foo: 'bar', }); this.render( @@ -565,7 +551,7 @@ moduleFor( this.runTask(() => { set(proxy, 'content', { Smartphones: 100, - Tablets: 20 + Tablets: 20, }); }); @@ -583,8 +569,8 @@ moduleFor( ObjectProxy.create({ content: { Smartphones: 8203, - 'JavaScript Frameworks': Infinity - } + 'JavaScript Frameworks': Infinity, + }, }) ) ); @@ -613,8 +599,8 @@ moduleFor( updateNestedValue(context, key, innerKey, value) { let target = context.hash.get(key); set(target, innerKey, value); - } - } + }, + }, }; } @@ -666,7 +652,7 @@ if (HAS_NATIVE_SYMBOL) { return accum.concat([[key, pojo[key]]]); }, []); let iterable = { - [Symbol.iterator]: () => makeIterator(ary) + [Symbol.iterator]: () => makeIterator(ary), }; return { hash: iterable, @@ -675,8 +661,8 @@ if (HAS_NATIVE_SYMBOL) { let ary = Array.from(context.hash); let target = ary.find(([k]) => k === key)[1]; set(target, innerKey, value); - } - } + }, + }, }; } } @@ -689,9 +675,7 @@ function makeIterator(ary) { return { next() { - return index < ary.length - ? { value: ary[index++], done: false } - : { done: true }; - } + return index < ary.length ? { value: ary[index++], done: false } : { done: true }; + }, }; } diff --git a/packages/ember-glimmer/tests/integration/syntax/each-test.js b/packages/ember-glimmer/tests/integration/syntax/each-test.js index 26c830fd853..8fbb09c5d68 100644 --- a/packages/ember-glimmer/tests/integration/syntax/each-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/each-test.js @@ -9,7 +9,7 @@ import { TogglingSyntaxConditionalsTest, TruthyGenerator, FalsyGenerator, - ArrayTestCases + ArrayTestCases, } from '../../utils/shared-conditional-tests'; class ArrayDelegate { @@ -161,7 +161,7 @@ const TRUTHY_CASES = [ makeSet(['hello']), new ForEachable(['hello']), ArrayProxy.create({ content: ['hello'] }), - ArrayProxy.create({ content: emberA(['hello']) }) + ArrayProxy.create({ content: emberA(['hello']) }), ]; const FALSY_CASES = [ @@ -175,7 +175,7 @@ const FALSY_CASES = [ makeSet([]), new ForEachable([]), ArrayProxy.create({ content: [] }), - ArrayProxy.create({ content: emberA([]) }) + ArrayProxy.create({ content: emberA([]) }), ]; if (HAS_NATIVE_SYMBOL) { @@ -223,7 +223,7 @@ applyMixins( { foo: 'bar' }, Object.create(null), Object.create({}), - Object.create({ foo: 'bar' }) + Object.create({ foo: 'bar' }), ]) ); @@ -390,9 +390,7 @@ class EachTest extends AbstractEachTest { ['@test it receives the index as the second parameter']() { this.makeList([{ text: 'hello' }, { text: 'world' }]); - this.render( - `{{#each list as |item index|}}[{{index}}. {{item.text}}]{{/each}}` - ); + this.render(`{{#each list as |item index|}}[{{index}}. {{item.text}}]{{/each}}`); this.assertText('[0. hello][1. world]'); @@ -482,9 +480,7 @@ class EachTest extends AbstractEachTest { ['@test it can specify @identity as the key for mixed arrays of objects and primitives']() { this.makeList([1, { id: 2 }, 3]); - this.render( - `{{#each list key='@identity' as |item|}}{{if item.id item.id item}}{{/each}}` - ); + this.render(`{{#each list key='@identity' as |item|}}{{if item.id item.id item}}{{/each}}`); this.assertText('123'); @@ -537,12 +533,12 @@ class EachTest extends AbstractEachTest { didUpdate() { this._isEven(); - } + }, }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, - template: '{{#if isEven}}{{item.value}}{{/if}}' + template: '{{#if isEven}}{{item.value}}{{/if}}', }); this.render(strip` @@ -569,12 +565,7 @@ class EachTest extends AbstractEachTest { ['@test it can render duplicate objects']() { let duplicateItem = { text: 'foo' }; - this.makeList([ - duplicateItem, - duplicateItem, - { text: 'bar' }, - { text: 'baz' } - ]); + this.makeList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); this.render(`{{#each list as |item|}}{{item.text}}{{/each}}`); @@ -590,12 +581,7 @@ class EachTest extends AbstractEachTest { this.assertText('foofoobarbazfoofoo'); - this.replaceList([ - duplicateItem, - duplicateItem, - { text: 'bar' }, - { text: 'baz' } - ]); + this.replaceList([duplicateItem, duplicateItem, { text: 'bar' }, { text: 'baz' }]); this.assertText('foofoobarbaz'); } @@ -677,12 +663,9 @@ class EachTest extends AbstractEachTest { ['@test context is not changed to the inner scope inside an {{#each as}} block']() { this.makeList([{ name: 'Chad' }, { name: 'Zack' }, { name: 'Asa' }]); - this.render( - `{{name}}-{{#each list as |person|}}{{name}}{{/each}}-{{name}}`, - { - name: 'Joel' - } - ); + this.render(`{{name}}-{{#each list as |person|}}{{name}}{{/each}}-{{name}}`, { + name: 'Joel', + }); this.assertText('Joel-JoelJoelJoel-Joel'); @@ -703,18 +686,11 @@ class EachTest extends AbstractEachTest { } ['@test can access the item and the original scope']() { - this.makeList([ - { name: 'Tom Dale' }, - { name: 'Yehuda Katz' }, - { name: 'Godfrey Chan' } - ]); + this.makeList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); - this.render( - `{{#each list key="name" as |person|}}[{{title}}: {{person.name}}]{{/each}}`, - { - title: 'Señor Engineer' - } - ); + this.render(`{{#each list key="name" as |person|}}[{{title}}: {{person.name}}]{{/each}}`, { + title: 'Señor Engineer', + }); this.assertText( '[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]' @@ -739,11 +715,7 @@ class EachTest extends AbstractEachTest { ); this.runTask(() => set(this.context, 'title', 'Señor Engineer')); - this.replaceList([ - { name: 'Tom Dale' }, - { name: 'Yehuda Katz' }, - { name: 'Godfrey Chan' } - ]); + this.replaceList([{ name: 'Tom Dale' }, { name: 'Yehuda Katz' }, { name: 'Godfrey Chan' }]); this.assertText( '[Señor Engineer: Tom Dale][Señor Engineer: Yehuda Katz][Señor Engineer: Godfrey Chan]' @@ -754,7 +726,7 @@ class EachTest extends AbstractEachTest { this.makeList(['Yehuda']); this.render(`{{name}}-{{#each list as |name|}}{{name}}{{/each}}-{{name}}`, { - name: 'Stef' + name: 'Stef', }); this.assertText('Stef-Yehuda-Stef'); @@ -780,12 +752,9 @@ class EachTest extends AbstractEachTest { ['@test inverse template is displayed with context']() { this.makeList([]); - this.render( - `{{#each list as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/each}}`, - { - otherThing: 'bar' - } - ); + this.render(`{{#each list as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/each}}`, { + otherThing: 'bar', + }); this.assertText('No Thing bar'); @@ -821,9 +790,7 @@ class EachTest extends AbstractEachTest { this.makeList([]); - this.render( - `{{#x-wrapper}}{{#each list as |obj|}}[{{obj.text}}]{{/each}}{{/x-wrapper}}` - ); + this.render(`{{#x-wrapper}}{{#each list as |obj|}}[{{obj.text}}]{{/each}}{{/x-wrapper}}`); this.assertText(''); @@ -870,7 +837,7 @@ class EachTest extends AbstractEachTest { `Admin: {{#each admins key="name" as |person|}}[{{person.name}}]{{/each}} User: {{#each users key="name" as |person|}}[{{person.name}}]{{/each}}`, { admins: admins.list, - users: users.list + users: users.list, } ); @@ -889,11 +856,7 @@ class EachTest extends AbstractEachTest { this.runTask(() => { set(this.context, 'admins', this.createList([{ name: 'Tom Dale' }]).list); - set( - this.context, - 'users', - this.createList([{ name: 'Yehuda Katz' }]).list - ); + set(this.context, 'users', this.createList([{ name: 'Yehuda Katz' }]).list); }); this.assertText('Admin: [Tom Dale] User: [Yehuda Katz]'); @@ -901,10 +864,7 @@ class EachTest extends AbstractEachTest { [`@test an outer {{#each}}'s scoped variable does not clobber an inner {{#each}}'s property if they share the same name - Issue #1315`]() { let content = this.createList(['X', 'Y']); - let options = this.createList([ - { label: 'One', value: 1 }, - { label: 'Two', value: 2 } - ]); + let options = this.createList([{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]); this.render( strip` @@ -917,7 +877,7 @@ class EachTest extends AbstractEachTest { `, { content: content.list, - options: options.list + options: options.list, } ); @@ -937,10 +897,7 @@ class EachTest extends AbstractEachTest { set( this.context, 'options', - this.createList([ - { label: 'One', value: 1 }, - { label: 'Two', value: 2 } - ]).list + this.createList([{ label: 'One', value: 1 }, { label: 'Two', value: 2 }]).list ); }); @@ -958,7 +915,7 @@ class EachTest extends AbstractEachTest { ring: 'Greed', first: first.list, fifth: fifth.list, - ninth: ninth.list + ninth: ninth.list, } ); @@ -980,9 +937,7 @@ class EachTest extends AbstractEachTest { ninth.delegate.replace(0, 1, ['K']); }); - this.assertText( - 'O-Limbo-D-K-D-Wrath-K-Wrath-Limbo-I-D-K-D-Wrath-K-Wrath-I-O' - ); + this.assertText('O-Limbo-D-K-D-Wrath-K-Wrath-Limbo-I-D-K-D-Wrath-K-Wrath-I-O'); this.runTask(() => { set(this.context, 'ring', 'Greed'); @@ -1001,7 +956,7 @@ class EachTest extends AbstractEachTest { this.render( `{{#each name key="@index" as |foo|}}{{#each foo as |bar|}}{{bar}}{{/each}}{{/each}}`, { - name: outer.list + name: outer.list, } ); @@ -1019,11 +974,7 @@ class EachTest extends AbstractEachTest { this.assertText('ladybird'); this.runTask(() => - set( - this.context, - 'name', - this.createList([this.createList(['caterpillar']).list]).list - ) + set(this.context, 'name', this.createList([this.createList(['caterpillar']).list]).list) ); this.assertText('caterpillar'); @@ -1106,7 +1057,7 @@ moduleFor( let wrapped = emberA(items); return { list: wrapped, - delegate: ArrayProxy.create({ content: wrapped }) + delegate: ArrayProxy.create({ content: wrapped }), }; } } @@ -1195,27 +1146,17 @@ if (typeof MutationObserver === 'function') { } assertNoMutation() { - this.assert.deepEqual( - this.observer.takeRecords(), - [], - 'Expected no mutations' - ); + this.assert.deepEqual(this.observer.takeRecords(), [], 'Expected no mutations'); } expectMutations() { - this.assert.ok( - this.observer.takeRecords().length > 0, - 'Expected some mutations' - ); + this.assert.ok(this.observer.takeRecords().length > 0, 'Expected some mutations'); } ['@test {{#each}} should not mutate a subtree when the array has not changed [GH #14332]']() { let page = { title: 'Blog Posts' }; - let model = [ - { title: 'Rails is omakase' }, - { title: 'Ember is omakase' } - ]; + let model = [{ title: 'Rails is omakase' }, { title: 'Ember is omakase' }]; this.render( strip` @@ -1262,9 +1203,7 @@ if (typeof MutationObserver === 'function') { .then(() => { this.assertNoMutation(); - this.runTask(() => - set(this.context.page, 'title', 'Think Pieces™') - ); + this.runTask(() => set(this.context.page, 'title', 'Think Pieces™')); this.assertHTML(strip`

Think Pieces™

diff --git a/packages/ember-glimmer/tests/integration/syntax/if-unless-test.js b/packages/ember-glimmer/tests/integration/syntax/if-unless-test.js index 90bf90d52c5..b08dc60d127 100644 --- a/packages/ember-glimmer/tests/integration/syntax/if-unless-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/if-unless-test.js @@ -47,8 +47,8 @@ moduleFor( willDestroy() { this._super(); destroyedChildrenCount++; - } - }) + }, + }), }); this.render( @@ -72,11 +72,7 @@ moduleFor( this.runTask(() => set(this.context, 'cond', false)); this.assertText('Nothing Here!'); - assert.equal( - destroyedChildrenCount, - 3, - 'the children were properly destroyed' - ); + assert.equal(destroyedChildrenCount, 3, 'the children were properly destroyed'); this.runTask(() => set(this.context, 'cond', true)); diff --git a/packages/ember-glimmer/tests/integration/syntax/in-element-test.js b/packages/ember-glimmer/tests/integration/syntax/in-element-test.js index cf166490d2a..db83e6bcf4d 100644 --- a/packages/ember-glimmer/tests/integration/syntax/in-element-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/in-element-test.js @@ -28,7 +28,7 @@ moduleFor( `, { someElement, - text: 'Whoop!' + text: 'Whoop!', } ); @@ -61,10 +61,10 @@ moduleFor( willDestroyElement() { hooks.push('willDestroyElement'); - } + }, }), - template: `{{text}}` + template: `{{text}}`, }); this.render( @@ -78,7 +78,7 @@ moduleFor( { someElement, text: 'Whoop!', - showModal: false + showModal: false, } ); @@ -91,21 +91,21 @@ moduleFor( equalTokens(this.element, ''); this.assertComponentElement(someElement.firstChild, { - content: 'Whoop!' + content: 'Whoop!', }); this.runTask(() => set(this.context, 'text', 'Huzzah!')); equalTokens(this.element, ''); this.assertComponentElement(someElement.firstChild, { - content: 'Huzzah!' + content: 'Huzzah!', }); this.runTask(() => set(this.context, 'text', 'Whoop!')); equalTokens(this.element, ''); this.assertComponentElement(someElement.firstChild, { - content: 'Whoop!' + content: 'Whoop!', }); this.runTask(() => set(this.context, 'showModal', false)); diff --git a/packages/ember-glimmer/tests/integration/syntax/let-test.js b/packages/ember-glimmer/tests/integration/syntax/let-test.js index 911a0a99a94..87e2dc34811 100644 --- a/packages/ember-glimmer/tests/integration/syntax/let-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/let-test.js @@ -37,12 +37,9 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { } ['@test it renders the block if arguments are falsey']() { - this.render( - `{{#let cond1 cond2 as |cond|}}value: "{{cond1}}"{{/let}}`, - { - cond1: false - } - ); + this.render(`{{#let cond1 cond2 as |cond|}}value: "{{cond1}}"{{/let}}`, { + cond1: false, + }); this.assertText('value: "false"'); @@ -60,14 +57,11 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { } ['@test it yields multiple arguments in order']() { - this.render( - `{{#let foo bar baz.name as |a b c|}}{{a}} {{b}} {{c}}{{/let}}`, - { - foo: 'Señor Engineer', - bar: '', - baz: { name: 'Dale' } - } - ); + this.render(`{{#let foo bar baz.name as |a b c|}}{{a}} {{b}} {{c}}{{/let}}`, { + foo: 'Señor Engineer', + bar: '', + baz: { name: 'Dale' }, + }); this.assertText('Señor Engineer Dale'); @@ -79,7 +73,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { ['@test can access alias and original scope']() { this.render(`{{#let person as |tom|}}{{title}}: {{tom.name}}{{/let}}`, { title: 'Señor Engineer', - person: { name: 'Tom Dale' } + person: { name: 'Tom Dale' }, }); this.assertText('Señor Engineer: Tom Dale'); @@ -104,13 +98,10 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { } ['@test the scoped variable is not available outside the {{#let}} block.']() { - this.render( - `{{name}}-{{#let other as |name|}}{{name}}{{/let}}-{{name}}`, - { - name: 'Stef', - other: 'Yehuda' - } - ); + this.render(`{{name}}-{{#let other as |name|}}{{name}}{{/let}}-{{name}}`, { + name: 'Stef', + other: 'Yehuda', + }); this.assertText('Stef-Yehuda-Stef'); @@ -136,7 +127,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { ['@test can access alias of a proxy']() { this.render(`{{#let proxy as |person|}}{{person.name}}{{/let}}`, { - proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }) + proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }), }); this.assertText('Tom Dale'); @@ -149,15 +140,11 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { this.assertText('Yehuda Katz'); - this.runTask(() => - set(this.context, 'proxy.content', { name: 'Godfrey Chan' }) - ); + this.runTask(() => set(this.context, 'proxy.content', { name: 'Godfrey Chan' })); this.assertText('Godfrey Chan'); - this.runTask(() => - set(this.context, 'proxy.content.name', 'Stefan Penner') - ); + this.runTask(() => set(this.context, 'proxy.content.name', 'Stefan Penner')); this.assertText('Stefan Penner'); @@ -166,11 +153,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { this.assertText(''); this.runTask(() => - set( - this.context, - 'proxy', - ObjectProxy.create({ content: { name: 'Tom Dale' } }) - ) + set(this.context, 'proxy', ObjectProxy.create({ content: { name: 'Tom Dale' } })) ); this.assertText('Tom Dale'); @@ -180,7 +163,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { this.render( `{{#let arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/let}}`, { - arrayThing: emberA(['Hello', ' ', 'world']) + arrayThing: emberA(['Hello', ' ', 'world']), } ); @@ -200,20 +183,15 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { this.assertText('Goodbye, world!'); - this.runTask(() => - set(this.context, 'arrayThing', ['Hello', ' ', 'world']) - ); + this.runTask(() => set(this.context, 'arrayThing', ['Hello', ' ', 'world'])); this.assertText('Hello world'); } ['@test `attrs` can be used as a block param [GH#14678]']() { - this.render( - '{{#let hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/let}}', - { - hash: { foo: 'foo' } - } - ); + this.render('{{#let hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/let}}', { + hash: { foo: 'foo' }, + }); this.assertText('[foo-foo]'); @@ -240,7 +218,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { `Admin: {{#let admin as |person|}}{{person.name}}{{/let}} User: {{#let user as |person|}}{{person.name}}{{/let}}`, { admin: { name: 'Tom Dale' }, - user: { name: 'Yehuda Katz' } + user: { name: 'Yehuda Katz' }, } ); @@ -272,7 +250,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { ring: 'Greed', first: 'Limbo', fifth: 'Wrath', - ninth: 'Treachery' + ninth: 'Treachery', } ); @@ -307,12 +285,9 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { } ['@test it should support {{#let name as |foo|}}, then {{#let foo as |bar|}}']() { - this.render( - `{{#let name as |foo|}}{{#let foo as |bar|}}{{bar}}{{/let}}{{/let}}`, - { - name: 'caterpillar' - } - ); + this.render(`{{#let name as |foo|}}{{#let foo as |bar|}}{{bar}}{{/let}}{{/let}}`, { + name: 'caterpillar', + }); this.assertText('caterpillar'); @@ -331,7 +306,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { ['@test updating the context should update the alias']() { this.render(`{{#let this as |person|}}{{person.name}}{{/let}}`, { - name: 'Los Pivots' + name: 'Los Pivots', }); this.assertText('Los Pivots'); @@ -373,29 +348,21 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { { name: 'ebryn', committer1: { name: 'trek' }, - committer2: { name: 'machty' } + committer2: { name: 'machty' }, } ); - this.assertText( - 'ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn' - ); + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); this.runTask(() => this.rerender()); - this.assertText( - 'ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn' - ); + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); this.runTask(() => set(this.context, 'name', 'chancancode')); - this.assertText( - 'chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode' - ); + this.assertText('chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode'); - this.runTask(() => - set(this.context, 'committer1', { name: 'krisselden' }) - ); + this.runTask(() => set(this.context, 'committer1', { name: 'krisselden' })); this.assertText( 'chancancode[krisselden[machty]krisselden]chancancode[machty[krisselden]machty]chancancode' @@ -416,9 +383,7 @@ if (EMBER_TEMPLATE_BLOCK_LET_HELPER) { set(this.context, 'committer2', { name: 'machty' }); }); - this.assertText( - 'ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn' - ); + this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn'); } } ); diff --git a/packages/ember-glimmer/tests/integration/syntax/with-test.js b/packages/ember-glimmer/tests/integration/syntax/with-test.js index d72d92dd011..f8964a1f728 100644 --- a/packages/ember-glimmer/tests/integration/syntax/with-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/with-test.js @@ -45,12 +45,9 @@ moduleFor( } ['@test it renders and hides the given block based on the conditional']() { - this.render( - `{{#with cond1 as |cond|}}{{cond.greeting}}{{else}}False{{/with}}`, - { - cond1: { greeting: 'Hello' } - } - ); + this.render(`{{#with cond1 as |cond|}}{{cond.greeting}}{{else}}False{{/with}}`, { + cond1: { greeting: 'Hello' }, + }); this.assertText('Hello'); @@ -74,7 +71,7 @@ moduleFor( ['@test can access alias and original scope']() { this.render(`{{#with person as |tom|}}{{title}}: {{tom.name}}{{/with}}`, { title: 'Señor Engineer', - person: { name: 'Tom Dale' } + person: { name: 'Tom Dale' }, }); this.assertText('Señor Engineer: Tom Dale'); @@ -99,13 +96,10 @@ moduleFor( } ['@test the scoped variable is not available outside the {{#with}} block.']() { - this.render( - `{{name}}-{{#with other as |name|}}{{name}}{{/with}}-{{name}}`, - { - name: 'Stef', - other: 'Yehuda' - } - ); + this.render(`{{name}}-{{#with other as |name|}}{{name}}{{/with}}-{{name}}`, { + name: 'Stef', + other: 'Yehuda', + }); this.assertText('Stef-Yehuda-Stef'); @@ -134,7 +128,7 @@ moduleFor( `{{#with falsyThing as |thing|}}Has Thing{{else}}No Thing {{otherThing}}{{/with}}`, { falsyThing: null, - otherThing: 'bar' + otherThing: 'bar', } ); @@ -166,7 +160,7 @@ moduleFor( ['@test can access alias of a proxy']() { this.render(`{{#with proxy as |person|}}{{person.name}}{{/with}}`, { - proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }) + proxy: ObjectProxy.create({ content: { name: 'Tom Dale' } }), }); this.assertText('Tom Dale'); @@ -179,15 +173,11 @@ moduleFor( this.assertText('Yehuda Katz'); - this.runTask(() => - set(this.context, 'proxy.content', { name: 'Godfrey Chan' }) - ); + this.runTask(() => set(this.context, 'proxy.content', { name: 'Godfrey Chan' })); this.assertText('Godfrey Chan'); - this.runTask(() => - set(this.context, 'proxy.content.name', 'Stefan Penner') - ); + this.runTask(() => set(this.context, 'proxy.content.name', 'Stefan Penner')); this.assertText('Stefan Penner'); @@ -196,11 +186,7 @@ moduleFor( this.assertText(''); this.runTask(() => - set( - this.context, - 'proxy', - ObjectProxy.create({ content: { name: 'Tom Dale' } }) - ) + set(this.context, 'proxy', ObjectProxy.create({ content: { name: 'Tom Dale' } })) ); this.assertText('Tom Dale'); @@ -210,7 +196,7 @@ moduleFor( this.render( `{{#with arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/with}}`, { - arrayThing: emberA(['Hello', ' ', 'world']) + arrayThing: emberA(['Hello', ' ', 'world']), } ); @@ -230,20 +216,15 @@ moduleFor( this.assertText('Goodbye, world!'); - this.runTask(() => - set(this.context, 'arrayThing', ['Hello', ' ', 'world']) - ); + this.runTask(() => set(this.context, 'arrayThing', ['Hello', ' ', 'world'])); this.assertText('Hello world'); } ['@test `attrs` can be used as a block param [GH#14678]']() { - this.render( - '{{#with hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/with}}', - { - hash: { foo: 'foo' } - } - ); + this.render('{{#with hash as |attrs|}}[{{hash.foo}}-{{attrs.foo}}]{{/with}}', { + hash: { foo: 'foo' }, + }); this.assertText('[foo-foo]'); @@ -270,7 +251,7 @@ moduleFor( `Admin: {{#with admin as |person|}}{{person.name}}{{/with}} User: {{#with user as |person|}}{{person.name}}{{/with}}`, { admin: { name: 'Tom Dale' }, - user: { name: 'Yehuda Katz' } + user: { name: 'Yehuda Katz' }, } ); @@ -302,7 +283,7 @@ moduleFor( ring: 'Greed', first: 'Limbo', fifth: 'Wrath', - ninth: 'Treachery' + ninth: 'Treachery', } ); @@ -337,12 +318,9 @@ moduleFor( } ['@test it should support {{#with name as |foo|}}, then {{#with foo as |bar|}}']() { - this.render( - `{{#with name as |foo|}}{{#with foo as |bar|}}{{bar}}{{/with}}{{/with}}`, - { - name: 'caterpillar' - } - ); + this.render(`{{#with name as |foo|}}{{#with foo as |bar|}}{{bar}}{{/with}}{{/with}}`, { + name: 'caterpillar', + }); this.assertText('caterpillar'); @@ -361,7 +339,7 @@ moduleFor( ['@test updating the context should update the alias']() { this.render(`{{#with this as |person|}}{{person.name}}{{/with}}`, { - name: 'Los Pivots' + name: 'Los Pivots', }); this.assertText('Los Pivots'); @@ -403,7 +381,7 @@ moduleFor( { name: 'ebryn', committer1: { name: 'trek' }, - committer2: { name: 'machty' } + committer2: { name: 'machty' }, } ); @@ -415,13 +393,9 @@ moduleFor( this.runTask(() => set(this.context, 'name', 'chancancode')); - this.assertText( - 'chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode' - ); + this.assertText('chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode'); - this.runTask(() => - set(this.context, 'committer1', { name: 'krisselden' }) - ); + this.runTask(() => set(this.context, 'committer1', { name: 'krisselden' })); this.assertText( 'chancancode[krisselden[machty]krisselden]chancancode[machty[krisselden]machty]chancancode' diff --git a/packages/ember-glimmer/tests/unit/layout-cache-test.js b/packages/ember-glimmer/tests/unit/layout-cache-test.js index 4c95307909f..5941ca881d5 100644 --- a/packages/ember-glimmer/tests/unit/layout-cache-test.js +++ b/packages/ember-glimmer/tests/unit/layout-cache-test.js @@ -12,17 +12,13 @@ moduleFor( // test directly import template factory onto late bound layout let Two = Component.extend({ - layout: this.compile('Two') + layout: this.compile('Two'), }); this.registerComponent('component-two', { ComponentClass: Two }); // inject layout onto component, share layout with component-one this.registerComponent('root-component', { ComponentClass: Component }); - this.owner.inject( - 'component:root-component', - 'layout', - 'template:components/component-one' - ); + this.owner.inject('component:root-component', 'layout', 'template:components/component-one'); // template instance shared between to template managers let rootFactory = this.owner.factoryFor('component:root-component'); @@ -33,7 +29,7 @@ moduleFor( state, { templateCacheHits: 0, - templateCacheMisses: 0 + templateCacheMisses: 0, }, 'precondition' ); @@ -47,16 +43,12 @@ moduleFor( {{component-two}} {{~/if}}`, { - cond: true + cond: true, } ); this.assertText('One'); - state = this.expectCacheChanges( - {}, - state, - 'test case component and component-one no change' - ); + state = this.expectCacheChanges({}, state, 'test case component and component-one no change'); // show component-two for the first time this.runTask(() => set(this.context, 'cond', false)); @@ -64,7 +56,7 @@ moduleFor( this.assertText('Two'); state = this.expectCacheChanges( { - templateCacheMisses: 1 + templateCacheMisses: 1, }, state, 'component-two first render misses template cache' @@ -74,11 +66,7 @@ moduleFor( this.runTask(() => set(this.context, 'cond', true)); this.assertText('One'); - state = this.expectCacheChanges( - {}, - state, - 'toggle back to component-one no change' - ); + state = this.expectCacheChanges({}, state, 'toggle back to component-one no change'); // show component-two again this.runTask(() => set(this.context, 'cond', false)); @@ -86,7 +74,7 @@ moduleFor( this.assertText('Two'); state = this.expectCacheChanges( { - templateCacheHits: 1 + templateCacheHits: 1, }, state, 'toggle back to component-two hits template cache' @@ -98,22 +86,14 @@ moduleFor( runAppend(root); this.assertText('TwoOne'); // roots have different capabilities so this will hit - state = this.expectCacheChanges( - {}, - state, - 'append root with component-one no change' - ); + state = this.expectCacheChanges({}, state, 'append root with component-one no change'); // render new root append let root2 = rootFactory.create(); try { runAppend(root2); this.assertText('TwoOneOne'); - state = this.expectCacheChanges( - {}, - state, - 'append another root no change' - ); + state = this.expectCacheChanges({}, state, 'append another root no change'); } finally { runDestroy(root2); } @@ -123,12 +103,10 @@ moduleFor( } getCacheCounters() { - let { - runtimeResolver: { templateCacheHits, templateCacheMisses } - } = this; + let { runtimeResolver: { templateCacheHits, templateCacheMisses } } = this; return { templateCacheHits, - templateCacheMisses + templateCacheMisses, }; } diff --git a/packages/ember-glimmer/tests/unit/outlet-test.js b/packages/ember-glimmer/tests/unit/outlet-test.js index a61b6cdcb5a..04ffd9a6f93 100644 --- a/packages/ember-glimmer/tests/unit/outlet-test.js +++ b/packages/ember-glimmer/tests/unit/outlet-test.js @@ -14,7 +14,7 @@ moduleFor( didAppendOutletView++; assert.equal(view, outletView); assert.equal(target, expectedOutlet); - } + }, }; let outletView = new OutletView({}, renderer); @@ -40,11 +40,7 @@ moduleFor( ) ); schedule('render', () => - assert.equal( - didAppendOutletView, - 1, - 'appendOutletView should be invoked in render' - ) + assert.equal(didAppendOutletView, 1, 'appendOutletView should be invoked in render') ); }); } diff --git a/packages/ember-glimmer/tests/unit/template-factory-test.js b/packages/ember-glimmer/tests/unit/template-factory-test.js index 144061be8fb..0c369b111a6 100644 --- a/packages/ember-glimmer/tests/unit/template-factory-test.js +++ b/packages/ember-glimmer/tests/unit/template-factory-test.js @@ -6,9 +6,7 @@ import { Component } from '../utils/helpers'; moduleFor( 'Template factory test', class extends RenderingTest { - ['@test the template factory returned from precompile is the same as compile']( - assert - ) { + ['@test the template factory returned from precompile is the same as compile'](assert) { let { owner } = this; let { runtimeResolver } = this; @@ -24,11 +22,7 @@ moduleFor( let Compiled = compile(templateStr, options); - assert.equal( - typeof Precompiled.create, - 'function', - 'precompiled is a factory' - ); + assert.equal(typeof Precompiled.create, 'function', 'precompiled is a factory'); assert.ok(Precompiled.id, 'precompiled has id'); assert.equal(typeof Compiled.create, 'function', 'compiled is a factory'); @@ -52,19 +46,17 @@ moduleFor( this.registerComponent('x-precompiled', { ComponentClass: Component.extend({ - layout: Precompiled - }) + layout: Precompiled, + }), }); this.registerComponent('x-compiled', { ComponentClass: Component.extend({ - layout: Compiled - }) + layout: Compiled, + }), }); - this.render( - '{{x-precompiled name="precompiled"}} {{x-compiled name="compiled"}}' - ); + this.render('{{x-precompiled name="precompiled"}} {{x-compiled name="compiled"}}'); assert.equal(runtimeResolver.templateCacheMisses, 2, 'misses 2'); assert.equal(runtimeResolver.templateCacheHits, 2, 'hits 2'); diff --git a/packages/ember-glimmer/tests/unit/utils/debug-stack-test.js b/packages/ember-glimmer/tests/unit/utils/debug-stack-test.js index b4a0e563ec6..15873c39000 100644 --- a/packages/ember-glimmer/tests/unit/utils/debug-stack-test.js +++ b/packages/ember-glimmer/tests/unit/utils/debug-stack-test.js @@ -22,10 +22,7 @@ moduleFor( stack.pushEngine('engine:my-engine'); stack.push('component:component-in-engine'); - assert.equal( - stack.peek(), - '"component:component-in-engine" (in "engine:my-engine")' - ); + assert.equal(stack.peek(), '"component:component-in-engine" (in "engine:my-engine")'); stack.pop(); stack.pop(); diff --git a/packages/ember-glimmer/tests/utils/abstract-test-case.js b/packages/ember-glimmer/tests/utils/abstract-test-case.js index 5b332b9df88..dc845202428 100644 --- a/packages/ember-glimmer/tests/utils/abstract-test-case.js +++ b/packages/ember-glimmer/tests/utils/abstract-test-case.js @@ -1,5 +1 @@ -export { - AbstractTestCase as TestCase, - applyMixins, - strip -} from 'internal-test-helpers'; +export { AbstractTestCase as TestCase, applyMixins, strip } from 'internal-test-helpers'; diff --git a/packages/ember-glimmer/tests/utils/helpers.js b/packages/ember-glimmer/tests/utils/helpers.js index a1710e35000..fe4ad324989 100644 --- a/packages/ember-glimmer/tests/utils/helpers.js +++ b/packages/ember-glimmer/tests/utils/helpers.js @@ -11,5 +11,5 @@ export { htmlSafe, SafeString, DOMChanges, - isHTMLSafe + isHTMLSafe, } from 'ember-glimmer'; diff --git a/packages/ember-glimmer/tests/utils/shared-conditional-tests.js b/packages/ember-glimmer/tests/utils/shared-conditional-tests.js index 8acd2f3246a..faf89c97999 100644 --- a/packages/ember-glimmer/tests/utils/shared-conditional-tests.js +++ b/packages/ember-glimmer/tests/utils/shared-conditional-tests.js @@ -7,7 +7,7 @@ import { ObjectProxy, A as emberA, ArrayProxy, - removeAt + removeAt, } from 'ember-runtime'; import { Component } from './helpers'; @@ -80,7 +80,7 @@ export class TruthyGenerator extends AbstractGenerator { this.runTask(() => set(this.context, 'cond1', value)); this.assertText('T1'); - } + }, }; } } @@ -104,7 +104,7 @@ export class FalsyGenerator extends AbstractGenerator { this.runTask(() => set(this.context, 'cond1', value)); this.assertText('F1'); - } + }, }; } } @@ -130,7 +130,7 @@ export class StableTruthyGenerator extends TruthyGenerator { this.assertText('T1'); this.assertInvariants(); - } + }, }); } } @@ -156,7 +156,7 @@ export class StableFalsyGenerator extends FalsyGenerator { this.assertText('F1'); this.assertInvariants(); - } + }, }); } } @@ -178,18 +178,14 @@ class ObjectProxyGenerator extends AbstractGenerator { this.assertText('T1'); - this.runTask(() => - set(this.context, 'cond1.content', this.falsyValue) - ); + this.runTask(() => set(this.context, 'cond1.content', this.falsyValue)); this.assertText('F1'); - this.runTask(() => - set(this.context, 'cond1', ObjectProxy.create({ content: value })) - ); + this.runTask(() => set(this.context, 'cond1', ObjectProxy.create({ content: value }))); this.assertText('T1'); - } + }, }; } else { return { @@ -204,18 +200,14 @@ class ObjectProxyGenerator extends AbstractGenerator { this.assertText('F1'); - this.runTask(() => - set(this.context, 'cond1.content', this.truthyValue) - ); + this.runTask(() => set(this.context, 'cond1.content', this.truthyValue)); this.assertText('T1'); - this.runTask(() => - set(this.context, 'cond1', ObjectProxy.create({ content: value })) - ); + this.runTask(() => set(this.context, 'cond1', ObjectProxy.create({ content: value }))); this.assertText('F1'); - } + }, }; } } @@ -285,16 +277,12 @@ export const ObjectTestCases = { this.runTask(() => { set(this.context, 'cond1', ObjectProxy.create({ content: {} })); - set( - this.context, - 'cond2', - ObjectProxy.create({ content: EmberObject.create() }) - ); + set(this.context, 'cond2', ObjectProxy.create({ content: EmberObject.create() })); set(this.context, 'cond3', ObjectProxy.create({ content: null })); }); this.assertText('T1T2F3'); - } + }, }; // Testing behaviors related to arrays and array proxies @@ -354,11 +342,7 @@ export const ArrayTestCases = { this.assertText('T1T2'); this.runTask(() => { - set( - this.context, - 'cond1', - ArrayProxy.create({ content: emberA(['hello']) }) - ); + set(this.context, 'cond1', ArrayProxy.create({ content: emberA(['hello']) })); set(this.context, 'cond2', ArrayProxy.create({ content: null })); }); @@ -389,16 +373,12 @@ export const ArrayTestCases = { this.assertText('T1T2'); this.runTask(() => { - set( - this.context, - 'cond1', - ArrayProxy.create({ content: emberA(['hello']) }) - ); + set(this.context, 'cond1', ArrayProxy.create({ content: emberA(['hello']) })); set(this.context, 'cond2', ArrayProxy.create({ content: emberA() })); }); this.assertText('T1F2'); - } + }, }; const IfUnlessWithTestCases = [ @@ -425,7 +405,7 @@ const IfUnlessWithTestCases = [ new Boolean(true), new Boolean(false), /*jshint +W053 */ - new Date() + new Date(), ]), new StableFalsyGenerator([ @@ -436,7 +416,7 @@ const IfUnlessWithTestCases = [ 0, [], emberA(), - ObjectProxy.create({ content: undefined }) + ObjectProxy.create({ content: undefined }), ]), new ObjectProxyGenerator([ @@ -470,12 +450,12 @@ const IfUnlessWithTestCases = [ '', 0, [], - emberA() + emberA(), ]), ObjectTestCases, - ArrayTestCases + ArrayTestCases, ]; // Testing behaviors shared across the "toggling" conditionals, i.e. {{#if}}, @@ -489,9 +469,7 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { let context = {}; for (let i = 1; i <= values.length; i++) { - templates.push( - this.templateFor({ cond: `cond${i}`, truthy: `t${i}`, falsy: `f${i}` }) - ); + templates.push(this.templateFor({ cond: `cond${i}`, truthy: `t${i}`, falsy: `f${i}` })); context[`t${i}`] = `T${i}`; context[`f${i}`] = `F${i}`; context[`cond${i}`] = values[i - 1]; @@ -504,14 +482,14 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { ['@test it has access to the outer scope from both templates']() { let template = this.wrapperFor([ this.templateFor({ cond: 'cond1', truthy: 'truthy', falsy: 'falsy' }), - this.templateFor({ cond: 'cond2', truthy: 'truthy', falsy: 'falsy' }) + this.templateFor({ cond: 'cond2', truthy: 'truthy', falsy: 'falsy' }), ]); this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', - falsy: 'NO' + falsy: 'NO', }); this.assertText('YESNO'); @@ -549,13 +527,13 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { this.templateFor({ cond: '(unbound cond1)', truthy: '"T1"', - falsy: '"F1"' + falsy: '"F1"', }), this.templateFor({ cond: '(unbound cond2)', truthy: '"T2"', - falsy: '"F2"' - }) + falsy: '"F2"', + }), ]); this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); @@ -605,25 +583,23 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { compute() { truthyEvaluated = true; return 'T'; - } + }, }); this.registerHelper('x-falsy', { compute() { falsyEvaluated = true; return 'F'; - } + }, }); let template = this.wrappedTemplateFor({ cond: 'cond', truthy: '(x-truthy)', - falsy: '(x-falsy)' + falsy: '(x-falsy)', }); - withoutEvaluatingFalsy(() => - this.render(template, { cond: this.truthyValue }) - ); + withoutEvaluatingFalsy(() => this.render(template, { cond: this.truthyValue })); this.assertText('T'); @@ -631,9 +607,7 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { this.assertText('T'); - withoutEvaluatingTruthy(() => - this.runTask(() => set(this.context, 'cond', this.falsyValue)) - ); + withoutEvaluatingTruthy(() => this.runTask(() => set(this.context, 'cond', this.falsyValue))); this.assertText('F'); @@ -641,9 +615,7 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { this.assertText('F'); - withoutEvaluatingFalsy(() => - this.runTask(() => set(this.context, 'cond', this.truthyValue)) - ); + withoutEvaluatingFalsy(() => this.runTask(() => set(this.context, 'cond', this.truthyValue))); this.assertText('T'); } @@ -665,7 +637,7 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { this.templateFor({ cond: `cond${i}`, truthy: `{{t}}${i}`, - falsy: `{{f}}${i}` + falsy: `{{f}}${i}`, }) ); context[`cond${i}`] = values[i - 1]; @@ -679,11 +651,11 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { let template = `${this.templateFor({ cond: '(unbound cond1)', truthy: 'T1', - falsy: 'F1' + falsy: 'F1', })}${this.templateFor({ cond: '(unbound cond2)', truthy: 'T2', - falsy: 'F2' + falsy: 'F2', })}`; this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue }); @@ -718,20 +690,20 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { this.templateFor({ cond: 'cond1', truthy: '{{truthy}}', - falsy: '{{falsy}}' + falsy: '{{falsy}}', }), this.templateFor({ cond: 'cond2', truthy: '{{truthy}}', - falsy: '{{falsy}}' - }) + falsy: '{{falsy}}', + }), ]); this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue, truthy: 'YES', - falsy: 'NO' + falsy: 'NO', }); this.assertText('YESNO'); @@ -769,12 +741,12 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { let inner = this.templateFor({ cond: 'inner', truthy: 'T-inner', - falsy: 'F-inner' + falsy: 'F-inner', }); let template = this.wrappedTemplateFor({ cond: 'outer', truthy: inner, - falsy: 'F-outer' + falsy: 'F-outer', }); this.render(template, { outer: this.truthyValue, inner: this.truthyValue }); @@ -801,12 +773,12 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { let template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{#each inner as |text|}}{{text}}{{/each}}', - falsy: 'F-outer' + falsy: 'F-outer', }); this.render(template, { outer: this.truthyValue, - inner: ['inner', '-', 'before'] + inner: ['inner', '-', 'before'], }); this.assertText('inner-before'); @@ -849,12 +821,12 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { let template = this.wrappedTemplateFor({ cond: 'outer', truthy: '{{{inner}}}', - falsy: 'F-outer' + falsy: 'F-outer', }); this.render(template, { outer: this.truthyValue, - inner: 'inner-before' + inner: 'inner-before', }); this.assertText('inner-before'); @@ -885,24 +857,24 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { init() { this._super(...arguments); childCreated = true; - } - }) + }, + }), }); let innerTemplate = this.templateFor({ cond: 'cond2', truthy: '{{foo-bar}}', - falsy: '' + falsy: '', }); let wrappedTemplate = this.wrappedTemplateFor({ cond: 'cond1', truthy: innerTemplate, - falsy: '' + falsy: '', }); this.render(wrappedTemplate, { cond1: this.truthyValue, - cond2: this.falsyValue + cond2: this.falsyValue, }); assert.ok(!childCreated); @@ -950,25 +922,23 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { compute() { truthyEvaluated = true; return 'T'; - } + }, }); this.registerHelper('x-falsy', { compute() { falsyEvaluated = true; return 'F'; - } + }, }); let template = this.wrappedTemplateFor({ cond: 'cond', truthy: '{{x-truthy}}', - falsy: '{{x-falsy}}' + falsy: '{{x-falsy}}', }); - withoutEvaluatingFalsy(() => - this.render(template, { cond: this.truthyValue }) - ); + withoutEvaluatingFalsy(() => this.render(template, { cond: this.truthyValue })); this.assertText('T'); @@ -976,9 +946,7 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { this.assertText('T'); - withoutEvaluatingTruthy(() => - this.runTask(() => set(this.context, 'cond', this.falsyValue)) - ); + withoutEvaluatingTruthy(() => this.runTask(() => set(this.context, 'cond', this.falsyValue))); this.assertText('F'); @@ -986,9 +954,7 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { this.assertText('F'); - withoutEvaluatingFalsy(() => - this.runTask(() => set(this.context, 'cond', this.truthyValue)) - ); + withoutEvaluatingFalsy(() => this.runTask(() => set(this.context, 'cond', this.truthyValue))); this.assertText('T'); } diff --git a/packages/ember-glimmer/tests/utils/string-test.js b/packages/ember-glimmer/tests/utils/string-test.js index 1673952e5bf..58587ca0ba4 100644 --- a/packages/ember-glimmer/tests/utils/string-test.js +++ b/packages/ember-glimmer/tests/utils/string-test.js @@ -8,40 +8,21 @@ moduleFor( ['@test htmlSafe should return an instance of SafeString']() { let safeString = htmlSafe('you need to be more bold'); - this.assert.ok( - safeString instanceof SafeString, - 'should be a SafeString' - ); + this.assert.ok(safeString instanceof SafeString, 'should be a SafeString'); } ['@test htmlSafe should return an empty string for null']() { let safeString = htmlSafe(null); - this.assert.equal( - safeString instanceof SafeString, - true, - 'should be a SafeString' - ); - this.assert.equal( - safeString.toString(), - '', - 'should return an empty string' - ); + this.assert.equal(safeString instanceof SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); } ['@test htmlSafe should return an instance of SafeString']() { let safeString = htmlSafe(); - this.assert.equal( - safeString instanceof SafeString, - true, - 'should be a SafeString' - ); - this.assert.equal( - safeString.toString(), - '', - 'should return an empty string' - ); + this.assert.equal(safeString instanceof SafeString, true, 'should be a SafeString'); + this.assert.equal(safeString.toString(), '', 'should return an empty string'); } } ); diff --git a/packages/ember-glimmer/tests/utils/test-case.js b/packages/ember-glimmer/tests/utils/test-case.js index b21b2018069..d028c95fc7a 100644 --- a/packages/ember-glimmer/tests/utils/test-case.js +++ b/packages/ember-glimmer/tests/utils/test-case.js @@ -2,5 +2,5 @@ export { AbstractTestCase as TestCase, ApplicationTestCase as ApplicationTest, RenderingTestCase as RenderingTest, - moduleFor + moduleFor, } from 'internal-test-helpers'; diff --git a/packages/ember-glimmer/tests/utils/test-helpers.js b/packages/ember-glimmer/tests/utils/test-helpers.js index 1acb35d7fd1..d3589f26658 100644 --- a/packages/ember-glimmer/tests/utils/test-helpers.js +++ b/packages/ember-glimmer/tests/utils/test-helpers.js @@ -1,6 +1 @@ -export { - styles, - classes, - equalTokens, - equalsElement -} from 'internal-test-helpers'; +export { styles, classes, equalTokens, equalsElement } from 'internal-test-helpers'; diff --git a/packages/ember-metal/lib/alias.js b/packages/ember-metal/lib/alias.js index d3030fcb119..bb145d8c254 100644 --- a/packages/ember-metal/lib/alias.js +++ b/packages/ember-metal/lib/alias.js @@ -70,9 +70,7 @@ export class AliasedProperty extends Descriptor { function AliasedProperty_readOnlySet(obj, keyName) { // eslint-disable-line no-unused-vars - throw new EmberError( - `Cannot set read-only property '${keyName}' on object: ${inspect(obj)}` - ); + throw new EmberError(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`); } function AliasedProperty_oneWaySet(obj, keyName, value) { diff --git a/packages/ember-metal/lib/array.js b/packages/ember-metal/lib/array.js index a7bdd9b63a1..64d4128e1a1 100644 --- a/packages/ember-metal/lib/array.js +++ b/packages/ember-metal/lib/array.js @@ -1,8 +1,5 @@ import { notifyPropertyChange } from './property_events'; -import { - eachProxyArrayDidChange, - eachProxyArrayWillChange -} from './each_proxy'; +import { eachProxyArrayDidChange, eachProxyArrayWillChange } from './each_proxy'; import { peekMeta } from './meta'; import { sendEvent, removeListener, addListener } from './events'; import { peekCacheFor } from './computed'; diff --git a/packages/ember-metal/lib/computed.js b/packages/ember-metal/lib/computed.js index d1119268b4a..9e9f5484611 100644 --- a/packages/ember-metal/lib/computed.js +++ b/packages/ember-metal/lib/computed.js @@ -347,10 +347,7 @@ class ComputedProperty extends Descriptor { if (cache.has(keyName)) { // special-case for computed with no dependent keys used to // trigger cacheable behavior. - if ( - !this._auto && - (!this._dependentKeys || this._dependentKeys.length === 0) - ) { + if (!this._auto && (!this._dependentKeys || this._dependentKeys.length === 0)) { return cache.get(keyName); } @@ -413,9 +410,7 @@ class ComputedProperty extends Descriptor { } _throwReadOnlyError(obj, keyName) { - throw new EmberError( - `Cannot set read-only property "${keyName}" on object: ${inspect(obj)}` - ); + throw new EmberError(`Cannot set read-only property "${keyName}" on object: ${inspect(obj)}`); } clobberSet(obj, keyName, value) { @@ -588,9 +583,7 @@ export default function computed(...args) { } const COMPUTED_PROPERTY_CACHED_VALUES = new WeakMap(); -const COMPUTED_PROPERTY_LAST_REVISION = EMBER_METAL_TRACKED_PROPERTIES - ? new WeakMap() - : undefined; +const COMPUTED_PROPERTY_LAST_REVISION = EMBER_METAL_TRACKED_PROPERTIES ? new WeakMap() : undefined; /** Returns the cached value for a property, if one exists. diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index 7396fc750b3..66c1b957106 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -1,7 +1,6 @@ import { context } from 'ember-environment'; -const Ember = - (typeof context.imports.Ember === 'object' && context.imports.Ember) || {}; +const Ember = (typeof context.imports.Ember === 'object' && context.imports.Ember) || {}; // Make sure these are set whether Ember was already defined or not Ember.isNamespace = true; diff --git a/packages/ember-metal/lib/deprecate_property.js b/packages/ember-metal/lib/deprecate_property.js index 51c363ea11d..b9fd1ae0245 100644 --- a/packages/ember-metal/lib/deprecate_property.js +++ b/packages/ember-metal/lib/deprecate_property.js @@ -37,6 +37,6 @@ export function deprecateProperty(object, deprecatedKey, newKey, options) { get() { _deprecate(); return get(this, newKey); - } + }, }); } diff --git a/packages/ember-metal/lib/error_handler.js b/packages/ember-metal/lib/error_handler.js index 2d857748465..6e3898cf610 100644 --- a/packages/ember-metal/lib/error_handler.js +++ b/packages/ember-metal/lib/error_handler.js @@ -2,7 +2,7 @@ let onerror; export const onErrorTarget = { get onerror() { return onerror; - } + }, }; // Ember.onerror getter diff --git a/packages/ember-metal/lib/events.js b/packages/ember-metal/lib/events.js index e1736371a2d..ecd5ee4730c 100644 --- a/packages/ember-metal/lib/events.js +++ b/packages/ember-metal/lib/events.js @@ -37,10 +37,7 @@ import { meta as metaFor, peekMeta } from './meta'; @public */ export function addListener(obj, eventName, target, method, once) { - assert( - 'You must pass at least an object and event name to addListener', - !!obj && !!eventName - ); + assert('You must pass at least an object and event name to addListener', !!obj && !!eventName); if (ENV._ENABLE_DID_INIT_ATTRS_SUPPORT === true) { deprecate( @@ -49,15 +46,12 @@ export function addListener(obj, eventName, target, method, once) { { id: 'ember-views.did-init-attrs', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + url: 'https://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs', } ); } else { assert( - `didInitAttrs called in ${obj && - obj.toString && - obj.toString()} is no longer supported.`, + `didInitAttrs called in ${obj && obj.toString && obj.toString()} is no longer supported.`, eventName !== 'didInitAttrs' ); } @@ -85,10 +79,7 @@ export function addListener(obj, eventName, target, method, once) { @public */ export function removeListener(obj, eventName, target, method) { - assert( - 'You must pass at least an object and event name to removeListener', - !!obj && !!eventName - ); + assert('You must pass at least an object and event name to removeListener', !!obj && !!eventName); if (!method && 'function' === typeof target) { method = target; @@ -118,10 +109,7 @@ export function removeListener(obj, eventName, target, method) { export function sendEvent(obj, eventName, params, actions, _meta) { if (actions === undefined) { let meta = _meta === undefined ? peekMeta(obj) : _meta; - actions = - typeof meta === 'object' && - meta !== null && - meta.matchingListeners(eventName); + actions = typeof meta === 'object' && meta !== null && meta.matchingListeners(eventName); } if (actions === undefined || actions.length === 0) { diff --git a/packages/ember-metal/lib/expand_properties.js b/packages/ember-metal/lib/expand_properties.js index fafa45dc18f..b9141d03df6 100644 --- a/packages/ember-metal/lib/expand_properties.js +++ b/packages/ember-metal/lib/expand_properties.js @@ -72,9 +72,7 @@ function dive(prefix, pattern, start, callback) { while (i < arrayLength) { newStart = after.indexOf('{'); if (newStart < 0) { - callback( - (prefix + tempArr[i++] + after).replace(END_WITH_EACH_REGEX, '.[]') - ); + callback((prefix + tempArr[i++] + after).replace(END_WITH_EACH_REGEX, '.[]')); } else { dive(prefix + tempArr[i++], after, newStart, callback); } diff --git a/packages/ember-metal/lib/index.js b/packages/ember-metal/lib/index.js index f45e6ba8456..a8d5f2073da 100644 --- a/packages/ember-metal/lib/index.js +++ b/packages/ember-metal/lib/index.js @@ -4,7 +4,7 @@ export { getCacheFor, getCachedValueFor, peekCacheFor, - ComputedProperty + ComputedProperty, } from './computed'; export { default as alias } from './alias'; export { default as merge } from './merge'; @@ -15,14 +15,9 @@ export { _instrumentStart, reset as instrumentationReset, subscribe as instrumentationSubscribe, - unsubscribe as instrumentationUnsubscribe + unsubscribe as instrumentationUnsubscribe, } from './instrumentation'; -export { - getOnerror, - setOnerror, - setDispatchOverride, - getDispatchOverride -} from './error_handler'; +export { getOnerror, setOnerror, setDispatchOverride, getDispatchOverride } from './error_handler'; export { descriptorFor, meta, peekMeta, deleteMeta } from './meta'; export { default as Cache } from './cache'; export { PROXY_CONTENT, _getPath, get, getWithDefault } from './property_get'; @@ -34,20 +29,10 @@ export { addArrayObserver, removeArrayObserver, arrayContentWillChange, - arrayContentDidChange + arrayContentDidChange, } from './array'; -export { - eachProxyFor, - eachProxyArrayWillChange, - eachProxyArrayDidChange -} from './each_proxy'; -export { - addListener, - hasListeners, - on, - removeListener, - sendEvent -} from './events'; +export { eachProxyFor, eachProxyArrayWillChange, eachProxyArrayDidChange } from './each_proxy'; +export { addListener, hasListeners, on, removeListener, sendEvent } from './events'; export { default as isNone } from './is_none'; export { default as isEmpty } from './is_empty'; @@ -71,7 +56,7 @@ export { cancel, debounce, throttle, - _globalsRun + _globalsRun, } from './run_loop'; export { beginPropertyChanges, @@ -81,7 +66,7 @@ export { overrideChains, propertyDidChange, propertyWillChange, - PROPERTY_DID_CHANGE + PROPERTY_DID_CHANGE, } from './property_events'; export { defineProperty, Descriptor } from './properties'; export { watchKey, unwatchKey } from './watch_key'; @@ -95,21 +80,10 @@ export { default as setProperties } from './set_properties'; export { default as expandProperties } from './expand_properties'; export { addObserver, removeObserver } from './observer'; -export { - Mixin, - aliasMethod, - mixin, - observer, - required, - REQUIRED -} from './mixin'; +export { Mixin, aliasMethod, mixin, observer, required, REQUIRED } from './mixin'; export { default as InjectedProperty } from './injected_property'; export { setHasViews, tagForProperty, tagFor, markObjectAsDirty } from './tags'; -export { - default as runInTransaction, - didRender, - assertNotRendered -} from './transaction'; +export { default as runInTransaction, didRender, assertNotRendered } from './transaction'; export { default as descriptor } from './descriptor'; export { tracked } from './tracked'; @@ -124,5 +98,5 @@ export { processAllNamespaces, removeNamespace, isSearchDisabled as isNamespaceSearchDisabled, - setSearchDisabled as setNamespaceSearchDisabled + setSearchDisabled as setNamespaceSearchDisabled, } from './namespace_search'; diff --git a/packages/ember-metal/lib/injected_property.js b/packages/ember-metal/lib/injected_property.js index 447a664fcd1..ab42a0bfe79 100644 --- a/packages/ember-metal/lib/injected_property.js +++ b/packages/ember-metal/lib/injected_property.js @@ -57,6 +57,6 @@ function injectedPropertyGet(keyName) { let specifier = `${desc.type}:${desc.name || keyName}`; return owner.lookup(specifier, { source: desc.source, - namespace: desc.namespace + namespace: desc.namespace, }); } diff --git a/packages/ember-metal/lib/instrumentation.js b/packages/ember-metal/lib/instrumentation.js index e0e4d67db78..ad68189ff0a 100644 --- a/packages/ember-metal/lib/instrumentation.js +++ b/packages/ember-metal/lib/instrumentation.js @@ -224,7 +224,7 @@ export function subscribe(pattern, object) { let subscriber = { pattern, regex: new RegExp(`^${regex}$`), - object + object, }; subscribers.push(subscriber); diff --git a/packages/ember-metal/lib/libraries.js b/packages/ember-metal/lib/libraries.js index 08235744b17..355f96a34cc 100644 --- a/packages/ember-metal/lib/libraries.js +++ b/packages/ember-metal/lib/libraries.js @@ -41,7 +41,7 @@ export class Libraries { this._registry.splice(index, 0, { name, version }); } else { warn(`Library "${name}" is already registered with Ember.`, false, { - id: 'ember-metal.libraries-register' + id: 'ember-metal.libraries-register', }); } } diff --git a/packages/ember-metal/lib/map.js b/packages/ember-metal/lib/map.js index e00059c3aba..af9dae555a1 100644 --- a/packages/ember-metal/lib/map.js +++ b/packages/ember-metal/lib/map.js @@ -161,10 +161,7 @@ class OrderedSet { @private */ forEach(fn /*, ...thisArg*/) { - assert( - `${Object.prototype.toString.call(fn)} is not a function`, - typeof fn === 'function' - ); + assert(`${Object.prototype.toString.call(fn)} is not a function`, typeof fn === 'function'); if (this.size === 0) { return; @@ -448,7 +445,7 @@ class MapWithDefault extends Map { return copyMap( this, new Constructor({ - defaultValue: this.defaultValue + defaultValue: this.defaultValue, }) ); } diff --git a/packages/ember-metal/lib/meta.js b/packages/ember-metal/lib/meta.js index fb8a3ebb121..297de499a69 100644 --- a/packages/ember-metal/lib/meta.js +++ b/packages/ember-metal/lib/meta.js @@ -2,11 +2,7 @@ import { lookupDescriptor, symbol, toString } from 'ember-utils'; import { protoMethods as listenerMethods } from './meta_listeners'; import { assert } from 'ember-debug'; import { DEBUG } from 'ember-env-flags'; -import { - DESCRIPTOR_TRAP, - EMBER_METAL_ES5_GETTERS, - MANDATORY_SETTER -} from 'ember/features'; +import { DESCRIPTOR_TRAP, EMBER_METAL_ES5_GETTERS, MANDATORY_SETTER } from 'ember/features'; import { removeChainWatcher } from './chains'; import { ENV } from 'ember-environment'; @@ -19,7 +15,7 @@ if (DEBUG) { setCalls: 0, deleteCalls: 0, metaCalls: 0, - metaInstantiated: 0 + metaInstantiated: 0, }; } @@ -295,9 +291,7 @@ export class Meta { writableTag(create) { assert( this.isMetaDestroyed() && - `Cannot create a new tag for \`${toString( - this.source - )}\` after it has been destroyed.`, + `Cannot create a new tag for \`${toString(this.source)}\` after it has been destroyed.`, !this.isMetaDestroyed() ); let ret = this._tag; @@ -333,9 +327,7 @@ export class Meta { writableChains(create) { assert( this.isMetaDestroyed() && - `Cannot create a new chains for \`${toString( - this.source - )}\` after it has been destroyed.`, + `Cannot create a new chains for \`${toString(this.source)}\` after it has been destroyed.`, !this.isMetaDestroyed() ); let ret = this._chains; @@ -459,9 +451,7 @@ export class Meta { ); assert( this.isMetaDestroyed() && - `Cannot clear bindings on \`${toString( - this.source - )}\` after it has been destroyed.`, + `Cannot clear bindings on \`${toString(this.source)}\` after it has been destroyed.`, !this.isMetaDestroyed() ); this._bindings = undefined; @@ -753,11 +743,7 @@ export function isDescriptorTrap(possibleDesc) { @private */ export function isDescriptor(possibleDesc) { - return ( - possibleDesc !== null && - typeof possibleDesc === 'object' && - possibleDesc.isDescriptor - ); + return possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; } export { counters }; diff --git a/packages/ember-metal/lib/meta_listeners.js b/packages/ember-metal/lib/meta_listeners.js index ff01c96e200..0d837ae2dd3 100644 --- a/packages/ember-metal/lib/meta_listeners.js +++ b/packages/ember-metal/lib/meta_listeners.js @@ -47,9 +47,7 @@ export const protoMethods = { for (let index = listeners.length - 4; index >= 0; index -= 4) { if ( listeners[index] === eventName && - (!method || - (listeners[index + 1] === target && - listeners[index + 2] === method)) + (!method || (listeners[index + 1] === target && listeners[index + 2] === method)) ) { if (pointer === this) { listeners.splice(index, 4); // we are modifying our own list, so we edit directly @@ -89,21 +87,14 @@ export const protoMethods = { pointer = pointer.parent; } return result; - } + }, }; function pushUniqueListener(destination, source, index) { let target = source[index + 1]; let method = source[index + 2]; - for ( - let destinationIndex = 0; - destinationIndex < destination.length; - destinationIndex += 3 - ) { - if ( - destination[destinationIndex] === target && - destination[destinationIndex + 1] === method - ) { + for (let destinationIndex = 0; destinationIndex < destination.length; destinationIndex += 3) { + if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) { return; } } diff --git a/packages/ember-metal/lib/mixin.js b/packages/ember-metal/lib/mixin.js index 7bb4b79af29..dc4b7dd3ecb 100644 --- a/packages/ember-metal/lib/mixin.js +++ b/packages/ember-metal/lib/mixin.js @@ -48,9 +48,7 @@ function concatenatedMixinProperties(concatProp, props, values, base) { // reset before adding each new mixin to pickup concats from previous let concats = values[concatProp] || base[concatProp]; if (props[concatProp]) { - concats = concats - ? a_concat.call(concats, props[concatProp]) - : props[concatProp]; + concats = concats ? a_concat.call(concats, props[concatProp]) : props[concatProp]; } return concats; } @@ -70,10 +68,7 @@ function giveDescriptorSuper(meta, key, property, values, descs, base) { superProperty = descriptorFor(base, key, meta); } - if ( - superProperty === undefined || - !(superProperty instanceof ComputedProperty) - ) { + if (superProperty === undefined || !(superProperty instanceof ComputedProperty)) { return property; } @@ -174,22 +169,9 @@ function applyMergedProperties(obj, key, value, values) { return newBase; } -function addNormalizedProperty( - base, - key, - value, - meta, - descs, - values, - concats, - mergings -) { +function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { if (value instanceof Descriptor) { - if ( - ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT && - value === REQUIRED && - descs[key] - ) { + if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT && value === REQUIRED && descs[key]) { return CONTINUE; } @@ -230,9 +212,7 @@ function mergeMixins(mixins, meta, descs, values, base, keys) { for (let i = 0; i < mixins.length; i++) { currentMixin = mixins[i]; assert( - `Expected hash or Mixin instance, got ${Object.prototype.toString.call( - currentMixin - )}`, + `Expected hash or Mixin instance, got ${Object.prototype.toString.call(currentMixin)}`, typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]' @@ -248,34 +228,15 @@ function mergeMixins(mixins, meta, descs, values, base, keys) { if (base.willMergeMixin) { base.willMergeMixin(props); } - concats = concatenatedMixinProperties( - 'concatenatedProperties', - props, - values, - base - ); - mergings = concatenatedMixinProperties( - 'mergedProperties', - props, - values, - base - ); + concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); + mergings = concatenatedMixinProperties('mergedProperties', props, values, base); for (key in props) { if (!props.hasOwnProperty(key)) { continue; } keys.push(key); - addNormalizedProperty( - base, - key, - props[key], - meta, - descs, - values, - concats, - mergings - ); + addNormalizedProperty(base, key, props[key], meta, descs, values, concats, mergings); } // manually copy toString() because some JS engines do not enumerate it @@ -319,18 +280,8 @@ function updateObserversAndListeners(obj, key, paths, updateMethod) { function replaceObserversAndListeners(obj, key, prev, next) { if (typeof prev === 'function') { - updateObserversAndListeners( - obj, - key, - prev.__ember_observes__, - removeObserver - ); - updateObserversAndListeners( - obj, - key, - prev.__ember_listens__, - removeListener - ); + updateObserversAndListeners(obj, key, prev.__ember_observes__, removeObserver); + updateObserversAndListeners(obj, key, prev.__ember_listens__, removeListener); } if (typeof next === 'function') { @@ -397,11 +348,7 @@ function applyMixin(obj, mixins, partial) { defineProperty(obj, key, desc, value, meta); } - if ( - ENV._ENABLE_BINDING_SUPPORT && - !partial && - typeof Mixin.finishProtype === 'function' - ) { + if (ENV._ENABLE_BINDING_SUPPORT && !partial && typeof Mixin.finishProtype === 'function') { Mixin.finishPartial(obj, meta); } @@ -643,9 +590,7 @@ function buildMixinsArray(mixins) { for (let i = 0; i < length; i++) { let x = mixins[i]; assert( - `Expected hash or Mixin instance, got ${Object.prototype.toString.call( - x - )}`, + `Expected hash or Mixin instance, got ${Object.prototype.toString.call(x)}`, typeof x === 'object' && x !== null && Object.prototype.toString.call(x) !== '[object Array]' @@ -721,11 +666,10 @@ REQUIRED.toString = () => '(Required Property)'; @private */ export function required() { - deprecate( - 'Ember.required is deprecated as its behavior is inconsistent and unreliable.', - false, - { id: 'ember-metal.required', until: '3.0.0' } - ); + deprecate('Ember.required is deprecated as its behavior is inconsistent and unreliable.', false, { + id: 'ember-metal.required', + until: '3.0.0', + }); return REQUIRED; } diff --git a/packages/ember-metal/lib/namespace_search.js b/packages/ember-metal/lib/namespace_search.js index f36e52bedcc..26ede84cd26 100644 --- a/packages/ember-metal/lib/namespace_search.js +++ b/packages/ember-metal/lib/namespace_search.js @@ -19,7 +19,7 @@ const flags = { set unprocessedNamespaces(v) { this._set++; this._unprocessedNamespaces = v; - } + }, }; let unprocessedMixins = false; @@ -163,8 +163,7 @@ function tryIsNamespace(lookup, prop) { try { let obj = lookup[prop]; return ( - ((obj !== null && typeof obj === 'object') || - typeof obj === 'function') && + ((obj !== null && typeof obj === 'object') || typeof obj === 'function') && obj.isNamespace && obj ); diff --git a/packages/ember-metal/lib/properties.js b/packages/ember-metal/lib/properties.js index 6519d4cc62d..f63e04bc7e4 100644 --- a/packages/ember-metal/lib/properties.js +++ b/packages/ember-metal/lib/properties.js @@ -4,19 +4,9 @@ import { assert } from 'ember-debug'; import { HAS_NATIVE_PROXY, HAS_NATIVE_SYMBOL } from 'ember-utils'; -import { - descriptorFor, - meta as metaFor, - peekMeta, - DESCRIPTOR, - UNDEFINED -} from './meta'; +import { descriptorFor, meta as metaFor, peekMeta, DESCRIPTOR, UNDEFINED } from './meta'; import { overrideChains } from './property_events'; -import { - DESCRIPTOR_TRAP, - EMBER_METAL_ES5_GETTERS, - MANDATORY_SETTER -} from 'ember/features'; +import { DESCRIPTOR_TRAP, EMBER_METAL_ES5_GETTERS, MANDATORY_SETTER } from 'ember/features'; // .......................................................... // DESCRIPTOR // @@ -149,7 +139,7 @@ if (EMBER_METAL_ES5_GETTERS) { } assert(messageFor(obj, keyName, property, descriptor[property])); - } + }, }); }; } else { @@ -160,30 +150,23 @@ if (EMBER_METAL_ES5_GETTERS) { configurable: false, enumerable: false, writable: false, - value: descriptor + value: descriptor, }); trap.toString = trap.toJSON = trap.valueOf = () => '[COMPUTED PROPERTY]'; // Without a proxy, we can only trap the "likely" properties - [ - 'isDescriptor', - 'setup', - 'teardown', - 'get', - '_getter', - 'set', - '_setter', - 'meta' - ].forEach(property => { - Object.defineProperty(trap, property, { - configurable: false, - enumerable: false, - get() { - assert(messageFor(obj, keyName, property, descriptor[property])); - } - }); - }); + ['isDescriptor', 'setup', 'teardown', 'get', '_getter', 'set', '_setter', 'meta'].forEach( + property => { + Object.defineProperty(trap, property, { + configurable: false, + enumerable: false, + get() { + assert(messageFor(obj, keyName, property, descriptor[property])); + }, + }); + } + ); return trap; }; @@ -287,21 +270,21 @@ export function defineProperty(obj, keyName, desc, data, meta) { Object.defineProperty(obj, keyName, { configurable: true, enumerable, - get: DESCRIPTOR_GETTER_FUNCTION(keyName, value) + get: DESCRIPTOR_GETTER_FUNCTION(keyName, value), }); } else if (MANDATORY_SETTER && watching) { Object.defineProperty(obj, keyName, { configurable: true, enumerable, writable: true, - value + value, }); } else if (enumerable === false) { Object.defineProperty(obj, keyName, { configurable: true, writable: true, enumerable, - value + value, }); } else { obj[keyName] = value; @@ -324,7 +307,7 @@ export function defineProperty(obj, keyName, desc, data, meta) { configurable: true, enumerable, set: MANDATORY_SETTER_FUNCTION(keyName), - get: DEFAULT_GETTER_FUNCTION(keyName) + get: DEFAULT_GETTER_FUNCTION(keyName), }; Object.defineProperty(obj, keyName, defaultDescriptor); @@ -333,14 +316,14 @@ export function defineProperty(obj, keyName, desc, data, meta) { configurable: true, enumerable, writable: true, - value + value, }); } else if (enumerable === false) { Object.defineProperty(obj, keyName, { configurable: true, enumerable, writable: true, - value + value, }); } else { obj[keyName] = data; diff --git a/packages/ember-metal/lib/property_events.js b/packages/ember-metal/lib/property_events.js index 0a526b8c4cc..f9bb27f45f0 100644 --- a/packages/ember-metal/lib/property_events.js +++ b/packages/ember-metal/lib/property_events.js @@ -35,7 +35,7 @@ function propertyWillChange() { id: 'ember-metal.deprecate-propertyWillChange', until: '3.5.0', url: - 'https://emberjs.com/deprecations/v3.x/#toc_use-notifypropertychange-instead-of-propertywillchange-and-propertydidchange' + 'https://emberjs.com/deprecations/v3.x/#toc_use-notifypropertychange-instead-of-propertywillchange-and-propertydidchange', } ); } @@ -53,7 +53,7 @@ function propertyDidChange(obj, keyName, _meta) { id: 'ember-metal.deprecate-propertyDidChange', until: '3.5.0', url: - 'https://emberjs.com/deprecations/v3.x/#toc_use-notifypropertychange-instead-of-propertywillchange-and-propertydidchange' + 'https://emberjs.com/deprecations/v3.x/#toc_use-notifypropertychange-instead-of-propertywillchange-and-propertydidchange', } ); @@ -242,5 +242,5 @@ export { overrideChains, beginPropertyChanges, endPropertyChanges, - changeProperties + changeProperties, }; diff --git a/packages/ember-metal/lib/property_get.js b/packages/ember-metal/lib/property_get.js index dd678cd18df..16019a737a2 100644 --- a/packages/ember-metal/lib/property_get.js +++ b/packages/ember-metal/lib/property_get.js @@ -8,22 +8,17 @@ import { DESCRIPTOR_TRAP, EMBER_METAL_ES5_GETTERS, EMBER_METAL_TRACKED_PROPERTIES, - MANDATORY_GETTER + MANDATORY_GETTER, } from 'ember/features'; import { isPath } from './path_cache'; -import { - isDescriptor, - isDescriptorTrap, - DESCRIPTOR, - descriptorFor -} from './meta'; +import { isDescriptor, isDescriptorTrap, DESCRIPTOR, descriptorFor } from './meta'; import { getCurrentTracker } from './tracked'; import { tagForProperty } from './tags'; const ALLOWABLE_TYPES = { object: true, function: true, - string: true + string: true, }; export const PROXY_CONTENT = symbol('PROXY_CONTENT'); @@ -91,8 +86,7 @@ export function get(obj, keyName) { ); assert( `The key provided to get must be a string or number, you passed ${keyName}`, - typeof keyName === 'string' || - (typeof keyName === 'number' && !isNaN(keyName)) + typeof keyName === 'string' || (typeof keyName === 'number' && !isNaN(keyName)) ); assert( `'this' in paths is not supported`, @@ -134,7 +128,7 @@ export function get(obj, keyName) { id: 'ember-meta.descriptor-on-object', until: '3.5.0', url: - 'https://emberjs.com/deprecations/v3.x#toc_use-defineProperty-to-define-computed-properties' + 'https://emberjs.com/deprecations/v3.x#toc_use-defineProperty-to-define-computed-properties', } ); descriptor = value; diff --git a/packages/ember-metal/lib/property_set.js b/packages/ember-metal/lib/property_set.js index d668b76dd8b..7943b14cdc1 100644 --- a/packages/ember-metal/lib/property_set.js +++ b/packages/ember-metal/lib/property_set.js @@ -1,24 +1,11 @@ import { toString } from 'ember-utils'; import { assert, Error as EmberError } from 'ember-debug'; -import { - getPossibleMandatoryProxyValue, - _getPath as getPath -} from './property_get'; +import { getPossibleMandatoryProxyValue, _getPath as getPath } from './property_get'; import { notifyPropertyChange } from './property_events'; import { isPath } from './path_cache'; -import { - isDescriptor, - isDescriptorTrap, - peekMeta, - DESCRIPTOR, - descriptorFor -} from './meta'; -import { - DESCRIPTOR_TRAP, - EMBER_METAL_ES5_GETTERS, - MANDATORY_SETTER -} from 'ember/features'; +import { isDescriptor, isDescriptorTrap, peekMeta, DESCRIPTOR, descriptorFor } from './meta'; +import { DESCRIPTOR_TRAP, EMBER_METAL_ES5_GETTERS, MANDATORY_SETTER } from 'ember/features'; /** @module @ember/object */ @@ -53,8 +40,7 @@ export function set(obj, keyName, value, tolerant) { ); assert( `The key provided to set must be a string or number, you passed ${keyName}`, - typeof keyName === 'string' || - (typeof keyName === 'number' && !isNaN(keyName)) + typeof keyName === 'string' || (typeof keyName === 'number' && !isNaN(keyName)) ); assert( `'this' in paths is not supported`, @@ -63,9 +49,7 @@ export function set(obj, keyName, value, tolerant) { if (obj.isDestroyed) { assert( - `calling set on destroyed object: ${toString( - obj - )}.${keyName} = ${toString(value)}`, + `calling set on destroyed object: ${toString(obj)}.${keyName} = ${toString(value)}`, tolerant ); return; @@ -143,10 +127,7 @@ function setPath(root, path, value, tolerant) { let parts = path.split('.'); let keyName = parts.pop(); - assert( - 'Property set failed: You passed an empty path', - keyName.trim().length > 0 - ); + assert('Property set failed: You passed an empty path', keyName.trim().length > 0); let newPath = parts.join('.'); diff --git a/packages/ember-metal/lib/run_loop.js b/packages/ember-metal/lib/run_loop.js index 6f9c08116db..c3587fd384d 100644 --- a/packages/ember-metal/lib/run_loop.js +++ b/packages/ember-metal/lib/run_loop.js @@ -42,19 +42,19 @@ export const queues = [ // used to re-throw unhandled RSVP rejection errors specifically in this // position to avoid breaking anything rendered in the other sections - P`rsvpAfter` + P`rsvpAfter`, ]; export const backburner = new Backburner(queues, { sync: { before: beginPropertyChanges, - after: endPropertyChanges + after: endPropertyChanges, }, defaultQueue: 'actions', onBegin, onEnd, onErrorTarget, - onErrorMethod: 'onerror' + onErrorMethod: 'onerror', }); /** @@ -301,11 +301,10 @@ export function schedule(queue /*, target, method */) { `You will need to wrap any code with asynchronous side-effects in a run`, currentRunLoop || !isTesting() ); - deprecate( - `Scheduling into the '${queue}' run loop queue is deprecated.`, - queue !== 'sync', - { id: 'ember-metal.run.sync', until: '3.5.0' } - ); + deprecate(`Scheduling into the '${queue}' run loop queue is deprecated.`, queue !== 'sync', { + id: 'ember-metal.run.sync', + until: '3.5.0', + }); return backburner.schedule(...arguments); } @@ -457,11 +456,10 @@ export function scheduleOnce(queue /*, target, method*/) { `You will need to wrap any code with asynchronous side-effects in a run`, currentRunLoop || !isTesting() ); - deprecate( - `Scheduling into the '${queue}' run loop queue is deprecated.`, - queue !== 'sync', - { id: 'ember-metal.run.sync', until: '3.5.0' } - ); + deprecate(`Scheduling into the '${queue}' run loop queue is deprecated.`, queue !== 'sync', { + id: 'ember-metal.run.sync', + until: '3.5.0', + }); return backburner.scheduleOnce(...arguments); } diff --git a/packages/ember-metal/lib/tags.js b/packages/ember-metal/lib/tags.js index 2538fe67cba..e79420c597b 100644 --- a/packages/ember-metal/lib/tags.js +++ b/packages/ember-metal/lib/tags.js @@ -1,9 +1,4 @@ -import { - CONSTANT_TAG, - UpdatableTag, - DirtyableTag, - combine -} from '@glimmer/reference'; +import { CONSTANT_TAG, UpdatableTag, DirtyableTag, combine } from '@glimmer/reference'; import { isProxy } from 'ember-utils'; import { EMBER_METAL_TRACKED_PROPERTIES } from 'ember/features'; import { meta as metaFor } from './meta'; @@ -19,9 +14,7 @@ function makeTag() { return DirtyableTag.create(); } -export const TRACKED_GETTERS = EMBER_METAL_TRACKED_PROPERTIES - ? new WeakMap() - : undefined; +export const TRACKED_GETTERS = EMBER_METAL_TRACKED_PROPERTIES ? new WeakMap() : undefined; export function tagForProperty(object, propertyKey, _meta) { if (typeof object !== 'object' || object === null) { diff --git a/packages/ember-metal/lib/tracked.js b/packages/ember-metal/lib/tracked.js index 4d2af8f6317..7a7d5a81751 100644 --- a/packages/ember-metal/lib/tracked.js +++ b/packages/ember-metal/lib/tracked.js @@ -147,7 +147,7 @@ function descriptorForAccessor(key, descriptor) { enumerable: true, configurable: false, get: get && getter, - set: set && setter + set: set && setter, }; } /** @@ -178,7 +178,7 @@ function descriptorForDataProperty(key, descriptor) { dirty(tagForProperty(this, key)); this[shadowKey] = newValue; propertyDidChange(); - } + }, }; } let propertyDidChange = function() {}; diff --git a/packages/ember-metal/lib/transaction.js b/packages/ember-metal/lib/transaction.js index 5d897a8b8a9..c2722324043 100644 --- a/packages/ember-metal/lib/transaction.js +++ b/packages/ember-metal/lib/transaction.js @@ -45,7 +45,7 @@ if (EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER) { if (DEBUG) { this.setKey(object, key, { lastRef: reference, - lastRenderedIn: this.debugStack.peek() + lastRenderedIn: this.debugStack.peek(), }); } else { this.setKey(object, key, this.transactionId); diff --git a/packages/ember-metal/lib/watch_key.js b/packages/ember-metal/lib/watch_key.js index 3e2ea975aca..fa5d6518ff1 100644 --- a/packages/ember-metal/lib/watch_key.js +++ b/packages/ember-metal/lib/watch_key.js @@ -1,16 +1,10 @@ import { lookupDescriptor } from 'ember-utils'; import { MANDATORY_SETTER } from 'ember/features'; -import { - descriptorFor, - isDescriptor, - meta as metaFor, - peekMeta, - UNDEFINED -} from './meta'; +import { descriptorFor, isDescriptor, meta as metaFor, peekMeta, UNDEFINED } from './meta'; import { MANDATORY_SETTER_FUNCTION, DEFAULT_GETTER_FUNCTION, - INHERITING_GETTER_FUNCTION + INHERITING_GETTER_FUNCTION, } from './properties'; let handleMandatorySetter; @@ -40,10 +34,8 @@ export function watchKey(obj, keyName, _meta) { } if (MANDATORY_SETTER) { - let hasOwnProperty = (obj, key) => - Object.prototype.hasOwnProperty.call(obj, key); - let propertyIsEnumerable = (obj, key) => - Object.prototype.propertyIsEnumerable.call(obj, key); + let hasOwnProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); + let propertyIsEnumerable = (obj, key) => Object.prototype.propertyIsEnumerable.call(obj, key); // Future traveler, although this code looks scary. It merely exists in // development to aid in development asertions. Production builds of @@ -65,7 +57,7 @@ if (MANDATORY_SETTER) { configurable: true, set: MANDATORY_SETTER_FUNCTION(keyName), enumerable: propertyIsEnumerable(obj, keyName), - get: undefined + get: undefined, }; if (hasOwnProperty(obj, keyName)) { @@ -115,14 +107,8 @@ export function unwatchKey(obj, keyName, _meta) { if (!isDescriptor && keyName in obj) { let maybeMandatoryDescriptor = lookupDescriptor(obj, keyName); - if ( - maybeMandatoryDescriptor.set && - maybeMandatoryDescriptor.set.isMandatorySetter - ) { - if ( - maybeMandatoryDescriptor.get && - maybeMandatoryDescriptor.get.isInheritingGetter - ) { + if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) { + if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) { let possibleValue = meta.readInheritedValue('values', keyName); if (possibleValue === UNDEFINED) { delete obj[keyName]; @@ -132,12 +118,9 @@ export function unwatchKey(obj, keyName, _meta) { Object.defineProperty(obj, keyName, { configurable: true, - enumerable: Object.prototype.propertyIsEnumerable.call( - obj, - keyName - ), + enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), writable: true, - value: meta.peekValues(keyName) + value: meta.peekValues(keyName), }); meta.deleteFromValues(keyName); } diff --git a/packages/ember-metal/tests/accessors/get_path_test.js b/packages/ember-metal/tests/accessors/get_path_test.js index 5a46db1adec..dc5615564c9 100644 --- a/packages/ember-metal/tests/accessors/get_path_test.js +++ b/packages/ember-metal/tests/accessors/get_path_test.js @@ -11,20 +11,20 @@ moduleFor( obj = { foo: { bar: { - baz: { biff: 'BIFF' } - } + baz: { biff: 'BIFF' }, + }, }, foothis: { bar: { - baz: { biff: 'BIFF' } - } + baz: { biff: 'BIFF' }, + }, }, falseValue: false, emptyString: '', Wuz: { - nar: 'foo' + nar: 'foo', }, - nullValue: null + nullValue: null, }; } diff --git a/packages/ember-metal/tests/accessors/get_properties_test.js b/packages/ember-metal/tests/accessors/get_properties_test.js index 3a77e631a2d..317d0043787 100644 --- a/packages/ember-metal/tests/accessors/get_properties_test.js +++ b/packages/ember-metal/tests/accessors/get_properties_test.js @@ -10,25 +10,25 @@ moduleFor( let obj = { firstName: 'Steve', lastName: 'Jobs', - companyName: 'Apple, Inc.' + companyName: 'Apple, Inc.', }; assert.deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', - lastName: 'Jobs' + lastName: 'Jobs', }); assert.deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', - lastName: 'Jobs' + lastName: 'Jobs', }); assert.deepEqual(getProperties(obj, 'lastName'), { lastName: 'Jobs' }); assert.deepEqual(getProperties(obj), {}); assert.deepEqual(getProperties(obj, ['firstName', 'lastName']), { firstName: 'Steve', - lastName: 'Jobs' + lastName: 'Jobs', }); assert.deepEqual(getProperties(obj, ['firstName']), { - firstName: 'Steve' + firstName: 'Steve', }); assert.deepEqual(getProperties(obj, []), {}); } diff --git a/packages/ember-metal/tests/accessors/get_test.js b/packages/ember-metal/tests/accessors/get_test.js index 3ecbf8e668a..b89706b3c52 100644 --- a/packages/ember-metal/tests/accessors/get_test.js +++ b/packages/ember-metal/tests/accessors/get_test.js @@ -15,7 +15,7 @@ moduleFor( number: 23, boolTrue: true, boolFalse: false, - nullValue: null + nullValue: null, }; for (let key in obj) { @@ -26,15 +26,13 @@ moduleFor( } } - ['@test implicitly computing the values of descriptors on properties is deprecated']( - assert - ) { + ['@test implicitly computing the values of descriptors on properties is deprecated'](assert) { let cp = computed(() => 'value'); let obj = { cp, toString() { return 'myobject'; - } + }, }; let result; @@ -64,7 +62,7 @@ moduleFor( let obj = { get id() { return ++count; - } + }, }; get(obj, 'id'); @@ -79,7 +77,7 @@ moduleFor( unknownProperty(key) { assert.equal(key, 'foo', 'should pass key'); return 'FOO'; - } + }, }; assert.equal(get(obj, 'foo'), 'FOO', 'should return value from unknown'); } @@ -92,13 +90,9 @@ moduleFor( unknownProperty(key) { assert.equal(key, 'foo', 'should pass key'); return 'FOO'; - } + }, }; - assert.equal( - aget(obj, 'foo'), - 'FOO', - 'should return value from unknown' - ); + assert.equal(aget(obj, 'foo'), 'FOO', 'should return value from unknown'); } else { assert.ok('SKIPPING ACCESSORS'); } @@ -164,10 +158,7 @@ moduleFor( () => get(obj, false), /The key provided to get must be a string or number, you passed false/ ); - expectAssertion( - () => get(obj, ''), - /Cannot call `get` with an empty string/ - ); + expectAssertion(() => get(obj, ''), /Cannot call `get` with an empty string/); } // .......................................................... @@ -179,7 +170,7 @@ moduleFor( ) { let MyMixin = Mixin.create({ someProperty: 'foo', - propertyDidChange: observer('someProperty', () => {}) + propertyDidChange: observer('someProperty', () => {}), }); let baseObject = MyMixin.apply({}); @@ -203,7 +194,7 @@ moduleFor( number: 23, boolTrue: true, boolFalse: false, - nullValue: null + nullValue: null, }; for (let key in obj) { @@ -214,7 +205,7 @@ moduleFor( } obj = { - undef: undefined + undef: undefined, }; assert.equal( @@ -229,32 +220,28 @@ moduleFor( ); } - ['@test should call unknownProperty if defined and value is undefined']( - assert - ) { + ['@test should call unknownProperty if defined and value is undefined'](assert) { let obj = { count: 0, unknownProperty(key) { assert.equal(key, 'foo', 'should pass key'); this.count++; return 'FOO'; - } + }, }; assert.equal(get(obj, 'foo'), 'FOO', 'should return value from unknown'); assert.equal(obj.count, 1, 'should have invoked'); } - ['@test if unknownProperty is present, it is called using getFromEmberMetal()/set()']( - assert - ) { + ['@test if unknownProperty is present, it is called using getFromEmberMetal()/set()'](assert) { let obj = { unknownProperty(key) { if (key === 'foo') { assert.equal(key, 'foo', 'should pass key'); return 'FOO'; } - } + }, }; assert.equal( getWithDefault(obj, 'foo', 'fail'), @@ -268,9 +255,7 @@ moduleFor( ); } - ['@test if unknownProperty is present, it is called using accessors']( - assert - ) { + ['@test if unknownProperty is present, it is called using accessors'](assert) { if (ENV.USES_ACCESSORS) { let obj = { unknownProperty(key) { @@ -278,13 +263,9 @@ moduleFor( assert.equal(key, 'foo', 'should pass key'); return 'FOO'; } - } + }, }; - assert.equal( - aget(obj, 'foo', 'fail'), - 'FOO', - 'should return value from unknownProperty' - ); + assert.equal(aget(obj, 'foo', 'fail'), 'FOO', 'should return value from unknownProperty'); assert.equal( aget(obj, 'bar', 'default'), 'default', @@ -306,7 +287,7 @@ moduleFor( someProperty: 'foo', propertyDidChange: observer('someProperty', () => { /* nothing to do */ - }) + }), }); let baseObject = MyMixin.apply({}); diff --git a/packages/ember-metal/tests/accessors/mandatory_setters_test.js b/packages/ember-metal/tests/accessors/mandatory_setters_test.js index c611fc66c73..ece110d363f 100644 --- a/packages/ember-metal/tests/accessors/mandatory_setters_test.js +++ b/packages/ember-metal/tests/accessors/mandatory_setters_test.js @@ -4,10 +4,7 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; function hasMandatorySetter(object, property) { try { - return ( - Object.getOwnPropertyDescriptor(object, property).set - .isMandatorySetter === true - ); + return Object.getOwnPropertyDescriptor(object, property).set.isMandatorySetter === true; } catch (e) { return false; } @@ -26,16 +23,14 @@ if (MANDATORY_SETTER) { someProp: null, toString() { return 'custom-object'; - } + }, }; obj.someProp = 'blastix'; assert.equal(get(obj, 'someProp'), 'blastix'); } - ['@test should not setup mandatory-setter if property is not writable']( - assert - ) { + ['@test should not setup mandatory-setter if property is not writable'](assert) { assert.expect(6); let obj = {}; @@ -46,11 +41,11 @@ if (MANDATORY_SETTER) { Object.defineProperty(obj, 'd', { value: undefined, writable: false }); Object.defineProperty(obj, 'e', { value: undefined, - configurable: false + configurable: false, }); Object.defineProperty(obj, 'f', { value: undefined, - configurable: true + configurable: true, }); watch(obj, 'a'); @@ -60,30 +55,12 @@ if (MANDATORY_SETTER) { watch(obj, 'e'); watch(obj, 'f'); - assert.ok( - !hasMandatorySetter(obj, 'a'), - 'mandatory-setter should not be installed' - ); - assert.ok( - !hasMandatorySetter(obj, 'b'), - 'mandatory-setter should not be installed' - ); - assert.ok( - !hasMandatorySetter(obj, 'c'), - 'mandatory-setter should not be installed' - ); - assert.ok( - !hasMandatorySetter(obj, 'd'), - 'mandatory-setter should not be installed' - ); - assert.ok( - !hasMandatorySetter(obj, 'e'), - 'mandatory-setter should not be installed' - ); - assert.ok( - !hasMandatorySetter(obj, 'f'), - 'mandatory-setter should not be installed' - ); + assert.ok(!hasMandatorySetter(obj, 'a'), 'mandatory-setter should not be installed'); + assert.ok(!hasMandatorySetter(obj, 'b'), 'mandatory-setter should not be installed'); + assert.ok(!hasMandatorySetter(obj, 'c'), 'mandatory-setter should not be installed'); + assert.ok(!hasMandatorySetter(obj, 'd'), 'mandatory-setter should not be installed'); + assert.ok(!hasMandatorySetter(obj, 'e'), 'mandatory-setter should not be installed'); + assert.ok(!hasMandatorySetter(obj, 'f'), 'mandatory-setter should not be installed'); } ['@test should not teardown non mandatory-setter descriptor'](assert) { @@ -92,7 +69,7 @@ if (MANDATORY_SETTER) { let obj = { get a() { return 'hi'; - } + }, }; watch(obj, 'a'); @@ -107,7 +84,7 @@ if (MANDATORY_SETTER) { let obj = { get a() { return 'hi'; - } + }, }; watch(obj, 'a'); @@ -115,9 +92,7 @@ if (MANDATORY_SETTER) { assert.equal(obj.a, 'hi'); } - ['@test should not setup mandatory-setter if setter is already setup on property']( - assert - ) { + ['@test should not setup mandatory-setter if setter is already setup on property'](assert) { assert.expect(2); let obj = { someProp: null }; @@ -129,27 +104,22 @@ if (MANDATORY_SETTER) { set(value) { assert.equal(value, 'foo-bar', 'custom setter was called'); - } + }, }); watch(obj, 'someProp'); - assert.ok( - !hasMandatorySetter(obj, 'someProp'), - 'mandatory-setter should not be installed' - ); + assert.ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); obj.someProp = 'foo-bar'; } - ['@test watched ES5 setter should not be smashed by mandatory setter']( - assert - ) { + ['@test watched ES5 setter should not be smashed by mandatory setter'](assert) { let value; let obj = { get foo() {}, set foo(_value) { value = _value; - } + }, }; watch(obj, 'foo'); @@ -172,16 +142,13 @@ if (MANDATORY_SETTER) { set(value) { assert.equal(value, 'foo-bar', 'custom setter was called'); - } + }, }); let obj = new Foo(); watch(obj, 'someProp'); - assert.ok( - !hasMandatorySetter(obj, 'someProp'), - 'mandatory-setter should not be installed' - ); + assert.ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); obj.someProp = 'foo-bar'; } @@ -200,7 +167,7 @@ if (MANDATORY_SETTER) { set(value) { assert.equal(value, 'foo-bar', 'custom setter was called'); - } + }, }); function Bar() {} @@ -210,10 +177,7 @@ if (MANDATORY_SETTER) { let obj = new Bar(); watch(obj, 'someProp'); - assert.ok( - !hasMandatorySetter(obj, 'someProp'), - 'mandatory-setter should not be installed' - ); + assert.ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); obj.someProp = 'foo-bar'; } @@ -232,7 +196,7 @@ if (MANDATORY_SETTER) { set(value) { assert.equal(value, 'foo-bar', 'custom setter was called'); - } + }, }); function Bar() {} @@ -246,10 +210,7 @@ if (MANDATORY_SETTER) { let obj = new Qux(); watch(obj, 'someProp'); - assert.ok( - !hasMandatorySetter(obj, 'someProp'), - 'mandatory-setter should not be installed' - ); + assert.ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); obj.someProp = 'foo-bar'; } @@ -259,7 +220,7 @@ if (MANDATORY_SETTER) { someProp: null, toString() { return 'custom-object'; - } + }, }; watch(obj, 'someProp'); @@ -269,14 +230,12 @@ if (MANDATORY_SETTER) { }, 'You must use set() to set the `someProp` property (of custom-object) to `foo-bar`.'); } - ['@test should not assert if set with set when property is being watched']( - assert - ) { + ['@test should not assert if set with set when property is being watched'](assert) { let obj = { someProp: null, toString() { return 'custom-object'; - } + }, }; watch(obj, 'someProp'); @@ -290,13 +249,13 @@ if (MANDATORY_SETTER) { someProp: null, toString() { return 'custom-object'; - } + }, }; Object.defineProperty(obj, 'someProp', { configurable: false, enumerable: true, - value: 'blastix' + value: 'blastix', }); watch(obj, 'someProp'); @@ -310,57 +269,31 @@ if (MANDATORY_SETTER) { someProp: null, toString() { return 'custom-object'; - } + }, }; Object.defineProperty(obj, 'someProp', { configurable: true, enumerable: false, - value: 'blastix' + value: 'blastix', }); watch(obj, 'someProp'); - assert.equal( - hasMandatorySetter(obj, 'someProp'), - true, - 'should have a mandatory setter' - ); + assert.equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); let descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); - assert.equal( - descriptor.enumerable, - false, - 'property should remain non-enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - obj.someProp, - 'blastix', - 'expected value to be the getter' - ); + assert.equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(obj.someProp, 'blastix', 'expected value to be the getter'); - assert.equal( - descriptor.value, - undefined, - 'expected existing value to NOT remain' - ); + assert.equal(descriptor.value, undefined, 'expected existing value to NOT remain'); - assert.ok( - hasMetaValue(obj, 'someProp'), - 'someProp is stored in meta.values' - ); + assert.ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); unwatch(obj, 'someProp'); - assert.ok( - !hasMetaValue(obj, 'someProp'), - 'someProp is no longer stored in meta.values' - ); + assert.ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); @@ -370,52 +303,20 @@ if (MANDATORY_SETTER) { 'should no longer have a mandatory setter' ); - assert.equal( - descriptor.enumerable, - false, - 'property should remain non-enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - obj.someProp, - 'blastix', - 'expected value to be the getter' - ); - assert.equal( - descriptor.value, - 'blastix', - 'expected existing value to remain' - ); + assert.equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(obj.someProp, 'blastix', 'expected value to be the getter'); + assert.equal(descriptor.value, 'blastix', 'expected existing value to remain'); obj.someProp = 'new value'; // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); - assert.equal( - descriptor.enumerable, - false, - 'property should remain non-enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - descriptor.value, - 'new value', - 'expected existing value to NOT remain' - ); - assert.equal( - obj.someProp, - 'new value', - 'expected value to be the getter' - ); + assert.equal(descriptor.enumerable, false, 'property should remain non-enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); + assert.equal(obj.someProp, 'new value', 'expected value to be the getter'); assert.equal(obj.someProp, 'new value'); } @@ -426,57 +327,31 @@ if (MANDATORY_SETTER) { someProp: null, toString() { return 'custom-object'; - } + }, }; Object.defineProperty(obj, 'someProp', { configurable: true, enumerable: true, - value: 'blastix' + value: 'blastix', }); watch(obj, 'someProp'); - assert.equal( - hasMandatorySetter(obj, 'someProp'), - true, - 'should have a mandatory setter' - ); + assert.equal(hasMandatorySetter(obj, 'someProp'), true, 'should have a mandatory setter'); let descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); - assert.equal( - descriptor.enumerable, - true, - 'property should remain enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - obj.someProp, - 'blastix', - 'expected value to be the getter' - ); + assert.equal(descriptor.enumerable, true, 'property should remain enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(obj.someProp, 'blastix', 'expected value to be the getter'); - assert.equal( - descriptor.value, - undefined, - 'expected existing value to NOT remain' - ); + assert.equal(descriptor.value, undefined, 'expected existing value to NOT remain'); - assert.ok( - hasMetaValue(obj, 'someProp'), - 'someProp is stored in meta.values' - ); + assert.ok(hasMetaValue(obj, 'someProp'), 'someProp is stored in meta.values'); unwatch(obj, 'someProp'); - assert.ok( - !hasMetaValue(obj, 'someProp'), - 'someProp is no longer stored in meta.values' - ); + assert.ok(!hasMetaValue(obj, 'someProp'), 'someProp is no longer stored in meta.values'); descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); @@ -486,70 +361,37 @@ if (MANDATORY_SETTER) { 'should no longer have a mandatory setter' ); - assert.equal( - descriptor.enumerable, - true, - 'property should remain enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - obj.someProp, - 'blastix', - 'expected value to be the getter' - ); - assert.equal( - descriptor.value, - 'blastix', - 'expected existing value to remain' - ); + assert.equal(descriptor.enumerable, true, 'property should remain enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(obj.someProp, 'blastix', 'expected value to be the getter'); + assert.equal(descriptor.value, 'blastix', 'expected existing value to remain'); obj.someProp = 'new value'; // make sure the descriptor remains correct (nothing funky, like a redefined, happened in the setter); descriptor = Object.getOwnPropertyDescriptor(obj, 'someProp'); - assert.equal( - descriptor.enumerable, - true, - 'property should remain enumerable' - ); - assert.equal( - descriptor.configurable, - true, - 'property should remain configurable' - ); - assert.equal( - descriptor.value, - 'new value', - 'expected existing value to NOT remain' - ); + assert.equal(descriptor.enumerable, true, 'property should remain enumerable'); + assert.equal(descriptor.configurable, true, 'property should remain configurable'); + assert.equal(descriptor.value, 'new value', 'expected existing value to NOT remain'); assert.equal(obj.someProp, 'new value'); } - ['@test sets up mandatory-setter if property comes from prototype']( - assert - ) { + ['@test sets up mandatory-setter if property comes from prototype'](assert) { assert.expect(2); let obj = { someProp: null, toString() { return 'custom-object'; - } + }, }; let obj2 = Object.create(obj); watch(obj2, 'someProp'); - assert.ok( - hasMandatorySetter(obj2, 'someProp'), - 'mandatory setter has been setup' - ); + assert.ok(hasMandatorySetter(obj2, 'someProp'), 'mandatory setter has been setup'); expectAssertion(function() { obj2.someProp = 'foo-bar'; @@ -589,7 +431,7 @@ if (MANDATORY_SETTER) { Object.defineProperty(Parent.prototype, 'food', { get() { return this._food; - } + }, }); let child = new Parent('chips'); @@ -608,22 +450,13 @@ if (MANDATORY_SETTER) { assert.equal(child.food, 'icecreame'); - let foodDesc = Object.getOwnPropertyDescriptor( - Parent.prototype, - 'food' - ); - assert.ok( - !foodDesc.configurable, - 'Parent.prototype.food desc should be non configable' - ); - assert.ok( - !foodDesc.enumerable, - 'Parent.prototype.food desc should be non enumerable' - ); + let foodDesc = Object.getOwnPropertyDescriptor(Parent.prototype, 'food'); + assert.ok(!foodDesc.configurable, 'Parent.prototype.food desc should be non configable'); + assert.ok(!foodDesc.enumerable, 'Parent.prototype.food desc should be non enumerable'); assert.equal( foodDesc.get.call({ - _food: 'hi' + _food: 'hi', }), 'hi' ); diff --git a/packages/ember-metal/tests/accessors/set_path_test.js b/packages/ember-metal/tests/accessors/set_path_test.js index 4300826aef8..812f1f2be52 100644 --- a/packages/ember-metal/tests/accessors/set_path_test.js +++ b/packages/ember-metal/tests/accessors/set_path_test.js @@ -11,9 +11,9 @@ function commonSetup() { obj = { foo: { bar: { - baz: { biff: 'BIFF' } - } - } + baz: { biff: 'BIFF' }, + }, + }, }; } @@ -38,7 +38,7 @@ moduleFor( lookup.Foo = { toString() { return 'Foo'; - } + }, }; // Behave like an Ember.Namespace set(lookup.Foo, 'bar', 'baz'); diff --git a/packages/ember-metal/tests/accessors/set_test.js b/packages/ember-metal/tests/accessors/set_test.js index 491bd1675d5..d159de71c6c 100644 --- a/packages/ember-metal/tests/accessors/set_test.js +++ b/packages/ember-metal/tests/accessors/set_test.js @@ -15,7 +15,7 @@ moduleFor( boolTrue: true, boolFalse: false, nullValue: null, - undefinedValue: undefined + undefinedValue: undefined, }; let newObj = {}; @@ -25,11 +25,7 @@ moduleFor( continue; } - assert.equal( - set(newObj, key, obj[key]), - obj[key], - 'should return value' - ); + assert.equal(set(newObj, key, obj[key]), obj[key], 'should return value'); assert.ok(key in newObj, 'should have key'); assert.ok(newObj.hasOwnProperty(key), 'should have key'); assert.equal(get(newObj, key), obj[key], 'should set value'); @@ -50,17 +46,12 @@ moduleFor( assert.deepEqual(arr, ['first', 'lol']); } - ['@test should call setUnknownProperty if defined and value is undefined']( - assert - ) { + ['@test should call setUnknownProperty if defined and value is undefined'](assert) { let obj = { count: 0, unknownProperty() { - assert.ok( - false, - 'should not invoke unknownProperty if setUnknownProperty is defined' - ); + assert.ok(false, 'should not invoke unknownProperty if setUnknownProperty is defined'); }, setUnknownProperty(key, value) { @@ -68,7 +59,7 @@ moduleFor( assert.equal(value, 'BAR', 'should pass key'); this.count++; return 'FOO'; - } + }, }; assert.equal(set(obj, 'foo', 'BAR'), 'BAR', 'should return set value'); @@ -118,9 +109,7 @@ moduleFor( ); } - ['@test does not trigger auto-run assertion for objects that have not been tagged']( - assert - ) { + ['@test does not trigger auto-run assertion for objects that have not been tagged'](assert) { setHasViews(() => true); let obj = {}; @@ -129,17 +118,11 @@ moduleFor( assert.equal(obj.foo, 'bar'); } - ['@test does not warn on attempts of calling set on a destroyed object with `trySet`']( - assert - ) { + ['@test does not warn on attempts of calling set on a destroyed object with `trySet`'](assert) { let obj = { isDestroyed: true }; trySet(obj, 'favoriteFood', 'hot dogs'); - assert.equal( - obj.favoriteFood, - undefined, - 'does not set and does not error' - ); + assert.equal(obj.favoriteFood, undefined, 'does not set and does not error'); } } ); diff --git a/packages/ember-metal/tests/alias_test.js b/packages/ember-metal/tests/alias_test.js index 19021e23d77..f6f254b4c6d 100644 --- a/packages/ember-metal/tests/alias_test.js +++ b/packages/ember-metal/tests/alias_test.js @@ -7,7 +7,7 @@ import { isWatching, addObserver, removeObserver, - tagFor + tagFor, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -81,9 +81,7 @@ moduleFor( assert.equal(count, 1); } - ['@test an observer of the alias works if added after defining the alias']( - assert - ) { + ['@test an observer of the alias works if added after defining the alias'](assert) { defineProperty(obj, 'bar', alias('foo.faz')); addObserver(obj, 'bar', incrementCount); assert.ok(isWatching(obj, 'foo.faz')); @@ -91,9 +89,7 @@ moduleFor( assert.equal(count, 1); } - ['@test an observer of the alias works if added before defining the alias']( - assert - ) { + ['@test an observer of the alias works if added before defining the alias'](assert) { addObserver(obj, 'bar', incrementCount); defineProperty(obj, 'bar', alias('foo.faz')); assert.ok(isWatching(obj, 'foo.faz')); @@ -111,10 +107,7 @@ moduleFor( let tagValue = tag.value(); set(obj, 'foo.faz', 'BAR'); - assert.ok( - !tag.validate(tagValue), - 'setting the aliased key should dirty the object' - ); + assert.ok(!tag.validate(tagValue), 'setting the aliased key should dirty the object'); } ['@test setting alias on self should fail assertion']() { diff --git a/packages/ember-metal/tests/chains_test.js b/packages/ember-metal/tests/chains_test.js index 66f10bf98d4..18c1f0e46be 100644 --- a/packages/ember-metal/tests/chains_test.js +++ b/packages/ember-metal/tests/chains_test.js @@ -10,16 +10,14 @@ import { meta, watch, unwatch, - watcherCount + watcherCount, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'Chains', class extends AbstractTestCase { - ['@test finishChains should properly copy chains from prototypes to instances']( - assert - ) { + ['@test finishChains should properly copy chains from prototypes to instances'](assert) { function didChange() {} let obj = {}; @@ -40,7 +38,7 @@ moduleFor( ['@test does not observe primitive values'](assert) { let obj = { - foo: { bar: 'STRING' } + foo: { bar: 'STRING' }, }; addObserver(obj, 'foo.bar.baz', null, function() {}); diff --git a/packages/ember-metal/tests/computed_test.js b/packages/ember-metal/tests/computed_test.js index 7d01b5cc0fc..fd1878e13e5 100644 --- a/packages/ember-metal/tests/computed_test.js +++ b/packages/ember-metal/tests/computed_test.js @@ -10,7 +10,7 @@ import { set, isWatching, addObserver, - meta as metaFor + meta as metaFor, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -40,7 +40,7 @@ moduleFor( computed({ get() {}, set() {}, - other() {} + other() {}, }); }, 'Config object passed to computed can only contain `get` and `set` keys.'); } @@ -72,7 +72,7 @@ moduleFor( let obj = { toString() { return 'obj'; - } + }, }; let count = 0; defineProperty( @@ -88,15 +88,8 @@ moduleFor( () => obj.foo.isDescriptor, /You attempted to access `foo\.isDescriptor` \(on `obj`\)/ ); - expectAssertion( - () => obj.foo.get(), - /You attempted to access `foo\.get` \(on `obj`\)/ - ); - assert.strictEqual( - count, - 0, - 'should not have invoked computed property' - ); + expectAssertion(() => obj.foo.get(), /You attempted to access `foo\.get` \(on `obj`\)/); + assert.strictEqual(count, 0, 'should not have invoked computed property'); } else { assert.expect(0); } @@ -132,7 +125,7 @@ moduleFor( count++; this['__' + key] = 'computed ' + value; return this['__' + key]; - } + }, }) ); @@ -189,7 +182,7 @@ moduleFor( set(key, value) { this['__' + key] = 'computed ' + value; return this['__' + key]; - } + }, }) ); @@ -235,7 +228,7 @@ moduleFor( set(key, value) { this['__' + key] = 'computed ' + value; return this['__' + key]; - } + }, }) ); @@ -281,7 +274,7 @@ moduleFor( set(key, value) { this['__' + key] = 'A ' + value; return this['__' + key]; - } + }, }) ); @@ -297,7 +290,7 @@ moduleFor( set(key, value) { this['__' + key] = 'B ' + value; return this['__' + key]; - } + }, }) ); } @@ -341,11 +334,7 @@ moduleFor( ['@test meta should return an empty hash if no meta is set'](assert) { let computedProperty = computed(function() {}); - assert.deepEqual( - computedProperty.meta(), - {}, - 'returned value is an empty hash' - ); + assert.deepEqual(computedProperty.meta(), {}, 'returned value is an empty hash'); } } ); @@ -400,19 +389,11 @@ moduleFor( } ['@test getCachedValueFor should return the cached value'](assert) { - assert.equal( - getCachedValueFor(obj, 'foo'), - undefined, - 'should not yet be a cached value' - ); + assert.equal(getCachedValueFor(obj, 'foo'), undefined, 'should not yet be a cached value'); get(obj, 'foo'); - assert.equal( - getCachedValueFor(obj, 'foo'), - 'bar 1', - 'should retrieve cached value' - ); + assert.equal(getCachedValueFor(obj, 'foo'), 'bar 1', 'should retrieve cached value'); } ['@test getCachedValueFor should return falsy cached values'](assert) { @@ -424,26 +405,18 @@ moduleFor( }) ); - assert.equal( - getCachedValueFor(obj, 'falsy'), - undefined, - 'should not yet be a cached value' - ); + assert.equal(getCachedValueFor(obj, 'falsy'), undefined, 'should not yet be a cached value'); get(obj, 'falsy'); - assert.equal( - getCachedValueFor(obj, 'falsy'), - false, - 'should retrieve cached value' - ); + assert.equal(getCachedValueFor(obj, 'falsy'), false, 'should retrieve cached value'); } ['@test setting a cached computed property passes the old value as the third argument']( assert ) { let obj = { - foo: 0 + foo: 0, }; let receivedOldValue; @@ -456,16 +429,12 @@ moduleFor( set(key, value, oldValue) { receivedOldValue = oldValue; return value; - } + }, }).property('foo') ); set(obj, 'plusOne', 1); - assert.strictEqual( - receivedOldValue, - undefined, - 'oldValue should be undefined' - ); + assert.strictEqual(receivedOldValue, undefined, 'oldValue should be undefined'); set(obj, 'plusOne', 2); assert.strictEqual(receivedOldValue, 1, 'oldValue should be 1'); @@ -496,7 +465,7 @@ moduleFor( 'foo', computed({ get: getterAndSetter, - set: getterAndSetter + set: getterAndSetter, }).property('bar') ); } @@ -506,45 +475,21 @@ moduleFor( } ['@test should lazily watch dependent keys on set'](assert) { - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); set(obj, 'foo', 'bar'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key'); } ['@test should lazily watch dependent keys on get'](assert) { - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); get(obj, 'foo'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key'); } ['@test local dependent key should invalidate cache'](assert) { - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); assert.equal(get(obj, 'foo'), 'bar 1', 'get once'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily setup watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); assert.equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); set(obj, 'bar', 'BIFF'); // should invalidate foo @@ -565,27 +510,11 @@ moduleFor( }).property('baz') ); - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); - assert.equal( - isWatching(obj, 'baz'), - false, - 'precond not watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); + assert.equal(isWatching(obj, 'baz'), false, 'precond not watching dependent key'); assert.equal(get(obj, 'foo'), 'bar 1', 'get once'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily setup watching dependent key' - ); - assert.equal( - isWatching(obj, 'baz'), - true, - 'lazily setup watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + assert.equal(isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); assert.equal(get(obj, 'foo'), 'bar 1', 'cached retrieve'); set(obj, 'baz', 'BIFF'); // should invalidate bar -> foo @@ -602,16 +531,8 @@ moduleFor( assert.equal(get(obj, 'foo'), 'bar 2', 'should recache'); assert.equal(get(obj, 'foo'), 'bar 2', 'cached retrieve'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily setup watching dependent key' - ); - assert.equal( - isWatching(obj, 'baz'), - true, - 'lazily setup watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key'); + assert.equal(isWatching(obj, 'baz'), true, 'lazily setup watching dependent key'); } ['@test circular keys should not blow up'](assert) { @@ -619,11 +540,7 @@ moduleFor( count++; return 'bar ' + count; }; - defineProperty( - obj, - 'bar', - computed({ get: func, set: func }).property('foo') - ); + defineProperty(obj, 'bar', computed({ get: func, set: func }).property('foo')); defineProperty( obj, @@ -644,17 +561,9 @@ moduleFor( } ['@test redefining a property should undo old dependent keys'](assert) { - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); assert.equal(get(obj, 'foo'), 'bar 1'); - assert.equal( - isWatching(obj, 'bar'), - true, - 'lazily watching dependent key' - ); + assert.equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key'); defineProperty( obj, @@ -722,14 +631,8 @@ moduleFor( }, /cannot contain spaces/); } - ['@test throws an assertion if an uncached `get` is called after object is destroyed']( - assert - ) { - assert.equal( - isWatching(obj, 'bar'), - false, - 'precond not watching dependent key' - ); + ['@test throws an assertion if an uncached `get` is called after object is destroyed'](assert) { + assert.equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); let meta = metaFor(obj); meta.destroy(); @@ -759,10 +662,10 @@ moduleFor( foo: { bar: { baz: { - biff: 'BIFF' - } - } - } + biff: 'BIFF', + }, + }, + }, }; count = 0; @@ -819,9 +722,7 @@ moduleFor( assert.equal(count, 8, 'should be not have invoked computed again'); } - ['@test chained dependent keys should evaluate computed properties lazily']( - assert - ) { + ['@test chained dependent keys should evaluate computed properties lazily'](assert) { defineProperty(obj.foo.bar, 'b', computed(func)); defineProperty(obj.foo, 'c', computed(function() {}).property('bar.b')); assert.equal(count, 0, 'b should not run'); @@ -851,8 +752,8 @@ moduleFor( assert.equal(oldValue, 1, 'setter receives the old value'); this.set('a', '' + value); // side effect return parseInt(this.get('a')); - } - }) + }, + }), }).create(); assert.ok(testObj.get('aInt') === 1, 'getter works'); @@ -869,8 +770,8 @@ moduleFor( get(keyName) { assert.equal(keyName, 'aInt', 'getter receives the keyName'); return parseInt(this.get('a')); - } - }) + }, + }), }).create(); assert.ok(testObj.get('aInt') === 1, 'getter works'); @@ -884,8 +785,8 @@ moduleFor( com: computed({ set(key, value) { return value; - } - }) + }, + }), }).create(); assert.ok(testObj.get('com') === undefined); @@ -903,15 +804,12 @@ moduleFor( }, set() { return 'set-value'; - } - }) + }, + }), }).create(); testObj.set('sampleCP', 'abcd'); - assert.ok( - testObj.get('sampleCP') === 'set-value', - 'The return value of the CP was cached' - ); + assert.ok(testObj.get('sampleCP') === 'set-value', 'The return value of the CP was cached'); } } ); @@ -923,9 +821,7 @@ moduleFor( moduleFor( 'computed edge cases', class extends AbstractTestCase { - ['@test adding a computed property should show up in key iteration']( - assert - ) { + ['@test adding a computed property should show up in key iteration'](assert) { let obj = {}; defineProperty(obj, 'foo', computed(function() {})); @@ -956,7 +852,7 @@ moduleFor( oldValueIsNoFunction = false; } return undefined; - } + }, }) ); @@ -974,7 +870,7 @@ moduleFor( ['@test setting a watched computed property'](assert) { let obj = { firstName: 'Yehuda', - lastName: 'Katz' + lastName: 'Katz', }; defineProperty( @@ -989,7 +885,7 @@ moduleFor( set(this, 'firstName', values[0]); set(this, 'lastName', values[1]); return value; - } + }, }).property('firstName', 'lastName') ); @@ -1021,11 +917,9 @@ moduleFor( assert.equal(lastNameDidChange, 1); } - ['@test setting a cached computed property that modifies the value you give it']( - assert - ) { + ['@test setting a cached computed property that modifies the value you give it'](assert) { let obj = { - foo: 0 + foo: 0, }; defineProperty( @@ -1038,7 +932,7 @@ moduleFor( set(key, value) { set(this, 'foo', value); return value + 1; - } + }, }).property('foo') ); @@ -1066,9 +960,7 @@ moduleFor( moduleFor( 'computed - default setter', class extends AbstractTestCase { - ["@test when setting a value on a computed property that doesn't handle sets"]( - assert - ) { + ["@test when setting a value on a computed property that doesn't handle sets"](assert) { let obj = {}; let observerFired = false; @@ -1084,15 +976,8 @@ moduleFor( set(obj, 'foo', 'bar'); - assert.equal( - get(obj, 'foo'), - 'bar', - 'The set value is properly returned' - ); - assert.ok( - typeof obj.foo === 'string', - 'The computed property was removed' - ); + assert.equal(get(obj, 'foo'), 'bar', 'The set value is properly returned'); + assert.ok(typeof obj.foo === 'string', 'The computed property was removed'); assert.ok(observerFired, 'The observer was still notified'); } } @@ -1112,7 +997,7 @@ moduleFor( expectAssertion(() => { computed({ get() {}, - set() {} + set() {}, }).readOnly(); }, /Computed properties that define a setter using the new syntax cannot be read-only/); } diff --git a/packages/ember-metal/tests/descriptor_test.js b/packages/ember-metal/tests/descriptor_test.js index 8af78673ef7..1dae0bf857b 100644 --- a/packages/ember-metal/tests/descriptor_test.js +++ b/packages/ember-metal/tests/descriptor_test.js @@ -169,7 +169,7 @@ let classes = [ source() { return this.superklass.prototype; } - } + }, ]; classes.forEach(TestClass => { @@ -193,10 +193,7 @@ classes.forEach(TestClass => { assert.equal(obj.foo, 'baz'); }); - TestClass.test('defining a non-configurable property', function( - assert, - factory - ) { + TestClass.test('defining a non-configurable property', function(assert, factory) { factory.install('foo', descriptor({ configurable: false, value: 'bar' })); let obj = factory.finalize(); @@ -211,7 +208,7 @@ classes.forEach(TestClass => { () => Object.defineProperty(source, 'foo', { configurable: true, - value: 'baz' + value: 'baz', }), TypeError ); @@ -231,10 +228,7 @@ classes.forEach(TestClass => { assert.ok(Object.keys(source).indexOf('foo') !== -1); }); - TestClass.test('defining a non-enumerable property', function( - assert, - factory - ) { + TestClass.test('defining a non-enumerable property', function(assert, factory) { factory.install('foo', descriptor({ enumerable: false, value: 'bar' })); let obj = factory.finalize(); @@ -285,7 +279,7 @@ classes.forEach(TestClass => { descriptor({ get: function() { return this.__foo__; - } + }, }) ); @@ -306,7 +300,7 @@ classes.forEach(TestClass => { descriptor({ set: function(value) { this.__foo__ = value; - } + }, }) ); @@ -321,10 +315,7 @@ classes.forEach(TestClass => { assert.equal(obj.__foo__, 'baz'); }); - TestClass.test('combining multiple setter and getters', function( - assert, - factory - ) { + TestClass.test('combining multiple setter and getters', function(assert, factory) { factory.install( 'foo', descriptor({ @@ -334,7 +325,7 @@ classes.forEach(TestClass => { set: function(value) { this.__foo__ = value; - } + }, }) ); @@ -349,7 +340,7 @@ classes.forEach(TestClass => { set: function(value) { this.__bar__ = value; - } + }, }) ); @@ -360,7 +351,7 @@ classes.forEach(TestClass => { descriptor({ get: function() { return this.foo + '-' + this.bar; - } + }, }) ); diff --git a/packages/ember-metal/tests/events_test.js b/packages/ember-metal/tests/events_test.js index ae4114e1446..47553698171 100644 --- a/packages/ember-metal/tests/events_test.js +++ b/packages/ember-metal/tests/events_test.js @@ -1,11 +1,4 @@ -import { - Mixin, - on, - addListener, - removeListener, - sendEvent, - hasListeners -} from '..'; +import { Mixin, on, addListener, removeListener, sendEvent, hasListeners } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( @@ -71,9 +64,7 @@ moduleFor( assert.equal(count, 1, 'should only invoke once'); } - ['@test adding a listener with a target should invoke with target']( - assert - ) { + ['@test adding a listener with a target should invoke with target'](assert) { let obj = {}; let target; @@ -81,7 +72,7 @@ moduleFor( count: 0, method() { this.count++; - } + }, }; addListener(obj, 'event!', target, target.method); @@ -89,15 +80,13 @@ moduleFor( assert.equal(target.count, 1, 'should invoke'); } - ['@test adding a listener with string method should lookup method on event delivery']( - assert - ) { + ['@test adding a listener with string method should lookup method on event delivery'](assert) { let obj = {}; let target; target = { count: 0, - method() {} + method() {}, }; addListener(obj, 'event!', target, 'method'); @@ -111,9 +100,7 @@ moduleFor( assert.equal(target.count, 1, 'should invoke now'); } - ['@test calling sendEvent with extra params should be passed to listeners']( - assert - ) { + ['@test calling sendEvent with extra params should be passed to listeners'](assert) { let obj = {}; let params = null; addListener(obj, 'event!', function() { @@ -124,9 +111,7 @@ moduleFor( assert.deepEqual(params, ['foo', 'bar'], 'params should be saved'); } - ['@test hasListeners tells you if there are listeners for a given event']( - assert - ) { + ['@test hasListeners tells you if there are listeners for a given event'](assert) { let obj = {}; function F() {} @@ -149,9 +134,7 @@ moduleFor( assert.equal(hasListeners(obj, 'event!'), true, 'has listeners'); } - ['@test calling removeListener without method should remove all listeners']( - assert - ) { + ['@test calling removeListener without method should remove all listeners'](assert) { let obj = {}; function F() {} function F2() {} @@ -176,7 +159,7 @@ moduleFor( foo2: on('bar', function() { triggered++; - }) + }), }); let obj = {}; @@ -189,13 +172,13 @@ moduleFor( [`@test 'on' asserts for invalid arguments`]() { expectAssertion(() => { Mixin.create({ - foo1: on('bar') + foo1: on('bar'), }); }, 'on expects function as last argument'); expectAssertion(() => { Mixin.create({ - foo1: on(function() {}) + foo1: on(function() {}), }); }, 'on called without valid event names'); } @@ -205,12 +188,12 @@ moduleFor( let FirstMixin = Mixin.create({ foo: on('bar', function() { triggered++; - }) + }), }); let SecondMixin = Mixin.create({ foo: on('baz', function() { triggered++; - }) + }), }); let obj = {}; diff --git a/packages/ember-metal/tests/expand_properties_test.js b/packages/ember-metal/tests/expand_properties_test.js index f8c455439b9..25186366fa8 100644 --- a/packages/ember-metal/tests/expand_properties_test.js +++ b/packages/ember-metal/tests/expand_properties_test.js @@ -22,10 +22,7 @@ moduleFor( expandProperties('a.b.[]', addProperty); expandProperties('a.b.@each.c', addProperty); - assert.deepEqual( - ['a', 'a.b', 'a.b.[]', 'a.b.@each.c'].sort(), - foundProperties.sort() - ); + assert.deepEqual(['a', 'a.b', 'a.b.[]', 'a.b.@each.c'].sort(), foundProperties.sort()); } ['@test A single expansion at the end expands properly'](assert) { @@ -67,14 +64,7 @@ moduleFor( expandProperties('{a,b,c}.d.{e,f}.g', addProperty); - let expected = [ - 'a.d.e.g', - 'a.d.f.g', - 'b.d.e.g', - 'b.d.f.g', - 'c.d.e.g', - 'c.d.f.g' - ]; + let expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; assert.deepEqual(expected.sort(), foundProperties.sort()); } @@ -94,7 +84,7 @@ moduleFor( 'a.{b,c}.{d.{e,f}.g', 'a.{b.{c}', 'a.{b,c}}', - 'model.{bar,baz' + 'model.{bar,baz', ]; nestedBraceProperties.forEach(invalidProperties => { diff --git a/packages/ember-metal/tests/injected_property_test.js b/packages/ember-metal/tests/injected_property_test.js index 06d165431b5..3c393e95923 100644 --- a/packages/ember-metal/tests/injected_property_test.js +++ b/packages/ember-metal/tests/injected_property_test.js @@ -15,11 +15,7 @@ moduleFor( set(obj, 'foo', 'bar'); - assert.equal( - get(obj, 'foo'), - 'bar', - 'should return the overridden value' - ); + assert.equal(get(obj, 'foo'), 'bar', 'should return the overridden value'); } ['@test getting on an object without an owner or container should fail assertion']() { @@ -31,25 +27,19 @@ moduleFor( }, /Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container./); } - ['@test getting on an object without an owner but with a container should not fail']( - assert - ) { + ['@test getting on an object without an owner but with a container should not fail'](assert) { let obj = { container: { lookup(key) { assert.ok(true, 'should call container.lookup'); return key; - } - } + }, + }, }; defineProperty(obj, 'foo', new InjectedProperty('type', 'name')); - assert.equal( - get(obj, 'foo'), - 'type:name', - 'should return the value of container.lookup' - ); + assert.equal(get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); } ['@test getting should return a lookup on the container'](assert) { @@ -61,36 +51,26 @@ moduleFor( lookup(key) { assert.ok(true, 'should call container.lookup'); return key; - } + }, }); defineProperty(obj, 'foo', new InjectedProperty('type', 'name')); - assert.equal( - get(obj, 'foo'), - 'type:name', - 'should return the value of container.lookup' - ); + assert.equal(get(obj, 'foo'), 'type:name', 'should return the value of container.lookup'); } - ['@test omitting the lookup name should default to the property name']( - assert - ) { + ['@test omitting the lookup name should default to the property name'](assert) { let obj = {}; setOwner(obj, { lookup(key) { return key; - } + }, }); defineProperty(obj, 'foo', new InjectedProperty('type')); - assert.equal( - get(obj, 'foo'), - 'type:foo', - 'should lookup the type using the property name' - ); + assert.equal(get(obj, 'foo'), 'type:foo', 'should lookup the type using the property name'); } } ); diff --git a/packages/ember-metal/tests/instrumentation_test.js b/packages/ember-metal/tests/instrumentation_test.js index 334c59c41d6..ba34231e2c9 100644 --- a/packages/ember-metal/tests/instrumentation_test.js +++ b/packages/ember-metal/tests/instrumentation_test.js @@ -2,7 +2,7 @@ import { instrument, instrumentationSubscribe as subscribe, instrumentationUnsubscribe as unsubscribe, - instrumentationReset as reset + instrumentationReset as reset, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -49,7 +49,7 @@ moduleFor( assert.strictEqual(payload, sentPayload); count++; - } + }, }); instrument('render', sentPayload, function() {}); @@ -57,9 +57,7 @@ moduleFor( instrument('render.handlebars', sentPayload, function() {}); } - ['@test returning a value from the before callback passes it to the after callback']( - assert - ) { + ['@test returning a value from the before callback passes it to the after callback'](assert) { assert.expect(2); let passthru1 = {}; @@ -71,7 +69,7 @@ moduleFor( }, after(name, timestamp, payload, beforeValue) { assert.strictEqual(beforeValue, passthru1); - } + }, }); subscribe('render', { @@ -80,7 +78,7 @@ moduleFor( }, after(name, timestamp, payload, beforeValue) { assert.strictEqual(beforeValue, passthru2); - } + }, }); instrument('render', null, function() {}); @@ -93,15 +91,13 @@ moduleFor( before(name, timestamp, payload) { assert.deepEqual(payload, {}); }, - after() {} + after() {}, }); instrument('render', function() {}); } - ['@test instrument with 3 args (name, callback, binding) no payload']( - assert - ) { + ['@test instrument with 3 args (name, callback, binding) no payload'](assert) { assert.expect(2); let binding = {}; @@ -109,7 +105,7 @@ moduleFor( before(name, timestamp, payload) { assert.deepEqual(payload, {}); }, - after() {} + after() {}, }); instrument( @@ -121,9 +117,7 @@ moduleFor( ); } - ['@test instrument with 3 args (name, payload, callback) with payload']( - assert - ) { + ['@test instrument with 3 args (name, payload, callback) with payload'](assert) { assert.expect(1); let expectedPayload = { hi: 1 }; @@ -131,15 +125,13 @@ moduleFor( before(name, timestamp, payload) { assert.deepEqual(payload, expectedPayload); }, - after() {} + after() {}, }); instrument('render', expectedPayload, function() {}); } - ['@test instrument with 4 args (name, payload, callback, binding) with payload']( - assert - ) { + ['@test instrument with 4 args (name, payload, callback, binding) with payload'](assert) { assert.expect(2); let expectedPayload = { hi: 1 }; @@ -148,7 +140,7 @@ moduleFor( before(name, timestamp, payload) { assert.deepEqual(payload, expectedPayload); }, - after() {} + after() {}, }); instrument( @@ -161,9 +153,7 @@ moduleFor( ); } - ['@test raising an exception in the instrumentation attaches it to the payload']( - assert - ) { + ['@test raising an exception in the instrumentation attaches it to the payload'](assert) { assert.expect(2); let error = new Error('Instrumentation'); @@ -172,14 +162,14 @@ moduleFor( before() {}, after(name, timestamp, payload) { assert.strictEqual(payload.exception, error); - } + }, }); subscribe('render', { before() {}, after(name, timestamp, payload) { assert.strictEqual(payload.exception, error); - } + }, }); instrument('render.handlebars', null, function() { @@ -187,9 +177,7 @@ moduleFor( }); } - ['@test it is possible to add a new subscriber after the first instrument']( - assert - ) { + ['@test it is possible to add a new subscriber after the first instrument'](assert) { instrument('render.handlebars', null, function() {}); subscribe('render', { @@ -198,7 +186,7 @@ moduleFor( }, after() { assert.ok(true, 'After callback was called'); - } + }, }); instrument('render.handlebars', null, function() {}); @@ -218,7 +206,7 @@ moduleFor( assert.equal(count, 0); assert.ok(true, 'After callback was called'); count++; - } + }, }); instrument('render.handlebars', null, function() {}); diff --git a/packages/ember-metal/tests/is_blank_test.js b/packages/ember-metal/tests/is_blank_test.js index 28d87e4655f..e29e67710a6 100644 --- a/packages/ember-metal/tests/is_blank_test.js +++ b/packages/ember-metal/tests/is_blank_test.js @@ -22,11 +22,7 @@ moduleFor( assert.equal(false, isBlank(0), 'for 0'); assert.equal(true, isBlank([]), 'for an empty Array'); assert.equal(false, isBlank({}), 'for an empty Object'); - assert.equal( - true, - isBlank(object), - "for an Object that has zero 'length'" - ); + assert.equal(true, isBlank(object), "for an Object that has zero 'length'"); assert.equal(false, isBlank([1, 2, 3]), 'for a non-empty array'); } } diff --git a/packages/ember-metal/tests/is_empty_test.js b/packages/ember-metal/tests/is_empty_test.js index bc7c04e77d0..95273bf23d1 100644 --- a/packages/ember-metal/tests/is_empty_test.js +++ b/packages/ember-metal/tests/is_empty_test.js @@ -21,11 +21,7 @@ moduleFor( assert.equal(false, isEmpty(0), 'for 0'); assert.equal(true, isEmpty([]), 'for an empty Array'); assert.equal(false, isEmpty({}), 'for an empty Object'); - assert.equal( - true, - isEmpty(object), - "for an Object that has zero 'length'" - ); + assert.equal(true, isEmpty(object), "for an Object that has zero 'length'"); } ['@test isEmpty Map'](assert) { diff --git a/packages/ember-metal/tests/is_present_test.js b/packages/ember-metal/tests/is_present_test.js index 00a6e0246c4..deac592c66b 100644 --- a/packages/ember-metal/tests/is_present_test.js +++ b/packages/ember-metal/tests/is_present_test.js @@ -23,11 +23,7 @@ moduleFor( assert.equal(true, isPresent(0), 'for 0'); assert.equal(false, isPresent([]), 'for an empty Array'); assert.equal(true, isPresent({}), 'for an empty Object'); - assert.equal( - false, - isPresent(object), - "for an Object that has zero 'length'" - ); + assert.equal(false, isPresent(object), "for an Object that has zero 'length'"); assert.equal(true, isPresent([1, 2, 3]), 'for a non-empty array'); } } diff --git a/packages/ember-metal/tests/libraries_test.js b/packages/ember-metal/tests/libraries_test.js index 37be0ed9ef9..8285c86c1c7 100644 --- a/packages/ember-metal/tests/libraries_test.js +++ b/packages/ember-metal/tests/libraries_test.js @@ -62,9 +62,7 @@ moduleFor( } } - ['@test attempting to register a library that is already registered warns you']( - assert - ) { + ['@test attempting to register a library that is already registered warns you'](assert) { if (EmberDev && EmberDev.runningProdBuild) { assert.ok(true, 'Logging does not occur in production builds'); return; @@ -76,10 +74,7 @@ moduleFor( setDebugFunction('warn', function(msg, test) { if (!test) { - assert.equal( - msg, - 'Library "magic" is already registered with Ember.' - ); + assert.equal(msg, 'Library "magic" is already registered with Ember.'); } }); diff --git a/packages/ember-metal/tests/main_test.js b/packages/ember-metal/tests/main_test.js index 90955980180..f0f144a6055 100644 --- a/packages/ember-metal/tests/main_test.js +++ b/packages/ember-metal/tests/main_test.js @@ -14,9 +14,7 @@ moduleFor( ); } - ['@test SEMVER_REGEX properly validates and invalidates version numbers']( - assert - ) { + ['@test SEMVER_REGEX properly validates and invalidates version numbers'](assert) { function validateVersionString(versionString, expectedResult) { assert.equal(SEMVER_REGEX.test(versionString), expectedResult); } diff --git a/packages/ember-metal/tests/map_test.js b/packages/ember-metal/tests/map_test.js index b286e3908b5..5d6cee60679 100644 --- a/packages/ember-metal/tests/map_test.js +++ b/packages/ember-metal/tests/map_test.js @@ -23,32 +23,16 @@ function testMap(nameAndFunc) { map.set(number, 'winning'); map.set(string, 'winning'); - mapHasEntries(assert, [ - [object, 'winning'], - [number, 'winning'], - [string, 'winning'] - ]); + mapHasEntries(assert, [[object, 'winning'], [number, 'winning'], [string, 'winning']]); map.set(object, 'losing'); map.set(number, 'losing'); map.set(string, 'losing'); - mapHasEntries(assert, [ - [object, 'losing'], - [number, 'losing'], - [string, 'losing'] - ]); - - assert.equal( - map.has('nope'), - false, - 'expected the key `nope` to not be present' - ); - assert.equal( - map.has({}), - false, - 'expected they key `{}` to not be present' - ); + mapHasEntries(assert, [[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + assert.equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + assert.equal(map.has({}), false, 'expected they key `{}` to not be present'); } ['@test set chaining'](assert) { @@ -57,33 +41,17 @@ function testMap(nameAndFunc) { .set(number, 'winning') .set(string, 'winning'); - mapHasEntries(assert, [ - [object, 'winning'], - [number, 'winning'], - [string, 'winning'] - ]); + mapHasEntries(assert, [[object, 'winning'], [number, 'winning'], [string, 'winning']]); map .set(object, 'losing') .set(number, 'losing') .set(string, 'losing'); - mapHasEntries(assert, [ - [object, 'losing'], - [number, 'losing'], - [string, 'losing'] - ]); - - assert.equal( - map.has('nope'), - false, - 'expected the key `nope` to not be present' - ); - assert.equal( - map.has({}), - false, - 'expected they key `{}` to not be present' - ); + mapHasEntries(assert, [[object, 'losing'], [number, 'losing'], [string, 'losing']]); + + assert.equal(map.has('nope'), false, 'expected the key `nope` to not be present'); + assert.equal(map.has({}), false, 'expected they key `{}` to not be present'); } ['@test with key with undefined value'](assert) { @@ -100,21 +68,11 @@ function testMap(nameAndFunc) { } ['@test arity of forEach is 1 – es6 23.1.3.5'](assert) { - assert.equal( - map.forEach.length, - 1, - 'expected arity for map.forEach is 1' - ); + assert.equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); } - ['@test forEach throws without a callback as the first argument']( - assert - ) { - assert.equal( - map.forEach.length, - 1, - 'expected arity for map.forEach is 1' - ); + ['@test forEach throws without a callback as the first argument'](assert) { + assert.equal(map.forEach.length, 1, 'expected arity for map.forEach is 1'); } ['@test has empty collection'](assert) { @@ -150,17 +108,9 @@ function testMap(nameAndFunc) { map2.set(number, 'losing'); map2.set(string, 'losing'); - mapHasEntries(assert, [ - [object, 'winning'], - [number, 'winning'], - [string, 'winning'] - ]); - - mapHasEntries( - assert, - [[object, 'losing'], [number, 'losing'], [string, 'losing']], - map2 - ); + mapHasEntries(assert, [[object, 'winning'], [number, 'winning'], [string, 'winning']]); + + mapHasEntries(assert, [[object, 'losing'], [number, 'losing'], [string, 'losing']], map2); } ['@test copy and then delete'](assert) { @@ -174,11 +124,7 @@ function testMap(nameAndFunc) { map2.delete(number); map2.delete(string); - mapHasEntries(assert, [ - [object, 'winning'], - [number, 'winning'], - [string, 'winning'] - ]); + mapHasEntries(assert, [[object, 'winning'], [number, 'winning'], [string, 'winning']]); mapHasEntries(assert, [], map2); } @@ -253,7 +199,7 @@ function testMap(nameAndFunc) { let expectations = [ { value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, - { value: 3, key: 'c', context: unboundThis } + { value: 3, key: 'c', context: unboundThis }, ]; map.forEach(function(value, key, theMap) { @@ -261,16 +207,8 @@ function testMap(nameAndFunc) { assert.equal(value, expectation.value, 'value should be correct'); assert.equal(key, expectation.key, 'key should be correct'); - assert.equal( - this, - expectation.context, - 'context should be as if it was unbound' - ); - assert.equal( - map, - theMap, - 'map being iterated over should be passed in' - ); + assert.equal(this, expectation.context, 'context should be as if it was unbound'); + assert.equal(map, theMap, 'map being iterated over should be passed in'); iteration++; }); @@ -288,7 +226,7 @@ function testMap(nameAndFunc) { let expectations = [ { value: 1, key: 'a', context: context }, { value: 2, key: 'b', context: context }, - { value: 3, key: 'c', context: context } + { value: 3, key: 'c', context: context }, ]; map.forEach(function(value, key, theMap) { @@ -296,16 +234,8 @@ function testMap(nameAndFunc) { assert.equal(value, expectation.value, 'value should be correct'); assert.equal(key, expectation.key, 'key should be correct'); - assert.equal( - this, - expectation.context, - 'context should be as if it was unbound' - ); - assert.equal( - map, - theMap, - 'map being iterated over should be passed in' - ); + assert.equal(this, expectation.context, 'context should be as if it was unbound'); + assert.equal(map, theMap, 'map being iterated over should be passed in'); iteration++; }, context); @@ -322,7 +252,7 @@ function testMap(nameAndFunc) { let expectations = [ { value: 1, key: 'a', context: unboundThis }, - { value: 2, key: 'b', context: unboundThis } + { value: 2, key: 'b', context: unboundThis }, ]; map.forEach(function(value, key, theMap) { @@ -334,16 +264,8 @@ function testMap(nameAndFunc) { assert.equal(value, expectation.value, 'value should be correct'); assert.equal(key, expectation.key, 'key should be correct'); - assert.equal( - this, - expectation.context, - 'context should be as if it was unbound' - ); - assert.equal( - map, - theMap, - 'map being iterated over should be passed in' - ); + assert.equal(this, expectation.context, 'context should be as if it was unbound'); + assert.equal(map, theMap, 'map being iterated over should be passed in'); iteration++; }); @@ -362,7 +284,7 @@ function testMap(nameAndFunc) { { value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }, - { value: 4, key: 'd', context: unboundThis } + { value: 4, key: 'd', context: unboundThis }, ]; map.forEach(function(value, key, theMap) { @@ -374,16 +296,8 @@ function testMap(nameAndFunc) { assert.equal(value, expectation.value, 'value should be correct'); assert.equal(key, expectation.key, 'key should be correct'); - assert.equal( - this, - expectation.context, - 'context should be as if it was unbound' - ); - assert.equal( - map, - theMap, - 'map being iterated over should be passed in' - ); + assert.equal(this, expectation.context, 'context should be as if it was unbound'); + assert.equal(map, theMap, 'map being iterated over should be passed in'); iteration++; }); @@ -428,11 +342,7 @@ function testMap(nameAndFunc) { assert.equal(map.get(-0), 'zero'); map.forEach(function(value, key) { - assert.equal( - 1 / key, - Infinity, - 'spec says key should be positive zero' - ); + assert.equal(1 / key, Infinity, 'spec says key should be positive zero'); }); } @@ -515,13 +425,11 @@ for (let i = 0; i < varieties.length; i++) { moduleFor( 'MapWithDefault - default values', class extends AbstractTestCase { - ['@test Retrieving a value that has not been set returns and sets a default value']( - assert - ) { + ['@test Retrieving a value that has not been set returns and sets a default value'](assert) { let map = MapWithDefault.create({ defaultValue(key) { return [key]; - } + }, }); let value = map.get('ohai'); @@ -539,7 +447,7 @@ moduleFor( let map = new MapWithDefault({ defaultValue(key) { return key; - } + }, }); assert.equal(map.constructor, MapWithDefault); } @@ -548,7 +456,7 @@ moduleFor( let map = MapWithDefault.create({ defaultValue(key) { return [key]; - } + }, }); map.set('ohai', 1); diff --git a/packages/ember-metal/tests/meta_test.js b/packages/ember-metal/tests/meta_test.js index 3be53f40c70..089e08ce3bc 100644 --- a/packages/ember-metal/tests/meta_test.js +++ b/packages/ember-metal/tests/meta_test.js @@ -9,11 +9,7 @@ moduleFor( meta(obj).foo = 'bar'; - assert.equal( - meta(obj).foo, - 'bar', - 'returns same hash with multiple calls to Ember.meta()' - ); + assert.equal(meta(obj).foo, 'bar', 'returns same hash with multiple calls to Ember.meta()'); } ['@test meta is not enumerable'](assert) { @@ -84,7 +80,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); @@ -99,7 +95,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); @@ -114,7 +110,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); @@ -129,7 +125,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); @@ -144,7 +140,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); @@ -159,7 +155,7 @@ moduleFor( let target = { toString() { return ''; - } + }, }; let targetMeta = meta(target); diff --git a/packages/ember-metal/tests/mixin/alias_method_test.js b/packages/ember-metal/tests/mixin/alias_method_test.js index a58536cab85..d00cdd9d535 100644 --- a/packages/ember-metal/tests/mixin/alias_method_test.js +++ b/packages/ember-metal/tests/mixin/alias_method_test.js @@ -9,14 +9,12 @@ function validateAliasMethod(assert, obj) { moduleFor( 'aliasMethod', class extends AbstractTestCase { - ['@test methods of another name are aliased when the mixin is applied']( - assert - ) { + ['@test methods of another name are aliased when the mixin is applied'](assert) { let MyMixin = Mixin.create({ fooMethod() { return 'FOO'; }, - barMethod: aliasMethod('fooMethod') + barMethod: aliasMethod('fooMethod'), }); let obj = MyMixin.apply({}); @@ -29,67 +27,59 @@ moduleFor( baz() { return 'baz'; }, - foo: aliasMethod('baz') + foo: aliasMethod('baz'), }); let obj = MyMixin.apply({}); - assert.equal( - get(obj, 'bar')(), - 'baz', - 'should have followed aliasMethods' - ); + assert.equal(get(obj, 'bar')(), 'baz', 'should have followed aliasMethods'); } ['@test should alias methods from other dependent mixins'](assert) { let BaseMixin = Mixin.create({ fooMethod() { return 'FOO'; - } + }, }); let MyMixin = Mixin.create(BaseMixin, { - barMethod: aliasMethod('fooMethod') + barMethod: aliasMethod('fooMethod'), }); let obj = MyMixin.apply({}); validateAliasMethod(assert, obj); } - ['@test should alias methods from other mixins applied at same time']( - assert - ) { + ['@test should alias methods from other mixins applied at same time'](assert) { let BaseMixin = Mixin.create({ fooMethod() { return 'FOO'; - } + }, }); let MyMixin = Mixin.create({ - barMethod: aliasMethod('fooMethod') + barMethod: aliasMethod('fooMethod'), }); let obj = mixin({}, BaseMixin, MyMixin); validateAliasMethod(assert, obj); } - ['@test should alias methods from mixins already applied on object']( - assert - ) { + ['@test should alias methods from mixins already applied on object'](assert) { let BaseMixin = Mixin.create({ quxMethod() { return 'qux'; - } + }, }); let MyMixin = Mixin.create({ bar: aliasMethod('foo'), - barMethod: aliasMethod('fooMethod') + barMethod: aliasMethod('fooMethod'), }); let obj = { fooMethod() { return 'FOO'; - } + }, }; BaseMixin.apply(obj); diff --git a/packages/ember-metal/tests/mixin/apply_test.js b/packages/ember-metal/tests/mixin/apply_test.js index eb9e2b3df39..e829b61f47c 100644 --- a/packages/ember-metal/tests/mixin/apply_test.js +++ b/packages/ember-metal/tests/mixin/apply_test.js @@ -19,7 +19,7 @@ moduleFor( let obj = {}; mixin(obj, { foo: 'FOO', - baz: K + baz: K, }); assert.equal(get(obj, 'foo'), 'FOO', 'should apply foo'); diff --git a/packages/ember-metal/tests/mixin/computed_test.js b/packages/ember-metal/tests/mixin/computed_test.js index 58def1ae39c..b094bcd0aa5 100644 --- a/packages/ember-metal/tests/mixin/computed_test.js +++ b/packages/ember-metal/tests/mixin/computed_test.js @@ -15,25 +15,25 @@ moduleFor( MixinA = Mixin.create({ aProp: computed(function() { return 'A'; - }) + }), }); MixinB = Mixin.create(MixinA, { aProp: computed(function() { return this._super(...arguments) + 'B'; - }) + }), }); MixinC = Mixin.create(MixinA, { aProp: computed(function() { return this._super(...arguments) + 'C'; - }) + }), }); MixinD = Mixin.create({ aProp: computed(function() { return this._super(...arguments) + 'D'; - }) + }), }); obj = {}; @@ -59,11 +59,7 @@ moduleFor( }) ); MixinD.apply(obj); - assert.equal( - get(obj, 'aProp'), - 'objD', - 'should preserve original computed property' - ); + assert.equal(get(obj, 'aProp'), 'objD', 'should preserve original computed property'); } ['@test calling set on overridden computed properties'](assert) { @@ -80,8 +76,8 @@ moduleFor( }, set() { superSetOccurred = true; - } - }) + }, + }), }); SubMixin = Mixin.create(SuperMixin, { @@ -91,8 +87,8 @@ moduleFor( }, set() { return this._super(...arguments); - } - }) + }, + }), }); obj = {}; @@ -113,15 +109,13 @@ moduleFor( assert.ok(superSetOccurred, 'should pass set to _super after getting'); } - ['@test setter behavior works properly when overriding computed properties']( - assert - ) { + ['@test setter behavior works properly when overriding computed properties'](assert) { let obj = {}; let MixinA = Mixin.create({ cpWithSetter2: computed(K), cpWithSetter3: computed(K), - cpWithoutSetter: computed(K) + cpWithoutSetter: computed(K), }); let cpWasCalled = false; @@ -131,29 +125,26 @@ moduleFor( get: K, set() { cpWasCalled = true; - } + }, }), cpWithSetter3: computed({ get: K, set() { cpWasCalled = true; - } + }, }), cpWithoutSetter: computed(function() { cpWasCalled = true; - }) + }), }); MixinA.apply(obj); MixinB.apply(obj); set(obj, 'cpWithSetter2', 'test'); - assert.ok( - cpWasCalled, - 'The computed property setter was called when defined with two args' - ); + assert.ok(cpWasCalled, 'The computed property setter was called when defined with two args'); cpWasCalled = false; set(obj, 'cpWithSetter3', 'test'); @@ -169,10 +160,7 @@ moduleFor( 'test', 'The default setter was called, the value is correct' ); - assert.ok( - !cpWasCalled, - 'The default setter was called, not the CP itself' - ); + assert.ok(!cpWasCalled, 'The default setter was called, not the CP itself'); } } ); diff --git a/packages/ember-metal/tests/mixin/concatenated_properties_test.js b/packages/ember-metal/tests/mixin/concatenated_properties_test.js index ef70f5106f7..177efe0b1aa 100644 --- a/packages/ember-metal/tests/mixin/concatenated_properties_test.js +++ b/packages/ember-metal/tests/mixin/concatenated_properties_test.js @@ -4,31 +4,27 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'Mixin concatenatedProperties', class extends AbstractTestCase { - ['@test defining concatenated properties should concat future version']( - assert - ) { + ['@test defining concatenated properties should concat future version'](assert) { let MixinA = Mixin.create({ concatenatedProperties: ['foo'], - foo: ['a', 'b', 'c'] + foo: ['a', 'b', 'c'], }); let MixinB = Mixin.create({ - foo: ['d', 'e', 'f'] + foo: ['d', 'e', 'f'], }); let obj = mixin({}, MixinA, MixinB); assert.deepEqual(get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f']); } - ['@test defining concatenated properties should concat future version']( - assert - ) { + ['@test defining concatenated properties should concat future version'](assert) { let MixinA = Mixin.create({ - concatenatedProperties: null + concatenatedProperties: null, }); let MixinB = Mixin.create({ - concatenatedProperties: null + concatenatedProperties: null, }); let obj = mixin({}, MixinA, MixinB); @@ -39,17 +35,17 @@ moduleFor( ['@test concatenatedProperties should be concatenated'](assert) { let MixinA = Mixin.create({ concatenatedProperties: ['foo'], - foo: ['a', 'b', 'c'] + foo: ['a', 'b', 'c'], }); let MixinB = Mixin.create({ concatenatedProperties: 'bar', foo: ['d', 'e', 'f'], - bar: [1, 2, 3] + bar: [1, 2, 3], }); let MixinC = Mixin.create({ - bar: [4, 5, 6] + bar: [4, 5, 6], }); let obj = mixin({}, MixinA, MixinB, MixinC); @@ -58,22 +54,18 @@ moduleFor( ['foo', 'bar'], 'get concatenatedProperties' ); - assert.deepEqual( - get(obj, 'foo'), - ['a', 'b', 'c', 'd', 'e', 'f'], - 'get foo' - ); + assert.deepEqual(get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f'], 'get foo'); assert.deepEqual(get(obj, 'bar'), [1, 2, 3, 4, 5, 6], 'get bar'); } ['@test adding a prop that is not an array should make array'](assert) { let MixinA = Mixin.create({ concatenatedProperties: ['foo'], - foo: [1, 2, 3] + foo: [1, 2, 3], }); let MixinB = Mixin.create({ - foo: 4 + foo: 4, }); let obj = mixin({}, MixinA, MixinB); @@ -83,7 +75,7 @@ moduleFor( ['@test adding a prop that is not an array should make array'](assert) { let MixinA = Mixin.create({ concatenatedProperties: ['foo'], - foo: 'bar' + foo: 'bar', }); let obj = mixin({}, MixinA); @@ -94,12 +86,12 @@ moduleFor( assert ) { let mixinA = Mixin.create({ - foo: 1 + foo: 1, }); let mixinB = Mixin.create({ concatenatedProperties: ['foo'], - foo: 2 + foo: 2, }); let obj = mixin({}, mixinA, mixinB); @@ -110,12 +102,12 @@ moduleFor( assert ) { let mixinA = Mixin.create({ - foobar: 'foo' + foobar: 'foo', }); let mixinB = Mixin.create({ concatenatedProperties: ['foobar'], - foobar: 'bar' + foobar: 'bar', }); let obj = mixin({}, mixinA, mixinB); diff --git a/packages/ember-metal/tests/mixin/detect_test.js b/packages/ember-metal/tests/mixin/detect_test.js index de85cae39ba..d99caae6043 100644 --- a/packages/ember-metal/tests/mixin/detect_test.js +++ b/packages/ember-metal/tests/mixin/detect_test.js @@ -8,18 +8,10 @@ moduleFor( let MixinA = Mixin.create(); let obj = {}; - assert.equal( - MixinA.detect(obj), - false, - 'MixinA.detect(obj) before apply()' - ); + assert.equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); MixinA.apply(obj); - assert.equal( - MixinA.detect(obj), - true, - 'MixinA.detect(obj) after apply()' - ); + assert.equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); } ['@test detect() finds nested mixins'](assert) { @@ -27,29 +19,17 @@ moduleFor( let MixinB = Mixin.create(MixinA); let obj = {}; - assert.equal( - MixinA.detect(obj), - false, - 'MixinA.detect(obj) before apply()' - ); + assert.equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); MixinB.apply(obj); - assert.equal( - MixinA.detect(obj), - true, - 'MixinA.detect(obj) after apply()' - ); + assert.equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); } ['@test detect() finds mixins on other mixins'](assert) { let MixinA = Mixin.create({}); let MixinB = Mixin.create(MixinA); assert.equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB'); - assert.equal( - MixinB.detect(MixinA), - false, - 'MixinB is not part of MixinA' - ); + assert.equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA'); } ['@test detect handles null values'](assert) { diff --git a/packages/ember-metal/tests/mixin/introspection_test.js b/packages/ember-metal/tests/mixin/introspection_test.js index 8edca85c0c6..446470722a6 100644 --- a/packages/ember-metal/tests/mixin/introspection_test.js +++ b/packages/ember-metal/tests/mixin/introspection_test.js @@ -7,24 +7,24 @@ import { mixin, Mixin } from '../..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; const PrivateProperty = Mixin.create({ - _foo: '_FOO' + _foo: '_FOO', }); const PublicProperty = Mixin.create({ - foo: 'FOO' + foo: 'FOO', }); const PrivateMethod = Mixin.create({ - _fooMethod() {} + _fooMethod() {}, }); const PublicMethod = Mixin.create({ - fooMethod() {} + fooMethod() {}, }); const BarProperties = Mixin.create({ _bar: '_BAR', - bar: 'bar' + bar: 'bar', }); const BarMethods = Mixin.create({ _barMethod() {}, - barMethod() {} + barMethod() {}, }); const Combined = Mixin.create(BarProperties, BarMethods); @@ -36,14 +36,7 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = {}; - mixin( - obj, - PrivateProperty, - PublicProperty, - PrivateMethod, - PublicMethod, - Combined - ); + mixin(obj, PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined); } ['@test Ember.mixins()'](assert) { @@ -60,7 +53,7 @@ moduleFor( PublicMethod, Combined, BarProperties, - BarMethods + BarMethods, ]), 'should return included mixins' ); diff --git a/packages/ember-metal/tests/mixin/merged_properties_test.js b/packages/ember-metal/tests/mixin/merged_properties_test.js index 26a86fc49b9..709b0c9abf7 100644 --- a/packages/ember-metal/tests/mixin/merged_properties_test.js +++ b/packages/ember-metal/tests/mixin/merged_properties_test.js @@ -8,11 +8,11 @@ moduleFor( ['@test defining mergedProperties should merge future version'](assert) { let MixinA = Mixin.create({ mergedProperties: ['foo'], - foo: { a: true, b: true, c: true } + foo: { a: true, b: true, c: true }, }); let MixinB = Mixin.create({ - foo: { d: true, e: true, f: true } + foo: { d: true, e: true, f: true }, }); let obj = mixin({}, MixinA, MixinB); @@ -22,20 +22,18 @@ moduleFor( c: true, d: true, e: true, - f: true + f: true, }); } - ['@test defining mergedProperties on future mixin should merged into past']( - assert - ) { + ['@test defining mergedProperties on future mixin should merged into past'](assert) { let MixinA = Mixin.create({ - foo: { a: true, b: true, c: true } + foo: { a: true, b: true, c: true }, }); let MixinB = Mixin.create({ mergedProperties: ['foo'], - foo: { d: true, e: true, f: true } + foo: { d: true, e: true, f: true }, }); let obj = mixin({}, MixinA, MixinB); @@ -45,20 +43,18 @@ moduleFor( c: true, d: true, e: true, - f: true + f: true, }); } - ['@test defining mergedProperties with null properties should keep properties null']( - assert - ) { + ['@test defining mergedProperties with null properties should keep properties null'](assert) { let MixinA = Mixin.create({ mergedProperties: ['foo'], - foo: null + foo: null, }); let MixinB = Mixin.create({ - foo: null + foo: null, }); let obj = mixin({}, MixinA, MixinB); @@ -68,11 +64,11 @@ moduleFor( ["@test mergedProperties' properties can get overwritten"](assert) { let MixinA = Mixin.create({ mergedProperties: ['foo'], - foo: { a: 1 } + foo: { a: 1 }, }); let MixinB = Mixin.create({ - foo: { a: 2 } + foo: { a: 2 }, }); let obj = mixin({}, MixinA, MixinB); @@ -82,79 +78,67 @@ moduleFor( ['@test mergedProperties should be concatenated'](assert) { let MixinA = Mixin.create({ mergedProperties: ['foo'], - foo: { a: true, b: true, c: true } + foo: { a: true, b: true, c: true }, }); let MixinB = Mixin.create({ mergedProperties: 'bar', foo: { d: true, e: true, f: true }, - bar: { a: true, l: true } + bar: { a: true, l: true }, }); let MixinC = Mixin.create({ - bar: { e: true, x: true } + bar: { e: true, x: true }, }); let obj = mixin({}, MixinA, MixinB, MixinC); - assert.deepEqual( - get(obj, 'mergedProperties'), - ['foo', 'bar'], - 'get mergedProperties' - ); + assert.deepEqual(get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties'); assert.deepEqual( get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, 'get foo' ); - assert.deepEqual( - get(obj, 'bar'), - { a: true, l: true, e: true, x: true }, - 'get bar' - ); + assert.deepEqual(get(obj, 'bar'), { a: true, l: true, e: true, x: true }, 'get bar'); } - ['@test mergedProperties should exist even if not explicitly set on create']( - assert - ) { + ['@test mergedProperties should exist even if not explicitly set on create'](assert) { let AnObj = EmberObject.extend({ mergedProperties: ['options'], options: { a: 'a', b: { - c: 'ccc' - } - } + c: 'ccc', + }, + }, }); let obj = AnObj.create({ options: { - a: 'A' - } + a: 'A', + }, }); assert.equal(get(obj, 'options').a, 'A'); assert.equal(get(obj, 'options').b.c, 'ccc'); } - ['@test defining mergedProperties at create time should not modify the prototype']( - assert - ) { + ['@test defining mergedProperties at create time should not modify the prototype'](assert) { let AnObj = EmberObject.extend({ mergedProperties: ['options'], options: { - a: 1 - } + a: 1, + }, }); let objA = AnObj.create({ options: { - a: 2 - } + a: 2, + }, }); let objB = AnObj.create({ options: { - a: 3 - } + a: 3, + }, }); assert.equal(get(objA, 'options').a, 2); @@ -168,14 +152,10 @@ moduleFor( mergedProperties: ['foo'], foo: { meth(a) { - assert.equal( - a, - 'WOOT', - "_super successfully called MixinA's `foo.meth` method" - ); + assert.equal(a, 'WOOT', "_super successfully called MixinA's `foo.meth` method"); return 'WAT'; - } - } + }, + }, }); let MixinB = Mixin.create({ @@ -183,8 +163,8 @@ moduleFor( meth() { assert.ok(true, "MixinB's `foo.meth` method called"); return this._super(...arguments); - } - } + }, + }, }); let MixinC = Mixin.create({ @@ -192,8 +172,8 @@ moduleFor( meth(a) { assert.ok(true, "MixinC's `foo.meth` method called"); return this._super(a); - } - } + }, + }, }); let obj = mixin({}, MixinA, MixinB, MixinC); @@ -205,11 +185,11 @@ moduleFor( let MixinA = Mixin.create({ mergedProperties: ['foo'], - foo: { a: true, b: true, c: true } + foo: { a: true, b: true, c: true }, }); let MixinB = Mixin.create({ - foo: ['a'] + foo: ['a'], }); expectAssertion(() => { diff --git a/packages/ember-metal/tests/mixin/method_test.js b/packages/ember-metal/tests/mixin/method_test.js index 41eb32a5b01..dfc9b4d2c50 100644 --- a/packages/ember-metal/tests/mixin/method_test.js +++ b/packages/ember-metal/tests/mixin/method_test.js @@ -13,7 +13,7 @@ moduleFor( }, _privateMethod() { return 'privateMethod'; - } + }, }; MixinA = Mixin.create(props); @@ -21,16 +21,8 @@ moduleFor( MixinA.apply(obj); // but should be defined - assert.equal( - props.publicMethod(), - 'publicMethod', - 'publicMethod is func' - ); - assert.equal( - props._privateMethod(), - 'privateMethod', - 'privateMethod is func' - ); + assert.equal(props.publicMethod(), 'publicMethod', 'publicMethod is func'); + assert.equal(props._privateMethod(), 'privateMethod', 'privateMethod is func'); } ['@test overriding public methods'](assert) { @@ -39,25 +31,25 @@ moduleFor( MixinA = Mixin.create({ publicMethod() { return 'A'; - } + }, }); MixinB = Mixin.create(MixinA, { publicMethod() { return this._super(...arguments) + 'B'; - } + }, }); MixinD = Mixin.create(MixinA, { publicMethod() { return this._super(...arguments) + 'D'; - } + }, }); MixinF = Mixin.create({ publicMethod() { return this._super(...arguments) + 'F'; - } + }, }); obj = {}; @@ -76,7 +68,7 @@ moduleFor( obj = { publicMethod() { return 'obj'; - } + }, }; MixinF.apply(obj); assert.equal(obj.publicMethod(), 'objF', 'should define super for F'); @@ -87,14 +79,14 @@ moduleFor( let MixinA = Mixin.create({ foo() { cnt++; - } + }, }); let MixinB = Mixin.create({ foo() { this._super(...arguments); cnt++; - } + }, }); let objA = {}; @@ -112,32 +104,30 @@ moduleFor( assert.equal(cnt, 1, 'should not screw w/ parent obj'); } - ['@test Including the same mixin more than once will only run once']( - assert - ) { + ['@test Including the same mixin more than once will only run once'](assert) { let cnt = 0; let MixinA = Mixin.create({ foo() { cnt++; - } + }, }); let MixinB = Mixin.create(MixinA, { foo() { this._super(...arguments); - } + }, }); let MixinC = Mixin.create(MixinA, { foo() { this._super(...arguments); - } + }, }); let MixinD = Mixin.create(MixinB, MixinC, MixinA, { foo() { this._super(...arguments); - } + }, }); let obj = {}; @@ -150,13 +140,11 @@ moduleFor( assert.equal(cnt, 1, 'should invoke MixinA.foo one time'); } - ['@test _super from a single mixin with no superclass does not error']( - assert - ) { + ['@test _super from a single mixin with no superclass does not error'](assert) { let MixinA = Mixin.create({ foo() { this._super(...arguments); - } + }, }); let obj = {}; @@ -166,9 +154,7 @@ moduleFor( assert.ok(true); } - ['@test _super from a first-of-two mixins with no superclass function does not error']( - assert - ) { + ['@test _super from a first-of-two mixins with no superclass function does not error'](assert) { // _super was previously calling itself in the second assertion. // Use remaining count of calls to ensure it doesn't loop indefinitely. let remaining = 3; @@ -177,13 +163,13 @@ moduleFor( if (remaining-- > 0) { this._super(...arguments); } - } + }, }); let MixinB = Mixin.create({ foo() { this._super(...arguments); - } + }, }); let obj = {}; @@ -206,7 +192,7 @@ moduleFor( let MixinA = Mixin.create({ toString() { return 'FOO'; - } + }, }); let obj = {}; @@ -217,7 +203,7 @@ moduleFor( mixin(obj, { toString() { return 'FOO'; - } + }, }); assert.equal(obj.toString(), 'FOO', 'should override toString w/o error'); } @@ -237,21 +223,21 @@ moduleFor( let MixinA = Mixin.create({ foo() { cnt++; - } + }, }); let MixinB = Mixin.create({ foo() { this._super(...arguments); cnt++; - } + }, }); let MixinC = Mixin.create({ foo() { this._super(...arguments); cnt++; - } + }, }); let obj = {}; diff --git a/packages/ember-metal/tests/mixin/observer_test.js b/packages/ember-metal/tests/mixin/observer_test.js index 3e3949f515b..b6dc006b5de 100644 --- a/packages/ember-metal/tests/mixin/observer_test.js +++ b/packages/ember-metal/tests/mixin/observer_test.js @@ -10,15 +10,11 @@ moduleFor( foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -30,15 +26,11 @@ moduleFor( foo: observer('bar', 'baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); set(obj, 'baz', 'BAZ'); @@ -51,35 +43,23 @@ moduleFor( foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let Mixin2 = Mixin.create({ foo: observer('baz', function() { set(this, 'count', get(this, 'count') + 10); - }) + }), }); let obj = mixin({}, MyMixin, Mixin2); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer after change' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer after change'); set(obj, 'baz', 'BAZ'); - assert.equal( - get(obj, 'count'), - 10, - 'should invoke observer after change' - ); + assert.equal(get(obj, 'count'), 10, 'should invoke observer after change'); } ['@test observing chain with property before'](assert) { @@ -90,15 +70,11 @@ moduleFor( bar: obj2, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -112,15 +88,11 @@ moduleFor( foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); }), - bar: obj2 + bar: obj2, }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -133,24 +105,16 @@ moduleFor( count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let MyMixin2 = Mixin.create({ bar: obj2 }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); MyMixin2.apply(obj); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -163,15 +127,11 @@ moduleFor( count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({ bar: obj2 }, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -185,15 +145,11 @@ moduleFor( count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({}, MyMixin2, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -207,15 +163,11 @@ moduleFor( count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({}, MyMixin, MyMixin2); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -231,29 +183,17 @@ moduleFor( count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = mixin({ bar: obj2 }, MyMixin, MyMixin2); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); - - assert.equal( - isWatching(obj2, 'baz'), - false, - 'should not be watching baz' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); + + assert.equal(isWatching(obj2, 'baz'), false, 'should not be watching baz'); assert.equal(isWatching(obj3, 'baz'), true, 'should be watching baz'); set(obj2, 'baz', 'BAZ'); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer after change' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer after change'); set(obj3, 'baz', 'BEAR'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); diff --git a/packages/ember-metal/tests/mixin/reopen_test.js b/packages/ember-metal/tests/mixin/reopen_test.js index 2de1f7a1485..358cb9a4fc0 100644 --- a/packages/ember-metal/tests/mixin/reopen_test.js +++ b/packages/ember-metal/tests/mixin/reopen_test.js @@ -26,13 +26,13 @@ moduleFor( // used to end in an infinite call loop this._super(...arguments); return 'Breakfast!'; - } + }, }); Taco.reopen({ createBreakfast() { return this._super(...arguments); - } + }, }); let taco = Taco.create(); diff --git a/packages/ember-metal/tests/mixin/required_test.js b/packages/ember-metal/tests/mixin/required_test.js index 5d8fe8c732e..17173b562e8 100644 --- a/packages/ember-metal/tests/mixin/required_test.js +++ b/packages/ember-metal/tests/mixin/required_test.js @@ -14,12 +14,12 @@ moduleFor( expectDeprecation(() => { PartialMixin = Mixin.create({ foo: required(), - bar: 'BAR' + bar: 'BAR', }); }, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.'); FinalMixin = Mixin.create({ - foo: 'FOO' + foo: 'FOO', }); obj = {}; diff --git a/packages/ember-metal/tests/mixin/without_test.js b/packages/ember-metal/tests/mixin/without_test.js index 337a393bb53..138c0b52f98 100644 --- a/packages/ember-metal/tests/mixin/without_test.js +++ b/packages/ember-metal/tests/mixin/without_test.js @@ -4,12 +4,10 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'without', class extends AbstractTestCase { - ['@test without should create a new mixin excluding named properties']( - assert - ) { + ['@test without should create a new mixin excluding named properties'](assert) { let MixinA = Mixin.create({ foo: 'FOO', - bar: 'BAR' + bar: 'BAR', }); let MixinB = MixinA.without('bar'); diff --git a/packages/ember-metal/tests/observer_test.js b/packages/ember-metal/tests/observer_test.js index ec22732ea7e..fe277867bcb 100644 --- a/packages/ember-metal/tests/observer_test.js +++ b/packages/ember-metal/tests/observer_test.js @@ -13,7 +13,7 @@ import { endPropertyChanges, changeProperties, get, - set + set, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -41,11 +41,7 @@ moduleFor( let count = 0; addObserver(obj, 'foo', function() { - assert.equal( - get(obj, 'foo'), - 'bar', - 'should invoke AFTER value changed' - ); + assert.equal(get(obj, 'foo'), 'bar', 'should invoke AFTER value changed'); count++; }); @@ -67,11 +63,7 @@ moduleFor( let count = 0; addObserver(obj, 'foo', function() { - assert.equal( - get(obj, 'foo'), - 'BAZ', - 'should have invoked after prop change' - ); + assert.equal(get(obj, 'foo'), 'BAZ', 'should have invoked after prop change'); count++; }); @@ -79,9 +71,7 @@ moduleFor( assert.equal(count, 1, 'should have invoked observer'); } - ['@test observer should continue to fire after dependent properties are accessed']( - assert - ) { + ['@test observer should continue to fire after dependent properties are accessed'](assert) { let observerCount = 0; let obj = {}; @@ -123,22 +113,14 @@ moduleFor( mixin(obj, { observeFooAndBar: function() { count++; - }.observes('{foo,bar}') + }.observes('{foo,bar}'), }); set(obj, 'foo', 'foo'); - assert.equal( - count, - 1, - 'observer specified via brace expansion invoked on property change' - ); + assert.equal(count, 1, 'observer specified via brace expansion invoked on property change'); set(obj, 'bar', 'bar'); - assert.equal( - count, - 2, - 'observer specified via brace expansion invoked on property change' - ); + assert.equal(count, 2, 'observer specified via brace expansion invoked on property change'); set(obj, 'baz', 'baz'); assert.equal(count, 2, 'observer not invoked on unspecified property'); @@ -173,7 +155,7 @@ moduleFor( mixin(obj, { fooAndBarWatcher: function() { count++; - }.observes('{foo,bar}') + }.observes('{foo,bar}'), }); get(obj, 'foo'); @@ -201,22 +183,14 @@ moduleFor( mixin(obj, { observeFooAndBar: observer('{foo,bar}', function() { count++; - }) + }), }); set(obj, 'foo', 'foo'); - assert.equal( - count, - 1, - 'observer specified via brace expansion invoked on property change' - ); + assert.equal(count, 1, 'observer specified via brace expansion invoked on property change'); set(obj, 'bar', 'bar'); - assert.equal( - count, - 2, - 'observer specified via brace expansion invoked on property change' - ); + assert.equal(count, 2, 'observer specified via brace expansion invoked on property change'); set(obj, 'baz', 'baz'); assert.equal(count, 2, 'observer not invoked on unspecified property'); @@ -247,7 +221,7 @@ moduleFor( mixin(obj, { fooAndBarWatcher: observer('{foo,bar}', function() { count++; - }) + }), }); get(obj, 'foo'); @@ -338,9 +312,7 @@ moduleFor( assert.equal(fooCount, 1, 'foo should have fired once'); } - ['@test deferring property change notifications safely despite exceptions']( - assert - ) { + ['@test deferring property change notifications safely despite exceptions'](assert) { let obj = { foo: 'foo' }; let fooCount = 0; let exc = new Error('Something unexpected happened!'); @@ -389,11 +361,7 @@ moduleFor( obj2.count = 0; set(obj, 'foo', 'baz'); assert.equal(obj.count, 1, 'should have invoked observer on parent'); - assert.equal( - obj2.count, - 0, - 'should not have invoked observer on inherited' - ); + assert.equal(obj2.count, 0, 'should not have invoked observer on inherited'); } ['@test addObserver should respect targets with methods'](assert) { @@ -409,7 +377,7 @@ moduleFor( assert.equal(keyName, 'foo', 'param2 should be keyName'); assert.equal(value, 'BAZ', 'param3 should new value'); this.count++; - } + }, }; let target2 = { @@ -422,7 +390,7 @@ moduleFor( assert.equal(keyName, 'foo', 'param2 should be keyName'); assert.equal(value, 'BAZ', 'param3 should new value'); this.count++; - } + }, }; addObserver(observed, 'foo', target1, 'didChange'); @@ -433,9 +401,7 @@ moduleFor( assert.equal(target2.count, 1, 'target2 observer should have fired'); } - ['@test addObserver should allow multiple objects to observe a property']( - assert - ) { + ['@test addObserver should allow multiple objects to observe a property'](assert) { let observed = { foo: 'foo' }; let target1 = { @@ -443,7 +409,7 @@ moduleFor( didChange() { this.count++; - } + }, }; let target2 = { @@ -451,7 +417,7 @@ moduleFor( didChange() { this.count++; - } + }, }; addObserver(observed, 'foo', target1, 'didChange'); @@ -498,7 +464,7 @@ moduleFor( foo2: observer('bar', function() { barObserved++; - }) + }), }); let obj = {}; @@ -523,7 +489,7 @@ moduleFor( didChange() { this.count++; - } + }, }; let target2 = { @@ -531,7 +497,7 @@ moduleFor( didChange() { this.count++; - } + }, }; addObserver(observed, 'foo', target1, 'didChange'); @@ -566,19 +532,19 @@ moduleFor( foo: { bar: { baz: { - biff: 'BIFF' - } - } + biff: 'BIFF', + }, + }, }, Capital: { foo: { bar: { baz: { - biff: 'BIFF' - } - } - } - } + biff: 'BIFF', + }, + }, + }, + }, }; count = 0; @@ -718,9 +684,7 @@ moduleFor( // The issue here is when a computed property is directly set with a value, then has a // dependent key change (which triggers a cache expiration and recomputation), observers will // not be fired if the CP setter is called with the last set value. - ['@test setting a cached computed property whose value has changed should trigger']( - assert - ) { + ['@test setting a cached computed property whose value has changed should trigger'](assert) { let obj = {}; defineProperty( @@ -732,7 +696,7 @@ moduleFor( }, set: function(key, value) { return value; - } + }, }).property('baz') ); @@ -761,11 +725,9 @@ moduleFor( moduleFor( 'changeProperties', class extends AbstractTestCase { - ['@test observers added/removed during changeProperties should do the right thing.']( - assert - ) { + ['@test observers added/removed during changeProperties should do the right thing.'](assert) { let obj = { - foo: 0 + foo: 0, }; function Observer() { this.didChangeCount = 0; @@ -779,7 +741,7 @@ moduleFor( }, didChange() { this.didChangeCount++; - } + }, }; let addedBeforeFirstChangeObserver = new Observer(); let addedAfterFirstChangeObserver = new Observer(); @@ -849,9 +811,7 @@ moduleFor( ); } - ['@test calling changeProperties while executing deferred observers works correctly']( - assert - ) { + ['@test calling changeProperties while executing deferred observers works correctly'](assert) { let obj = { foo: 0 }; let fooDidChange = 0; @@ -964,11 +924,7 @@ moduleFor( let itsMyLastBeer = new Beer(); set(itsMyLastBeer, 'type', 'ale'); removeObserver(beer, 'type', K); - assert.deepEqual( - Object.keys(itsMyLastBeer), - ['type'], - 'set -> removeObserver' - ); + assert.deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); } ['@test observers switched on and off with setter in between (observed property is shadowing one on the prototype)']( @@ -999,11 +955,7 @@ moduleFor( let itsMyLastBeer = new Beer(); set(itsMyLastBeer, 'type', 'ale'); removeObserver(beer, 'type', K); - assert.deepEqual( - Object.keys(itsMyLastBeer), - ['type'], - 'set -> removeObserver' - ); + assert.deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); } } ); diff --git a/packages/ember-metal/tests/performance_test.js b/packages/ember-metal/tests/performance_test.js index c6d5f683542..f88f074495a 100644 --- a/packages/ember-metal/tests/performance_test.js +++ b/packages/ember-metal/tests/performance_test.js @@ -6,7 +6,7 @@ import { notifyPropertyChange, beginPropertyChanges, endPropertyChanges, - addObserver + addObserver, } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; diff --git a/packages/ember-metal/tests/properties_test.js b/packages/ember-metal/tests/properties_test.js index e6f8984736c..4a218c497f8 100644 --- a/packages/ember-metal/tests/properties_test.js +++ b/packages/ember-metal/tests/properties_test.js @@ -12,16 +12,14 @@ moduleFor( assert.equal(obj.toString(), 'FOO', 'should replace toString'); } - ['@test for data properties, didDefineProperty hook should be called if implemented']( - assert - ) { + ['@test for data properties, didDefineProperty hook should be called if implemented'](assert) { assert.expect(2); let obj = { didDefineProperty(obj, keyName, value) { assert.equal(keyName, 'foo', 'key name should be foo'); assert.equal(value, 'bar', 'value should be bar'); - } + }, }; defineProperty(obj, 'foo', undefined, 'bar'); @@ -44,7 +42,7 @@ moduleFor( computedProperty, 'value should be passed as computed property' ); - } + }, }; defineProperty(obj, 'foo', computedProperty); @@ -59,18 +57,14 @@ moduleFor( writable: true, configurable: false, enumerable: true, - value: 42 + value: 42, }; let obj = { didDefineProperty(obj, keyName, value) { assert.equal(keyName, 'answer', 'key name should be answer'); - assert.strictEqual( - value, - descriptor, - 'value should be passed as descriptor' - ); - } + assert.strictEqual(value, descriptor, 'value should be passed as descriptor'); + }, }; defineProperty(obj, 'answer', descriptor); diff --git a/packages/ember-metal/tests/property_did_change_hook.js b/packages/ember-metal/tests/property_did_change_hook.js index 3310f9ef810..fd51c4ae391 100644 --- a/packages/ember-metal/tests/property_did_change_hook.js +++ b/packages/ember-metal/tests/property_did_change_hook.js @@ -1,12 +1,4 @@ -import { - isWatching, - defineProperty, - alias, - PROPERTY_DID_CHANGE, - computed, - get, - set -} from '..'; +import { isWatching, defineProperty, alias, PROPERTY_DID_CHANGE, computed, get, set } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( @@ -18,7 +10,7 @@ moduleFor( child: {}, [PROPERTY_DID_CHANGE](keyName) { counts[keyName] = (counts[keyName] || 0) + 1; - } + }, }; defineProperty(obj, 'cost', alias('child.cost')); @@ -30,14 +22,11 @@ moduleFor( computed('cost', 'tax', { get() { return get(this, 'cost') + get(this, 'tax'); - } + }, }) ); - assert.ok( - !isWatching(obj, 'child.cost'), - 'precond alias target `child.cost` is not watched' - ); + assert.ok(!isWatching(obj, 'child.cost'), 'precond alias target `child.cost` is not watched'); assert.equal(get(obj, 'cost'), undefined); // this is how PROPERTY_DID_CHANGE will get notified assert.ok( @@ -45,10 +34,7 @@ moduleFor( 'alias target `child.cost` is watched after consumption' ); - assert.ok( - !isWatching(obj, 'child.tax'), - 'precond alias target `child.tax` is not watched' - ); + assert.ok(!isWatching(obj, 'child.tax'), 'precond alias target `child.tax` is not watched'); assert.equal(get(obj, 'tax'), undefined); // this is how PROPERTY_DID_CHANGE will get notified assert.ok( @@ -62,7 +48,7 @@ moduleFor( // decrements the watching count on the alias itself to 0 set(obj, 'child', { cost: 399.0, - tax: 32.93 + tax: 32.93, }); // this should have called PROPERTY_DID_CHANGE for all of them @@ -76,7 +62,7 @@ moduleFor( set(obj, 'child', { cost: 100.0, - tax: 10.0 + tax: 10.0, }); assert.equal(counts['cost'], 2, 'PROPERTY_DID_CHANGE called with cost'); diff --git a/packages/ember-metal/tests/run_loop/debounce_test.js b/packages/ember-metal/tests/run_loop/debounce_test.js index c1aca507398..db809e06884 100644 --- a/packages/ember-metal/tests/run_loop/debounce_test.js +++ b/packages/ember-metal/tests/run_loop/debounce_test.js @@ -11,7 +11,7 @@ moduleFor( let target = { someFunc(...args) { calledWith.push(args); - } + }, }; debounce(target, target.someFunc, 10); @@ -19,11 +19,7 @@ moduleFor( debounce(target, target.someFunc, 10); setTimeout(() => { - assert.deepEqual( - calledWith, - [[]], - 'someFunc called once with correct arguments' - ); + assert.deepEqual(calledWith, [[]], 'someFunc called once with correct arguments'); done(); }, 20); } @@ -35,7 +31,7 @@ moduleFor( let target = { someFunc(...args) { calledWith.push(args); - } + }, }; debounce(target, 'someFunc', 10); @@ -43,11 +39,7 @@ moduleFor( debounce(target, 'someFunc', 10); setTimeout(() => { - assert.deepEqual( - calledWith, - [[]], - 'someFunc called once with correct arguments' - ); + assert.deepEqual(calledWith, [[]], 'someFunc called once with correct arguments'); done(); }, 20); } @@ -65,11 +57,7 @@ moduleFor( debounce(someFunc, 10); setTimeout(() => { - assert.deepEqual( - calledWith, - [[]], - 'someFunc called once with correct arguments' - ); + assert.deepEqual(calledWith, [[]], 'someFunc called once with correct arguments'); done(); }, 20); } diff --git a/packages/ember-metal/tests/run_loop/later_test.js b/packages/ember-metal/tests/run_loop/later_test.js index 8a399edb68e..1cc4c475ab2 100644 --- a/packages/ember-metal/tests/run_loop/later_test.js +++ b/packages/ember-metal/tests/run_loop/later_test.js @@ -1,13 +1,6 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; import { assign } from 'ember-utils'; -import { - run, - later, - backburner, - isNone, - hasScheduledTimers, - getCurrentRunLoop -} from '../..'; +import { run, later, backburner, isNone, hasScheduledTimers, getCurrentRunLoop } from '../..'; const originalSetTimeout = window.setTimeout; const originalDateValueOf = Date.prototype.valueOf; @@ -49,9 +42,7 @@ moduleFor( Date.prototype.valueOf = originalDateValueOf; } - ['@test should invoke after specified period of time - function only']( - assert - ) { + ['@test should invoke after specified period of time - function only'](assert) { let done = assert.async(); let invoked = false; @@ -65,9 +56,7 @@ moduleFor( }); } - ['@test should invoke after specified period of time - target/method']( - assert - ) { + ['@test should invoke after specified period of time - target/method'](assert) { let done = assert.async(); let obj = { invoked: false }; @@ -87,9 +76,7 @@ moduleFor( }); } - ['@test should invoke after specified period of time - target/method/args']( - assert - ) { + ['@test should invoke after specified period of time - target/method/args'](assert) { let done = assert.async(); let obj = { invoked: 0 }; @@ -138,10 +125,7 @@ moduleFor( wait(() => { assert.equal(obj.invoked, 10, 'should have invoked later item'); assert.ok(secondRunLoop, 'second run loop took place'); - assert.ok( - secondRunLoop !== firstRunLoop, - 'two different run loops took place' - ); + assert.ok(secondRunLoop !== firstRunLoop, 'two different run loops took place'); done(); }); } @@ -204,9 +188,7 @@ moduleFor( // }); // }); - ['@test inception calls to later should run callbacks in separate run loops']( - assert - ) { + ['@test inception calls to later should run callbacks in separate run loops'](assert) { let done = assert.async(); let runLoop, finished; @@ -253,7 +235,7 @@ moduleFor( assert.ok(!isNaN(wait) && wait >= 0, 'wait is a non-negative number'); return originalPlatform.setTimeout.apply(originalPlatform, arguments); - } + }, }); let count = 0; diff --git a/packages/ember-metal/tests/run_loop/next_test.js b/packages/ember-metal/tests/run_loop/next_test.js index 5c2e1fb5ee0..306b212a403 100644 --- a/packages/ember-metal/tests/run_loop/next_test.js +++ b/packages/ember-metal/tests/run_loop/next_test.js @@ -36,9 +36,7 @@ moduleFor( }, 20); } - ['@test multiple calls to next share coalesce callbacks into same run loop']( - assert - ) { + ['@test multiple calls to next share coalesce callbacks into same run loop'](assert) { let done = assert.async(); let secondRunLoop, thirdRunLoop; run(() => { diff --git a/packages/ember-metal/tests/run_loop/onerror_test.js b/packages/ember-metal/tests/run_loop/onerror_test.js index b3492966b98..64f80afa0ca 100644 --- a/packages/ember-metal/tests/run_loop/onerror_test.js +++ b/packages/ember-metal/tests/run_loop/onerror_test.js @@ -1,10 +1,4 @@ -import { - run, - setOnerror, - getOnerror, - setDispatchOverride, - getDispatchOverride -} from '../..'; +import { run, setOnerror, getOnerror, setDispatchOverride, getDispatchOverride } from '../..'; import { isTesting, setTesting } from 'ember-debug'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; diff --git a/packages/ember-metal/tests/run_loop/run_bind_test.js b/packages/ember-metal/tests/run_loop/run_bind_test.js index 5e7a695df80..9b30c69b811 100644 --- a/packages/ember-metal/tests/run_loop/run_bind_test.js +++ b/packages/ember-metal/tests/run_loop/run_bind_test.js @@ -12,7 +12,7 @@ moduleFor( increment(increment) { assert.ok(getCurrentRunLoop(), 'expected a run-loop'); return (this.value += increment); - } + }, }; let proxiedFunction = bind(obj, obj.increment, 1); diff --git a/packages/ember-metal/tests/run_loop/run_test.js b/packages/ember-metal/tests/run_loop/run_test.js index e370cc4b6bd..dc12d9108c5 100644 --- a/packages/ember-metal/tests/run_loop/run_test.js +++ b/packages/ember-metal/tests/run_loop/run_test.js @@ -12,20 +12,12 @@ moduleFor( bar: 'BAR', checkArgs(arg1, arg2) { return [arg1, this.bar, arg2]; - } + }, }; assert.equal(run(() => 'FOO'), 'FOO', 'pass function only'); - assert.deepEqual( - run(obj, obj.foo), - ['BAR', 'FOO'], - 'pass obj and obj.method' - ); - assert.deepEqual( - run(obj, 'foo'), - ['BAR', 'FOO'], - 'pass obj and "method"' - ); + assert.deepEqual(run(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method'); + assert.deepEqual(run(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and "method"'); assert.deepEqual( run(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], diff --git a/packages/ember-metal/tests/run_loop/schedule_test.js b/packages/ember-metal/tests/run_loop/schedule_test.js index 5eda08bb028..5ae132422c8 100644 --- a/packages/ember-metal/tests/run_loop/schedule_test.js +++ b/packages/ember-metal/tests/run_loop/schedule_test.js @@ -43,9 +43,7 @@ moduleFor( assert.equal(cnt, 2, 'should flush actions now'); } - ['@test prior queues should be flushed before moving on to next queue']( - assert - ) { + ['@test prior queues should be flushed before moving on to next queue'](assert) { let order = []; run(() => { @@ -82,13 +80,7 @@ moduleFor( }); }); - assert.deepEqual(order, [ - 'sync', - 'actions', - 'sync', - 'actions', - 'destroy' - ]); + assert.deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'destroy']); } ['@test makes sure it does not trigger an autorun during testing']() { diff --git a/packages/ember-metal/tests/set_properties_test.js b/packages/ember-metal/tests/set_properties_test.js index e2d5f0b7b49..41bf8e53aa2 100644 --- a/packages/ember-metal/tests/set_properties_test.js +++ b/packages/ember-metal/tests/set_properties_test.js @@ -5,11 +5,7 @@ moduleFor( 'setProperties', class extends AbstractTestCase { ['@test supports setting multiple attributes at once'](assert) { - assert.deepEqual( - setProperties(null, null), - null, - 'noop for null properties and null object' - ); + assert.deepEqual(setProperties(null, null), null, 'noop for null properties and null object'); assert.deepEqual( setProperties(undefined, undefined), undefined, @@ -17,11 +13,7 @@ moduleFor( ); assert.deepEqual(setProperties({}), undefined, 'noop for no properties'); - assert.deepEqual( - setProperties({}, undefined), - undefined, - 'noop for undefined' - ); + assert.deepEqual(setProperties({}, undefined), undefined, 'noop for undefined'); assert.deepEqual(setProperties({}, null), null, 'noop for null'); assert.deepEqual(setProperties({}, NaN), NaN, 'noop for NaN'); assert.deepEqual(setProperties({}, {}), {}, 'meh'); @@ -31,11 +23,7 @@ moduleFor( assert.ok('foo' in props, 'Setting undefined value'); assert.deepEqual(Object.keys(props), ['foo'], 'Setting undefined value'); - assert.deepEqual( - setProperties({}, { foo: 1 }), - { foo: 1 }, - 'Set a single property' - ); + assert.deepEqual(setProperties({}, { foo: 1 }), { foo: 1 }, 'Set a single property'); assert.deepEqual( setProperties({}, { foo: 1, bar: 1 }), @@ -52,7 +40,7 @@ moduleFor( assert.deepEqual( setProperties({ foo: 2, baz: 2 }, { bar: 2 }), { - bar: 2 + bar: 2, }, 'Set an additional, previously unset property' ); diff --git a/packages/ember-metal/tests/tracked/computed_test.js b/packages/ember-metal/tests/tracked/computed_test.js index 4bd02169e4e..116aa9ca5d7 100644 --- a/packages/ember-metal/tests/tracked/computed_test.js +++ b/packages/ember-metal/tests/tracked/computed_test.js @@ -18,11 +18,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { } } - tracked( - Count.prototype, - 'foo', - Object.getOwnPropertyDescriptor(Count.prototype, 'foo') - ); + tracked(Count.prototype, 'foo', Object.getOwnPropertyDescriptor(Count.prototype, 'foo')); let obj = new Count(); @@ -30,9 +26,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { assert.equal(count, 1, 'should have invoked computed property'); } - ['@test defining computed property should invoke property on get']( - assert - ) { + ['@test defining computed property should invoke property on get'](assert) { let count = 0; class Count { @@ -42,11 +36,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { } } - tracked( - Count.prototype, - 'foo', - Object.getOwnPropertyDescriptor(Count.prototype, 'foo') - ); + tracked(Count.prototype, 'foo', Object.getOwnPropertyDescriptor(Count.prototype, 'foo')); let obj = new Count(); @@ -54,9 +44,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { assert.equal(count, 1, 'should have invoked computed property'); } - ['@test defining computed property should invoke property on set']( - assert - ) { + ['@test defining computed property should invoke property on set'](assert) { let count = 0; let obj = createWithDescriptors({ @@ -67,16 +55,12 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { set foo(value) { count++; this.__foo = `computed ${value}`; - } + }, }); assert.equal(set(obj, 'foo', 'bar'), 'bar', 'should return set value'); assert.equal(count, 1, 'should have invoked computed property'); - assert.equal( - get(obj, 'foo'), - 'computed bar', - 'should return new value' - ); + assert.equal(get(obj, 'foo'), 'computed bar', 'should return new value'); } } ); diff --git a/packages/ember-metal/tests/tracked/get_test.js b/packages/ember-metal/tests/tracked/get_test.js index db737a6a5f5..18a879b306a 100644 --- a/packages/ember-metal/tests/tracked/get_test.js +++ b/packages/ember-metal/tests/tracked/get_test.js @@ -16,7 +16,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { number: 23, boolTrue: true, boolFalse: false, - nullValue: null + nullValue: null, }); for (let key in obj) { @@ -39,11 +39,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { } } - tracked( - Count.prototype, - 'id', - Object.getOwnPropertyDescriptor(Count.prototype, 'id') - ); + tracked(Count.prototype, 'id', Object.getOwnPropertyDescriptor(Count.prototype, 'id')); let obj = new Count(); @@ -63,7 +59,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { number: 23, boolTrue: true, boolFalse: false, - nullValue: null + nullValue: null, }); for (let key in obj) { @@ -71,7 +67,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { } obj = createTracked({ - undef: undefined + undef: undefined, }); assert.equal( diff --git a/packages/ember-metal/tests/tracked/set_test.js b/packages/ember-metal/tests/tracked/set_test.js index 3389493bdda..dee4e6ea13e 100644 --- a/packages/ember-metal/tests/tracked/set_test.js +++ b/packages/ember-metal/tests/tracked/set_test.js @@ -20,19 +20,15 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { boolTrue: true, boolFalse: false, nullValue: null, - undefinedValue: undefined + undefinedValue: undefined, }); let newObj = createTracked({ - undefinedValue: 'emberjs' + undefinedValue: 'emberjs', }); for (let key in obj) { - assert.equal( - set(newObj, key, obj[key]), - obj[key], - 'should return value' - ); + assert.equal(set(newObj, key, obj[key]), obj[key], 'should return value'); assert.equal(get(newObj, key), obj[key], 'should set value'); } } diff --git a/packages/ember-metal/tests/tracked/support.js b/packages/ember-metal/tests/tracked/support.js index 96834c18573..6d4bc761a78 100644 --- a/packages/ember-metal/tests/tracked/support.js +++ b/packages/ember-metal/tests/tracked/support.js @@ -15,7 +15,7 @@ export function createTracked(values, proto = {}) { enumerable: true, configurable: true, writable: true, - value: values[prop] + value: values[prop], }) ); } @@ -30,11 +30,7 @@ export function createWithDescriptors(values) { for (let prop in values) { let descriptor = Object.getOwnPropertyDescriptor(values, prop); - Object.defineProperty( - Class.prototype, - prop, - tracked(Class.prototype, prop, descriptor) - ); + Object.defineProperty(Class.prototype, prop, tracked(Class.prototype, prop, descriptor)); } return new Class(); diff --git a/packages/ember-metal/tests/tracked/validation_test.js b/packages/ember-metal/tests/tracked/validation_test.js index 5a86995ee43..30fe3490b35 100644 --- a/packages/ember-metal/tests/tracked/validation_test.js +++ b/packages/ember-metal/tests/tracked/validation_test.js @@ -22,7 +22,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { track(Tracked, ['first', 'last'], { get full() { return `${this.first} ${this.last}`; - } + }, }); let obj = new Tracked('Tom', 'Dale'); @@ -58,7 +58,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { track(Tracked, ['name'], { get full() { return `${get(this.name, 'first')} ${get(this.name, 'last')}`; - } + }, }); let tom = { first: 'Tom', last: 'Dale' }; @@ -76,11 +76,7 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { assert.equal(tag.validate(snapshot), true); set(tom, 'first', 'Thomas'); - assert.equal( - tag.validate(snapshot), - false, - 'invalid after setting with Ember set' - ); + assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember set'); assert.equal(obj.full, 'Thomas Dale'); snapshot = tag.value(); @@ -189,31 +185,19 @@ if (EMBER_METAL_TRACKED_PROPERTIES) { assert.equal(tag.validate(snapshot), true); set(tom, 'first', 'Thomas'); - assert.equal( - tag.validate(snapshot), - false, - 'invalid after setting with Ember.set' - ); + assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'Thomas Dale'); snapshot = tag.value(); tom = contact.name = new EmberName('T', 'Dale'); - assert.equal( - tag.validate(snapshot), - false, - 'invalid after setting with Ember.set' - ); + assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'T Dale'); snapshot = tag.value(); set(tom, 'first', 'Tizzle'); - assert.equal( - tag.validate(snapshot), - false, - 'invalid after setting with Ember.set' - ); + assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'Tizzle Dale'); } @@ -228,9 +212,7 @@ function track(Class, properties, accessors = {}) { let keys = Object.getOwnPropertyNames(accessors); - keys.forEach(key => - defineAccessor(proto, key, Object.getOwnPropertyDescriptor(accessors, key)) - ); + keys.forEach(key => defineAccessor(proto, key, Object.getOwnPropertyDescriptor(accessors, key))); } function defineData(prototype, property) { @@ -241,15 +223,11 @@ function defineData(prototype, property) { enumerable: true, configurable: true, writable: true, - value: undefined + value: undefined, }) ); } function defineAccessor(prototype, property, descriptor) { - Object.defineProperty( - prototype, - property, - tracked(prototype, property, descriptor) - ); + Object.defineProperty(prototype, property, tracked(prototype, property, descriptor)); } diff --git a/packages/ember-metal/tests/watching/is_watching_test.js b/packages/ember-metal/tests/watching/is_watching_test.js index c22f1cd7109..faa6c4ed338 100644 --- a/packages/ember-metal/tests/watching/is_watching_test.js +++ b/packages/ember-metal/tests/watching/is_watching_test.js @@ -6,7 +6,7 @@ import { observer, addObserver, removeObserver, - isWatching + isWatching, } from '../..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -14,23 +14,11 @@ function testObserver(assert, setup, teardown, key = 'key') { let obj = {}; function fn() {} - assert.equal( - isWatching(obj, key), - false, - 'precond - isWatching is false by default' - ); + assert.equal(isWatching(obj, key), false, 'precond - isWatching is false by default'); setup(obj, key, fn); - assert.equal( - isWatching(obj, key), - true, - 'isWatching is true when observers are added' - ); + assert.equal(isWatching(obj, key), true, 'isWatching is true when observers are added'); teardown(obj, key, fn); - assert.equal( - isWatching(obj, key), - false, - 'isWatching is false after observers are removed' - ); + assert.equal(isWatching(obj, key), false, 'isWatching is false after observers are removed'); } moduleFor( @@ -41,7 +29,7 @@ moduleFor( assert, (obj, key, fn) => { Mixin.create({ - didChange: observer(key, fn) + didChange: observer(key, fn), }).apply(obj); }, (obj, key, fn) => removeObserver(obj, key, obj, fn) diff --git a/packages/ember-metal/tests/watching/unwatch_test.js b/packages/ember-metal/tests/watching/unwatch_test.js index 10ed03bb2bf..e66e103a6e6 100644 --- a/packages/ember-metal/tests/watching/unwatch_test.js +++ b/packages/ember-metal/tests/watching/unwatch_test.js @@ -1,11 +1,4 @@ -import { - watch, - unwatch, - defineProperty, - addListener, - computed, - set -} from '../..'; +import { watch, unwatch, defineProperty, addListener, computed, set } from '../..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; let didCount; @@ -34,7 +27,7 @@ moduleFor( set(keyName, value) { this.__foo = value; return this.__foo; - } + }, }) ); addListeners(obj, 'foo'); @@ -99,13 +92,11 @@ moduleFor( assert.equal(didCount, 0, 'should NOT have invoked didCount'); } - ['@test unwatching should not destroy non MANDATORY_SETTER descriptor']( - assert - ) { + ['@test unwatching should not destroy non MANDATORY_SETTER descriptor'](assert) { let obj = { get foo() { return 'RUN'; - } + }, }; assert.equal(obj.foo, 'RUN', 'obj.foo'); diff --git a/packages/ember-metal/tests/watching/watch_test.js b/packages/ember-metal/tests/watching/watch_test.js index bf3e62b2006..cdac457482a 100644 --- a/packages/ember-metal/tests/watching/watch_test.js +++ b/packages/ember-metal/tests/watching/watch_test.js @@ -8,7 +8,7 @@ import { addListener, watch, unwatch, - deleteMeta + deleteMeta, } from '../..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -50,7 +50,7 @@ moduleFor( this.__foo = value; } return this.__foo; - } + }, }) ); addListeners(obj, 'foo'); @@ -155,27 +155,17 @@ moduleFor( assert.equal(didCount, 2, 'should have invoked didChange twice'); } - ['@test watching an object value then unwatching should restore old value']( - assert - ) { + ['@test watching an object value then unwatching should restore old value'](assert) { let obj = { foo: { bar: { baz: { biff: 'BIFF' } } } }; addListeners(obj, 'foo.bar.baz.biff'); watch(obj, 'foo.bar.baz.biff'); let foo = get(obj, 'foo'); - assert.equal( - get(get(get(foo, 'bar'), 'baz'), 'biff'), - 'BIFF', - 'biff should exist' - ); + assert.equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); unwatch(obj, 'foo.bar.baz.biff'); - assert.equal( - get(get(get(foo, 'bar'), 'baz'), 'biff'), - 'BIFF', - 'biff should exist' - ); + assert.equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); } ['@test when watching another object, destroy should remove chain watchers from the other object']( @@ -200,11 +190,7 @@ moduleFor( deleteMeta(objA); - assert.equal( - meta_objB.peekWatching('foo'), - 0, - 'should not be watching foo' - ); + assert.equal(meta_objB.peekWatching('foo'), 0, 'should not be watching foo'); assert.equal( meta_objB.readableChainWatchers().has('foo', chainNode), false, @@ -219,11 +205,7 @@ moduleFor( addListeners(obj, 'length'); watch(obj, 'length'); - assert.equal( - get(obj, 'length'), - '26.2 miles', - 'should have original prop' - ); + assert.equal(get(obj, 'length'), '26.2 miles', 'should have original prop'); set(obj, 'length', '10k'); assert.equal(didCount, 1, 'should have invoked didCount'); @@ -251,7 +233,7 @@ moduleFor( let child = { get b() { return parent.b; - } + }, }; assert.equal(parent.b, 1, 'parent.b should be 1'); @@ -263,11 +245,7 @@ moduleFor( assert.equal(parent.b, 1, 'parent.b should be 1 (after watch)'); assert.equal(child.b, 1, 'child.b should be 1 (after watch)'); - assert.equal( - get(child, 'b'), - 1, - 'get(child, "b") should be 1 (after watch)' - ); + assert.equal(get(child, 'b'), 1, 'get(child, "b") should be 1 (after watch)'); } ['@test watch + set + no-descriptor'](assert) { diff --git a/packages/ember-routing/lib/ext/controller.js b/packages/ember-routing/lib/ext/controller.js index 12b58dd9335..a3ab6936048 100644 --- a/packages/ember-routing/lib/ext/controller.js +++ b/packages/ember-routing/lib/ext/controller.js @@ -215,7 +215,7 @@ ControllerMixin.reopen({ let target = get(this, 'target'); let method = target.replaceRoute || target.replaceWith; return method.apply(target, prefixRouteNameArg(this, args)); - } + }, }); export default ControllerMixin; diff --git a/packages/ember-routing/lib/index.js b/packages/ember-routing/lib/index.js index dce6f4b8dc9..3ee44fa5dfb 100644 --- a/packages/ember-routing/lib/index.js +++ b/packages/ember-routing/lib/index.js @@ -9,7 +9,7 @@ export { default as AutoLocation } from './location/auto_location'; export { default as generateController, - generateControllerFactory + generateControllerFactory, } from './system/generate_controller'; export { default as controllerFor } from './system/controller_for'; export { default as RouterDSL } from './system/dsl'; diff --git a/packages/ember-routing/lib/location/api.js b/packages/ember-routing/lib/location/api.js index 10a5e8f3143..ddabb505961 100644 --- a/packages/ember-routing/lib/location/api.js +++ b/packages/ember-routing/lib/location/api.js @@ -88,10 +88,7 @@ export default { */ create(options) { let implementation = options && options.implementation; - assert( - "Location.create: you must specify a 'implementation' option", - !!implementation - ); + assert("Location.create: you must specify a 'implementation' option", !!implementation); let implementationClass = this.implementations[implementation]; assert( @@ -117,5 +114,5 @@ export default { */ _getHash() { return getHash(this.location); - } + }, }; diff --git a/packages/ember-routing/lib/location/auto_location.js b/packages/ember-routing/lib/location/auto_location.js index a81cace6ba6..b9a2a80806f 100644 --- a/packages/ember-routing/lib/location/auto_location.js +++ b/packages/ember-routing/lib/location/auto_location.js @@ -11,7 +11,7 @@ import { getHash, getQuery, getFullPath, - replacePath + replacePath, } from './util'; /** @@ -152,7 +152,7 @@ export default EmberObject.extend({ userAgent: this.userAgent, rootURL, documentMode: this.documentMode, - global: this.global + global: this.global, }); if (implementation === false) { @@ -181,7 +181,7 @@ export default EmberObject.extend({ if (concreteImplementation) { concreteImplementation.destroy(); } - } + }, }); function delegateToConcreteImplementation(methodName) { @@ -236,10 +236,7 @@ function detectImplementation(options) { // Be sure we're using a hashed path, otherwise let's switch over it to so // we start off clean and consistent. We'll count an index path with no // hash as "good enough" as well. - if ( - currentPath === hashPath || - (currentPath === '/' && hashPath === '/#/') - ) { + if (currentPath === hashPath || (currentPath === '/' && hashPath === '/#/')) { implementation = 'hash'; } else { // Our URL isn't in the expected hash-supported format, so we want to @@ -270,10 +267,7 @@ export function getHistoryPath(rootURL, location) { let rootURLIndex = path.indexOf(rootURL); let routeHash, hashParts; - assert( - `Path ${path} does not start with the provided rootURL ${rootURL}`, - rootURLIndex === 0 - ); + assert(`Path ${path} does not start with the provided rootURL ${rootURL}`, rootURLIndex === 0); // By convention, Ember.js routes using HashLocation are required to start // with `#/`. Anything else should NOT be considered a route and should diff --git a/packages/ember-routing/lib/location/hash_location.js b/packages/ember-routing/lib/location/hash_location.js index e8586702da6..88f63d6b146 100644 --- a/packages/ember-routing/lib/location/hash_location.js +++ b/packages/ember-routing/lib/location/hash_location.js @@ -166,5 +166,5 @@ export default EmberObject.extend({ if (this._hashchangeHandler) { window.removeEventListener('hashchange', this._hashchangeHandler); } - } + }, }); diff --git a/packages/ember-routing/lib/location/history_location.js b/packages/ember-routing/lib/location/history_location.js index 5f8069cd121..6cfab1d9efb 100644 --- a/packages/ember-routing/lib/location/history_location.js +++ b/packages/ember-routing/lib/location/history_location.js @@ -294,5 +294,5 @@ export default EmberObject.extend({ if (this._popstateHandler) { window.removeEventListener('popstate', this._popstateHandler); } - } + }, }); diff --git a/packages/ember-routing/lib/location/none_location.js b/packages/ember-routing/lib/location/none_location.js index fd75cfe2bc8..0027c4f86ca 100644 --- a/packages/ember-routing/lib/location/none_location.js +++ b/packages/ember-routing/lib/location/none_location.js @@ -118,5 +118,5 @@ export default EmberObject.extend({ } return rootURL + url; - } + }, }); diff --git a/packages/ember-routing/lib/location/util.js b/packages/ember-routing/lib/location/util.js index 945f9ebbc86..e74c4ac5cfd 100644 --- a/packages/ember-routing/lib/location/util.js +++ b/packages/ember-routing/lib/location/util.js @@ -72,9 +72,7 @@ export function getOrigin(location) { @function supportsHashChange */ export function supportsHashChange(documentMode, global) { - return ( - 'onhashchange' in global && (documentMode === undefined || documentMode > 7) - ); + return 'onhashchange' in global && (documentMode === undefined || documentMode > 7); } /* @@ -94,8 +92,7 @@ export function supportsHistory(userAgent, history) { // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies // itself as 'Mobile Safari' as well, nor Windows Phone. if ( - (userAgent.indexOf('Android 2.') !== -1 || - userAgent.indexOf('Android 4.0') !== -1) && + (userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 4.0') !== -1) && userAgent.indexOf('Mobile Safari') !== -1 && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Windows Phone') === -1 diff --git a/packages/ember-routing/lib/services/router.js b/packages/ember-routing/lib/services/router.js index c7332f19e11..ec1eadfb7ba 100644 --- a/packages/ember-routing/lib/services/router.js +++ b/packages/ember-routing/lib/services/router.js @@ -141,12 +141,7 @@ const RouterService = Service.extend({ let { routeName, models, queryParams } = extractRouteArgs(args); - let transition = this._router._doTransition( - routeName, - models, - queryParams, - true - ); + let transition = this._router._doTransition(routeName, models, queryParams, true); transition._keepDefaultQueryParamValues = true; return transition; @@ -223,7 +218,7 @@ const RouterService = Service.extend({ } return true; - } + }, }); export default RouterService; diff --git a/packages/ember-routing/lib/services/routing.js b/packages/ember-routing/lib/services/routing.js index 7ef90b10cc0..a9072a8f43c 100644 --- a/packages/ember-routing/lib/services/routing.js +++ b/packages/ember-routing/lib/services/routing.js @@ -58,25 +58,16 @@ export default Service.extend({ } return router.generate(routeName, ...models, { - queryParams: visibleQueryParams + queryParams: visibleQueryParams, }); }, - isActiveForRoute( - contexts, - queryParams, - routeName, - routerState, - isCurrentWhenSpecified - ) { + isActiveForRoute(contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { let router = get(this, 'router'); let handlers = router._routerMicrolib.recognizer.handlersFor(routeName); let leafName = handlers[handlers.length - 1].handler; - let maximumContexts = numberOfContextsAcceptedByHandler( - routeName, - handlers - ); + let maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); // NOTE: any ugliness in the calculation of activeness is largely // due to the fact that we support automatic normalizing of @@ -92,13 +83,8 @@ export default Service.extend({ routeName = leafName; } - return routerState.isActiveIntent( - routeName, - contexts, - queryParams, - !isCurrentWhenSpecified - ); - } + return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified); + }, }); function numberOfContextsAcceptedByHandler(handler, handlerInfos) { diff --git a/packages/ember-routing/lib/system/controller_for.js b/packages/ember-routing/lib/system/controller_for.js index 42575d46121..2880e5851ac 100644 --- a/packages/ember-routing/lib/system/controller_for.js +++ b/packages/ember-routing/lib/system/controller_for.js @@ -9,10 +9,6 @@ @method controllerFor @private */ -export default function controllerFor( - container, - controllerName, - lookupOptions -) { +export default function controllerFor(container, controllerName, lookupOptions) { return container.lookup(`controller:${controllerName}`, lookupOptions); } diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js index 583db4835ca..91513146a85 100644 --- a/packages/ember-routing/lib/system/dsl.js +++ b/packages/ember-routing/lib/system/dsl.js @@ -32,11 +32,11 @@ class DSL { if (this.enableLoadingSubstates) { createRoute(this, `${name}_loading`, { - resetNamespace: options.resetNamespace + resetNamespace: options.resetNamespace, }); createRoute(this, `${name}_error`, { resetNamespace: options.resetNamespace, - path: dummyErrorRoute + path: dummyErrorRoute, }); } @@ -59,9 +59,7 @@ class DSL { let parts = name.split('.'); if (this.options.engineInfo) { - let localFullName = name.slice( - this.options.engineInfo.fullName.length + 1 - ); + let localFullName = name.slice(this.options.engineInfo.fullName.length + 1); let routeInfo = assign({ localFullName }, this.options.engineInfo); if (serialize) { @@ -110,7 +108,7 @@ class DSL { name: _name, instanceId: uuid++, mountPoint: fullName, - fullName + fullName, }; let path = options.path; @@ -154,7 +152,7 @@ class DSL { let localFullName = `application_loading`; let routeInfo = assign({ localFullName }, engineInfo); createRoute(this, substateName, { - resetNamespace: options.resetNamespace + resetNamespace: options.resetNamespace, }); this.options.addRouteForEngine(substateName, routeInfo); @@ -163,7 +161,7 @@ class DSL { routeInfo = assign({ localFullName }, engineInfo); createRoute(this, substateName, { resetNamespace: options.resetNamespace, - path: dummyErrorRoute + path: dummyErrorRoute, }); this.options.addRouteForEngine(substateName, routeInfo); } diff --git a/packages/ember-routing/lib/system/generate_controller.js b/packages/ember-routing/lib/system/generate_controller.js index 923354afb57..3550a91f155 100644 --- a/packages/ember-routing/lib/system/generate_controller.js +++ b/packages/ember-routing/lib/system/generate_controller.js @@ -19,7 +19,7 @@ export function generateControllerFactory(owner, controllerName) { Factory = Factory.extend({ toString() { return `(generated ${controllerName} controller)`; - } + }, }); let fullName = `controller:${controllerName}`; diff --git a/packages/ember-routing/lib/system/route.js b/packages/ember-routing/lib/system/route.js index d561b4af3da..ce9388f8982 100644 --- a/packages/ember-routing/lib/system/route.js +++ b/packages/ember-routing/lib/system/route.js @@ -1,13 +1,5 @@ import { assign, symbol, getOwner } from 'ember-utils'; -import { - get, - set, - getProperties, - setProperties, - computed, - once, - isEmpty -} from 'ember-metal'; +import { get, set, getProperties, setProperties, computed, once, isEmpty } from 'ember-metal'; import { assert, info, isTesting, deprecate } from 'ember-debug'; import { DEBUG } from 'ember-env-flags'; import { @@ -17,14 +9,14 @@ import { Object as EmberObject, A as emberA, Evented, - ActionHandler + ActionHandler, } from 'ember-runtime'; import generateController from './generate_controller'; import { stashParamNames, normalizeControllerQueryParams, calculateCacheKey, - prefixRouteNameArg + prefixRouteNameArg, } from '../utils'; function K() { @@ -128,8 +120,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { { id: 'ember-routing.route-router', until: '3.5.0', - url: - 'https://emberjs.com/deprecations/v3.x#toc_ember-routing-route-router' + url: 'https://emberjs.com/deprecations/v3.x#toc_ember-routing-route-router', } ); return this._router; @@ -173,8 +164,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { let owner = getOwner(this); let controller = owner.lookup(`controller:${controllerName}`); let queryParameterConfiguraton = get(this, 'queryParams'); - let hasRouterDefinedQueryParams = - Object.keys(queryParameterConfiguraton).length > 0; + let hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0; if (controller) { // the developer has authored a controller class in their application for @@ -182,8 +172,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { // merge in the query params for the route. As a mergedProperty, // Route#queryParams is always at least `{}` - let controllerDefinedQueryParameterConfiguration = - get(controller, 'queryParams') || {}; + let controllerDefinedQueryParameterConfiguration = get(controller, 'queryParams') || {}; let normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams( controllerDefinedQueryParameterConfiguration ); @@ -231,11 +220,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { let type = desc.type || typeOf(defaultValue); - let defaultValueSerialized = this.serializeQueryParam( - defaultValue, - urlKey, - type - ); + let defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); let scopedPropertyName = `${controllerName}:${propName}`; let qp = { undecoratedDefaultValue: get(controller, propName), @@ -251,7 +236,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { route: this, parts, // provided later when stashNames is called if 'model' scope values: null, // provided later when setup is called. no idea why. - scope + scope, }; map[propName] = map[urlKey] = map[scopedPropertyName] = qp; @@ -291,8 +276,8 @@ let Route = EmberObject.extend(ActionHandler, Evented, { let qp = map[prop]; this._qpChanged(prop, value, qp); return this._updatingQPChanged(qp); - } - } + }, + }, }; }), @@ -412,9 +397,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { } let transition = this._router._routerMicrolib.activeTransition; - let state = transition - ? transition.state - : this._router._routerMicrolib.state; + let state = transition ? transition.state : this._router._routerMicrolib.state; let fullName = route.fullRouteName; let params = assign({}, state.params[fullName]); @@ -481,11 +464,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { @property _optionsForQueryParam */ _optionsForQueryParam(qp) { - return ( - get(this, `queryParams.${qp.urlKey}`) || - get(this, `queryParams.${qp.prop}`) || - {} - ); + return get(this, `queryParams.${qp.urlKey}`) || get(this, `queryParams.${qp.prop}`) || {}; }, /** @@ -930,16 +909,12 @@ let Route = EmberObject.extend(ActionHandler, Evented, { // Stash current serialized value of controller. qp.serializedValue = svalue; - let thisQueryParamHasDefaultValue = - qp.serializedDefaultValue === svalue; - if ( - !thisQueryParamHasDefaultValue || - transition._keepDefaultQueryParamValues - ) { + let thisQueryParamHasDefaultValue = qp.serializedDefaultValue === svalue; + if (!thisQueryParamHasDefaultValue || transition._keepDefaultQueryParamValues) { finalParams.push({ value: svalue, visible: true, - key: presentKey || qp.urlKey + key: presentKey || qp.urlKey, }); } } @@ -955,7 +930,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { }); router._qpUpdates = null; - } + }, }, /** @@ -1194,9 +1169,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { @public */ intermediateTransitionTo() { - this._router.intermediateTransitionTo( - ...prefixRouteNameArg(this, arguments) - ); + this._router.intermediateTransitionTo(...prefixRouteNameArg(this, arguments)); }, /** @@ -1321,9 +1294,9 @@ let Route = EmberObject.extend(ActionHandler, Evented, { */ send(...args) { assert( - `Attempted to call .send() with the action '${ - args[0] - }' on the destroyed route '${this.routeName}'.`, + `Attempted to call .send() with the action '${args[0]}' on the destroyed route '${ + this.routeName + }'.`, !this.isDestroying && !this.isDestroyed ); if ((this._router && this._router._routerMicrolib) || !isTesting()) { @@ -1381,11 +1354,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { let aQp = queryParams.map[prop]; aQp.values = params; - let cacheKey = calculateCacheKey( - aQp.route.fullRouteName, - aQp.parts, - aQp.values - ); + let cacheKey = calculateCacheKey(aQp.route.fullRouteName, aQp.parts, aQp.values); let value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); set(controller, prop, value); }); @@ -1413,11 +1382,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { // Update model-dep cache let cache = this._bucketCache; - let cacheKey = calculateCacheKey( - qp.route.fullRouteName, - qp.parts, - qp.values - ); + let cacheKey = calculateCacheKey(qp.route.fullRouteName, qp.parts, qp.values); cache.stash(cacheKey, prop, value); }, @@ -1633,8 +1598,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { if (transition.resolveIndex < 1) { return; } - return transition.state.handlerInfos[transition.resolveIndex - 1] - .context; + return transition.state.handlerInfos[transition.resolveIndex - 1].context; } } @@ -1707,7 +1671,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { ); return modelClass.find(value); - } + }, }; }), @@ -1952,9 +1916,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { modelFor(_name) { let name; let owner = getOwner(this); - let transition = this._router - ? this._router._routerMicrolib.activeTransition - : null; + let transition = this._router ? this._router._routerMicrolib.activeTransition : null; // Only change the route name when there is an active transition. // Otherwise, use the passed in route name. @@ -2152,20 +2114,12 @@ let Route = EmberObject.extend(ActionHandler, Evented, { name = this.templateName || this.routeName; options = _name; } else { - assert( - 'The name in the given arguments is undefined or empty string', - !isEmpty(_name) - ); + assert('The name in the given arguments is undefined or empty string', !isEmpty(_name)); name = _name; } } - let renderOptions = buildRenderOptions( - this, - isDefaultRender, - name, - options - ); + let renderOptions = buildRenderOptions(this, isDefaultRender, name, options); this.connections.push(renderOptions); once(this._router, '_setOutlets'); }, @@ -2235,9 +2189,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { outletName = options; } else { outletName = options.outlet; - parentView = options.parentView - ? options.parentView.replace(/\//g, '.') - : undefined; + parentView = options.parentView ? options.parentView.replace(/\//g, '.') : undefined; assert( 'You passed undefined as the outlet name.', @@ -2278,7 +2230,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, { outlet: connection.outlet, name: connection.name, controller: undefined, - template: undefined + template: undefined, }; once(this._router, '_setOutlets'); } @@ -2299,19 +2251,15 @@ let Route = EmberObject.extend(ActionHandler, Evented, { this.connections = []; once(this._router, '_setOutlets'); } - } + }, }); Route.reopenClass({ - isRouteFactory: true + isRouteFactory: true, }); function parentRoute(route) { - let handlerInfo = handlerInfoFor( - route, - route._router._routerMicrolib.state.handlerInfos, - -1 - ); + let handlerInfo = handlerInfoFor(route, route._router._routerMicrolib.state.handlerInfos, -1); return handlerInfo && handlerInfo.handler; } @@ -2332,8 +2280,7 @@ function handlerInfoFor(route, handlerInfos, offset = 0) { function buildRenderOptions(route, isDefaultRender, _name, options) { assert( 'You passed undefined as the outlet name.', - isDefaultRender || - !(options && 'outlet' in options && options.outlet === undefined) + isDefaultRender || !(options && 'outlet' in options && options.outlet === undefined) ); let owner = getOwner(route); @@ -2358,10 +2305,7 @@ function buildRenderOptions(route, isDefaultRender, _name, options) { if (isDefaultRender) { controller = route.controllerName || owner.lookup(`controller:${name}`); } else { - controller = - owner.lookup(`controller:${name}`) || - route.controllerName || - route.routeName; + controller = owner.lookup(`controller:${name}`) || route.controllerName || route.routeName; } } @@ -2395,14 +2339,14 @@ function buildRenderOptions(route, isDefaultRender, _name, options) { outlet, name, controller, - template: template || route._topLevelViewTemplate + template: template || route._topLevelViewTemplate, }; if (DEBUG) { let LOG_VIEW_LOOKUPS = get(route._router, 'namespace.LOG_VIEW_LOOKUPS'); if (LOG_VIEW_LOOKUPS && !template) { info(`Could not find "${name}" template. Nothing will be rendered`, { - fullName: `template:${name}` + fullName: `template:${name}`, }); } } @@ -2468,7 +2412,7 @@ function mergeEachQueryParams(controllerQP, routeQP) { defaultValue: true, type: true, scope: true, - as: true + as: true, }; // first loop over all controller qps, merging them with any matching route qps @@ -2479,11 +2423,7 @@ function mergeEachQueryParams(controllerQP, routeQP) { } let newControllerParameterConfiguration = {}; - assign( - newControllerParameterConfiguration, - controllerQP[cqpName], - routeQP[cqpName] - ); + assign(newControllerParameterConfiguration, controllerQP[cqpName], routeQP[cqpName]); qps[cqpName] = newControllerParameterConfiguration; @@ -2494,19 +2434,12 @@ function mergeEachQueryParams(controllerQP, routeQP) { // loop over all route qps, skipping those that were merged in the first pass // because they also appear in controller qps for (let rqpName in routeQP) { - if ( - !routeQP.hasOwnProperty(rqpName) || - keysAlreadyMergedOrSkippable[rqpName] - ) { + if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { continue; } let newRouteParameterConfiguration = {}; - assign( - newRouteParameterConfiguration, - routeQP[rqpName], - controllerQP[rqpName] - ); + assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); qps[rqpName] = newRouteParameterConfiguration; } diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index 19291c99f43..e73cbafea0a 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -8,24 +8,14 @@ import { once, scheduleOnce, schedule, - cancel + cancel, } from 'ember-metal'; import { Error as EmberError, deprecate, assert, info } from 'ember-debug'; -import { - Object as EmberObject, - Evented, - typeOf, - A as emberA -} from 'ember-runtime'; +import { Object as EmberObject, Evented, typeOf, A as emberA } from 'ember-runtime'; import { defaultSerialize, hasDefaultSerialize } from './route'; import EmberRouterDSL from './dsl'; import EmberLocation from '../location/api'; -import { - resemblesURL, - getActiveTargetName, - calculateCacheKey, - extractRouteArgs -} from '../utils'; +import { resemblesURL, getActiveTargetName, calculateCacheKey, extractRouteArgs } from '../utils'; import RouterState from './router_state'; import { DEBUG } from 'ember-env-flags'; @@ -168,10 +158,7 @@ const EmberRouter = EmberObject.extend(Evented, { return false; } - let resolver = get( - owner, - 'application.__registry__.resolver.moduleBasedResolver' - ); + let resolver = get(owner, 'application.__registry__.resolver.moduleBasedResolver'); return !!resolver; }, @@ -293,11 +280,7 @@ const EmberRouter = EmberObject.extend(Evented, { let connections = route.connections; let ownState; for (let j = 0; j < connections.length; j++) { - let appended = appendLiveRoute( - liveRoutes, - defaultParentState, - connections[j] - ); + let appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); liveRoutes = appended.liveRoutes; if ( appended.ownState.render.name === route.routeName || @@ -416,9 +399,7 @@ const EmberRouter = EmberObject.extend(Evented, { let infos = this._routerMicrolib.currentHandlerInfos; if (get(this, 'namespace').LOG_TRANSITIONS) { // eslint-disable-next-line no-console - console.log( - `Intermediate-transitioned into '${EmberRouter._routePath(infos)}'` - ); + console.log(`Intermediate-transitioned into '${EmberRouter._routePath(infos)}'`); } } }, @@ -560,7 +541,7 @@ const EmberRouter = EmberObject.extend(Evented, { } else { // Allow for deprecated registration of custom location API's let options = { - implementation: location + implementation: location, }; location = set(this, 'location', EmberLocation.create(options)); @@ -628,9 +609,7 @@ const EmberRouter = EmberObject.extend(Evented, { handler._setRouteName(routeName); if (engineInfo && !hasDefaultSerialize(handler)) { - throw new Error( - 'Defining a custom serialize method on an Engine route is not supported.' - ); + throw new Error('Defining a custom serialize method on an Engine route is not supported.'); } return handler; @@ -701,11 +680,7 @@ const EmberRouter = EmberObject.extend(Evented, { forEachQueryParam(this, handlerInfos, queryParams, (key, value, qp) => { if (qp) { delete queryParams[key]; - queryParams[qp.urlKey] = qp.route.serializeQueryParam( - value, - qp.urlKey, - qp.type - ); + queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); } else if (value === undefined) { return; // We don't serialize undefined values } else { @@ -747,11 +722,7 @@ const EmberRouter = EmberObject.extend(Evented, { // because all values will be treated as strings if (qp) { delete queryParams[key]; - queryParams[qp.prop] = qp.route.deserializeQueryParam( - value, - qp.urlKey, - qp.type - ); + queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); } }); }, @@ -797,14 +768,8 @@ const EmberRouter = EmberObject.extend(Evented, { } }, - _doTransition( - _targetRouteName, - models, - _queryParams, - _keepDefaultQueryParamValues - ) { - let targetRouteName = - _targetRouteName || getActiveTargetName(this._routerMicrolib); + _doTransition(_targetRouteName, models, _queryParams, _keepDefaultQueryParamValues) { + let targetRouteName = _targetRouteName || getActiveTargetName(this._routerMicrolib); assert( `The route ${targetRouteName} was not found`, targetRouteName && this._routerMicrolib.hasRoute(targetRouteName) @@ -812,38 +777,19 @@ const EmberRouter = EmberObject.extend(Evented, { let queryParams = {}; - this._processActiveTransitionQueryParams( - targetRouteName, - models, - queryParams, - _queryParams - ); + this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); assign(queryParams, _queryParams); - this._prepareQueryParams( - targetRouteName, - models, - queryParams, - _keepDefaultQueryParamValues - ); + this._prepareQueryParams(targetRouteName, models, queryParams, _keepDefaultQueryParamValues); - let transition = this._routerMicrolib.transitionTo( - targetRouteName, - ...models, - { queryParams } - ); + let transition = this._routerMicrolib.transitionTo(targetRouteName, ...models, { queryParams }); didBeginTransition(transition, this); return transition; }, - _processActiveTransitionQueryParams( - targetRouteName, - models, - queryParams, - _queryParams - ) { + _processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams) { // merge in any queryParams from the active transition which could include // queryParams from the url on initial load. if (!this._routerMicrolib.activeTransition) { @@ -879,12 +825,7 @@ const EmberRouter = EmberObject.extend(Evented, { @param {boolean} keepDefaultQueryParamValues @return {Void} */ - _prepareQueryParams( - targetRouteName, - models, - queryParams, - _fromRouterService - ) { + _prepareQueryParams(targetRouteName, models, queryParams, _fromRouterService) { let state = calculatePostTransitionState(this, targetRouteName, models); this._hydrateUnsuppliedQueryParams(state, queryParams, _fromRouterService); this._serializeQueryParams(state.handlerInfos, queryParams); @@ -1067,16 +1008,8 @@ const EmberRouter = EmberObject.extend(Evented, { delete queryParams[presentProp]; } } else { - let cacheKey = calculateCacheKey( - qp.route.fullRouteName, - qp.parts, - state.params - ); - queryParams[qp.scopedPropertyName] = appCache.lookup( - cacheKey, - qp.prop, - qp.defaultValue - ); + let cacheKey = calculateCacheKey(qp.route.fullRouteName, qp.parts, state.params); + queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); } } } @@ -1152,7 +1085,7 @@ const EmberRouter = EmberObject.extend(Evented, { engineInstance = owner.buildChildEngineInstance(name, { routable: true, - mountPoint + mountPoint, }); engineInstance.boot(); @@ -1161,7 +1094,7 @@ const EmberRouter = EmberObject.extend(Evented, { } return engineInstance; - } + }, }); /* @@ -1269,17 +1202,13 @@ let defaultActionHandlers = { // Don't bubble above pivot route. return transition.pivotHandler !== route; }); - } + }, }; function logError(_error, initialMessage) { let errorArgs = []; let error; - if ( - _error && - typeof _error === 'object' && - typeof _error.errorThrown === 'object' - ) { + if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { error = _error.errorThrown; } else { error = _error; @@ -1321,9 +1250,7 @@ function findRouteSubstateName(route, state) { let substateName = `${routeName}_${state}`; let substateNameFull = `${fullRouteName}_${state}`; - return routeHasBeenDefined(owner, router, substateName, substateNameFull) - ? substateNameFull - : ''; + return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; } /** @@ -1341,12 +1268,9 @@ function findRouteStateName(route, state) { let { routeName, fullRouteName, _router: router } = route; let stateName = routeName === 'application' ? state : `${routeName}.${state}`; - let stateNameFull = - fullRouteName === 'application' ? state : `${fullRouteName}.${state}`; + let stateNameFull = fullRouteName === 'application' ? state : `${fullRouteName}.${state}`; - return routeHasBeenDefined(owner, router, stateName, stateNameFull) - ? stateNameFull - : ''; + return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; } /** @@ -1363,8 +1287,7 @@ function findRouteStateName(route, state) { function routeHasBeenDefined(owner, router, localName, fullName) { let routerHasRoute = router.hasRoute(fullName); let ownerHasRoute = - owner.hasRegistration(`template:${localName}`) || - owner.hasRegistration(`route:${localName}`); + owner.hasRegistration(`template:${localName}`) || owner.hasRegistration(`route:${localName}`); return routerHasRoute && ownerHasRoute; } @@ -1552,15 +1475,11 @@ EmberRouter.reopenClass({ } return path.join('.'); - } + }, }); function didBeginTransition(transition, router) { - let routerState = new RouterState( - router, - router._routerMicrolib, - transition.state - ); + let routerState = new RouterState(router, router._routerMicrolib, transition.state); if (!router.currentState) { router.set('currentState', routerState); @@ -1612,7 +1531,7 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { let myState = { render: renderOptions, outlets: Object.create(null), - wasUsed: false + wasUsed: false, }; if (renderOptions.into) { target = findLiveRoute(liveRoutes, renderOptions.into); @@ -1630,7 +1549,7 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { id: 'ember-routing.top-level-render-helper', until: '3.0.0', url: - 'https://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' + 'https://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet', } ); @@ -1647,7 +1566,7 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { } return { liveRoutes, - ownState: myState + ownState: myState, }; } @@ -1655,9 +1574,9 @@ function appendOrphan(liveRoutes, into, myState) { if (!liveRoutes.outlets.__ember_orphans__) { liveRoutes.outlets.__ember_orphans__ = { render: { - name: '__ember_orphans__' + name: '__ember_orphans__', }, - outlets: Object.create(null) + outlets: Object.create(null), }; } liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; @@ -1685,9 +1604,9 @@ function representEmptyRoute(liveRoutes, defaultParentState, route) { defaultParentState.outlets.main = { render: { name: route.routeName, - outlet: 'main' + outlet: 'main', }, - outlets: {} + outlets: {}, }; return defaultParentState; } diff --git a/packages/ember-routing/lib/system/router_state.js b/packages/ember-routing/lib/system/router_state.js index 62a10984ddf..3864f9980cd 100644 --- a/packages/ember-routing/lib/system/router_state.js +++ b/packages/ember-routing/lib/system/router_state.js @@ -17,11 +17,7 @@ export default class RouterState { if (queryParamsMustMatch && Object.keys(queryParams).length > 0) { let visibleQueryParams = assign({}, queryParams); - this.emberRouter._prepareQueryParams( - routeName, - models, - visibleQueryParams - ); + this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); return shallowEqual(visibleQueryParams, state.queryParams); } diff --git a/packages/ember-routing/lib/utils.js b/packages/ember-routing/lib/utils.js index 4ccde67e208..2dfad167235 100644 --- a/packages/ember-routing/lib/utils.js +++ b/packages/ember-routing/lib/utils.js @@ -9,10 +9,7 @@ export function extractRouteArgs(args) { let possibleQueryParams = args[args.length - 1]; let queryParams; - if ( - possibleQueryParams && - possibleQueryParams.hasOwnProperty('queryParams') - ) { + if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { queryParams = args.pop().queryParams; } else { queryParams = {}; @@ -40,9 +37,7 @@ export function stashParamNames(router, handlerInfos) { // on whether a URL transition or named transition is happening. // Hopefully we can remove this in the future. let targetRouteName = handlerInfos[handlerInfos.length - 1].name; - let recogHandlers = router._routerMicrolib.recognizer.handlersFor( - targetRouteName - ); + let recogHandlers = router._routerMicrolib.recognizer.handlersFor(targetRouteName); let dynamicParent = null; for (let i = 0; i < handlerInfos.length; ++i) { @@ -98,9 +93,7 @@ export function calculateCacheKey(prefix, parts = [], values) { if (values) { if (cacheValuePrefix && cacheValuePrefix in values) { let partRemovedPrefix = - part.indexOf(cacheValuePrefix) === 0 - ? part.substr(cacheValuePrefix.length + 1) - : part; + part.indexOf(cacheValuePrefix) === 0 ? part.substr(cacheValuePrefix.length + 1) : part; value = get(values[cacheValuePrefix], partRemovedPrefix); } else { value = get(values, part); diff --git a/packages/ember-routing/tests/ext/controller_test.js b/packages/ember-routing/tests/ext/controller_test.js index 47223f746bb..5980905e72e 100644 --- a/packages/ember-routing/tests/ext/controller_test.js +++ b/packages/ember-routing/tests/ext/controller_test.js @@ -9,14 +9,14 @@ moduleFor( let router = { transitionTo(route) { return route; - } + }, }; let engineInstance = buildOwner({ ownerOptions: { routable: true, - mountPoint: 'foo.bar' - } + mountPoint: 'foo.bar', + }, }); let controller = Controller.create({ target: router }); @@ -49,14 +49,14 @@ moduleFor( let router = { replaceWith(route) { return route; - } + }, }; let engineInstance = buildOwner({ ownerOptions: { routable: true, - mountPoint: 'foo.bar' - } + mountPoint: 'foo.bar', + }, }); let controller = Controller.create({ target: router }); @@ -72,10 +72,7 @@ moduleFor( 'foo.bar.posts', 'properly prefixes child routes' ); - assert.throws( - () => controller.replaceRoute('/posts'), - 'throws when trying to use a url' - ); + assert.throws(() => controller.replaceRoute('/posts'), 'throws when trying to use a url'); let queryParams = {}; assert.strictEqual( diff --git a/packages/ember-routing/tests/location/auto_location_test.js b/packages/ember-routing/tests/location/auto_location_test.js index e512af54783..ee3f1cc310e 100644 --- a/packages/ember-routing/tests/location/auto_location_test.js +++ b/packages/ember-routing/tests/location/auto_location_test.js @@ -16,11 +16,8 @@ function mockBrowserLocation(overrides, assert) { hash: '', search: '', replace() { - assert.ok( - false, - 'location.replace should not be called during testing' - ); - } + assert.ok(false, 'location.replace should not be called during testing'); + }, }, overrides ); @@ -30,17 +27,11 @@ function mockBrowserHistory(overrides, assert) { return assign( { pushState() { - assert.ok( - false, - 'history.pushState should not be called during testing' - ); + assert.ok(false, 'history.pushState should not be called during testing'); }, replaceState() { - assert.ok( - false, - 'history.replaceState should not be called during testing' - ); - } + assert.ok(false, 'history.replaceState should not be called during testing'); + }, }, overrides ); @@ -57,7 +48,7 @@ function createLocation(location, history) { [OWNER]: owner, location: location, history: history, - global: {} + global: {}, }); return autolocation; @@ -78,16 +69,10 @@ moduleFor( let location = AutoLocation.create(); assert.ok(location.global, 'has a global defined'); - assert.strictEqual( - location.global, - environment.window, - 'has the environments window global' - ); + assert.strictEqual(location.global, environment.window, 'has the environments window global'); } - ["@test AutoLocation should return concrete implementation's value for `getURL`"]( - assert - ) { + ["@test AutoLocation should return concrete implementation's value for `getURL`"](assert) { let browserLocation = mockBrowserLocation({}, assert); let browserHistory = mockBrowserHistory({}, assert); @@ -112,9 +97,7 @@ moduleFor( location = createLocation(browserLocation, browserHistory); location.detect(); - assert.ok( - get(location, 'concreteImplementation') instanceof HistoryLocation - ); + assert.ok(get(location, 'concreteImplementation') instanceof HistoryLocation); } ['@test AutoLocation should use a HashLocation instance when pushStates are not supported, but hashchange events are and the URL is already in the HashLocation format']( @@ -122,20 +105,18 @@ moduleFor( ) { let browserLocation = mockBrowserLocation( { - hash: '#/testd' + hash: '#/testd', }, assert ); location = createLocation(browserLocation); location.global = { - onhashchange() {} + onhashchange() {}, }; location.detect(); - assert.ok( - get(location, 'concreteImplementation') instanceof HashLocation - ); + assert.ok(get(location, 'concreteImplementation') instanceof HashLocation); } ['@test AutoLocation should use a NoneLocation instance when neither history nor hashchange are supported.']( @@ -144,9 +125,7 @@ moduleFor( location = createLocation(mockBrowserLocation({}, assert)); location.detect(); - assert.ok( - get(location, 'concreteImplementation') instanceof NoneLocation - ); + assert.ok(get(location, 'concreteImplementation') instanceof NoneLocation); } ["@test AutoLocation should use an index path (i.e. '/') without any location.hash as OK for HashLocation"]( @@ -160,14 +139,14 @@ moduleFor( search: '', replace() { assert.ok(false, 'location.replace should not be called'); - } + }, }, assert ); location = createLocation(browserLocation); location.global = { - onhashchange() {} + onhashchange() {}, }; location.detect(); @@ -198,14 +177,14 @@ moduleFor( 'http://test.com/#/test', 'location.replace should be called with normalized HashLocation path' ); - } + }, }, assert ); let location = createLocation(browserLocation); location.global = { - onhashchange() {} + onhashchange() {}, }; location.detect(); @@ -233,7 +212,7 @@ moduleFor( pathname: '/', protocol: 'http:', port: '', - search: '' + search: '', }, assert ); @@ -246,7 +225,7 @@ moduleFor( '/test', 'history.replaceState should be called with normalized HistoryLocation url' ); - } + }, }, assert ); @@ -257,9 +236,7 @@ moduleFor( assert.ok(get(location, 'concreteImplementation'), HistoryLocation); } - ['@test AutoLocation requires any rootURL given to end in a trailing forward slash']( - assert - ) { + ['@test AutoLocation requires any rootURL given to end in a trailing forward slash'](assert) { let browserLocation = mockBrowserLocation({}, assert); let expectedMsg = /rootURL must end with a trailing forward slash e.g. "\/app\/"/; @@ -282,12 +259,10 @@ moduleFor( }, expectedMsg); } - ['@test AutoLocation provides its rootURL to the concreteImplementation']( - assert - ) { + ['@test AutoLocation provides its rootURL to the concreteImplementation'](assert) { let browserLocation = mockBrowserLocation( { - pathname: '/some/subdir/derp' + pathname: '/some/subdir/derp', }, assert ); @@ -302,15 +277,13 @@ moduleFor( assert.equal(location.rootURL, concreteLocation.rootURL); } - ['@test getHistoryPath() should return a normalized, HistoryLocation-supported path']( - assert - ) { + ['@test getHistoryPath() should return a normalized, HistoryLocation-supported path'](assert) { let browserLocation = mockBrowserLocation( { href: 'http://test.com/app/about?foo=bar#foo', pathname: '/app/about', search: '?foo=bar', - hash: '#foo' + hash: '#foo', }, assert ); @@ -326,7 +299,7 @@ moduleFor( href: 'http://test.com/app/#/about?foo=bar#foo', pathname: '/app/', search: '', - hash: '#/about?foo=bar#foo' + hash: '#/about?foo=bar#foo', }, assert ); @@ -341,7 +314,7 @@ moduleFor( href: 'http://test.com/app/#about?foo=bar#foo', pathname: '/app/', search: '', - hash: '#about?foo=bar#foo' + hash: '#about?foo=bar#foo', }, assert ); @@ -352,15 +325,13 @@ moduleFor( ); } - ['@test getHashPath() should return a normalized, HashLocation-supported path']( - assert - ) { + ['@test getHashPath() should return a normalized, HashLocation-supported path'](assert) { let browserLocation = mockBrowserLocation( { href: 'http://test.com/app/#/about?foo=bar#foo', pathname: '/app/', search: '', - hash: '#/about?foo=bar#foo' + hash: '#/about?foo=bar#foo', }, assert ); @@ -375,7 +346,7 @@ moduleFor( href: 'http://test.com/app/about?foo=bar#foo', pathname: '/app/about', search: '?foo=bar', - hash: '#foo' + hash: '#foo', }, assert ); @@ -390,7 +361,7 @@ moduleFor( href: 'http://test.com/app/#about?foo=bar#foo', pathname: '/app/', search: '', - hash: '#about?foo=bar#foo' + hash: '#about?foo=bar#foo', }, assert ); diff --git a/packages/ember-routing/tests/location/hash_location_test.js b/packages/ember-routing/tests/location/hash_location_test.js index e43d7e4a75d..1d62f6e2a68 100644 --- a/packages/ember-routing/tests/location/hash_location_test.js +++ b/packages/ember-routing/tests/location/hash_location_test.js @@ -12,12 +12,9 @@ function createLocation(options, assert) { hash: '', search: '', replace() { - assert.ok( - false, - 'location.replace should not be called during testing' - ); - } - } + assert.ok(false, 'location.replace should not be called during testing'); + }, + }, }); if (!options) { @@ -43,7 +40,7 @@ function mockBrowserLocation(path) { pathname: pathname, port: tmp.port || '', protocol: protocol, - search: tmp.search + search: tmp.search, }; } @@ -67,7 +64,7 @@ moduleFor( ['@test HashLocation.getURL() returns the current url'](assert) { createLocation( { - _location: mockBrowserLocation('/#/foo/bar') + _location: mockBrowserLocation('/#/foo/bar'), }, assert ); @@ -78,7 +75,7 @@ moduleFor( ['@test HashLocation.getURL() includes extra hashes'](assert) { createLocation( { - _location: mockBrowserLocation('/#/foo#bar#car') + _location: mockBrowserLocation('/#/foo#bar#car'), }, assert ); @@ -91,7 +88,7 @@ moduleFor( ) { createLocation( { - _location: mockBrowserLocation('/#foo#bar') + _location: mockBrowserLocation('/#foo#bar'), }, assert ); @@ -104,7 +101,7 @@ moduleFor( ) { createLocation( { - _location: mockBrowserLocation('/') + _location: mockBrowserLocation('/'), }, assert ); @@ -121,9 +118,7 @@ moduleFor( assert.equal(get(location, 'lastSetURL'), '/bar'); } - ['@test HashLocation.replaceURL() correctly replaces to the path with a page reload']( - assert - ) { + ['@test HashLocation.replaceURL() correctly replaces to the path with a page reload'](assert) { assert.expect(2); createLocation( @@ -131,8 +126,8 @@ moduleFor( _location: { replace(path) { assert.equal(path, '#/foo'); - } - } + }, + }, }, assert ); @@ -147,7 +142,7 @@ moduleFor( createLocation( { - _location: mockBrowserLocation('/#/foo/bar') + _location: mockBrowserLocation('/#/foo/bar'), }, assert ); @@ -161,17 +156,15 @@ moduleFor( triggerHashchange(); } - ["@test HashLocation.onUpdateURL doesn't execute callback if lastSetURL === path"]( - assert - ) { + ["@test HashLocation.onUpdateURL doesn't execute callback if lastSetURL === path"](assert) { assert.expect(0); createLocation( { _location: { - href: '/#/foo/bar' + href: '/#/foo/bar', }, - lastSetURL: '/foo/bar' + lastSetURL: '/foo/bar', }, assert ); @@ -185,17 +178,13 @@ moduleFor( triggerHashchange(); } - ['@test HashLocation.formatURL() prepends a # to the provided string']( - assert - ) { + ['@test HashLocation.formatURL() prepends a # to the provided string'](assert) { createLocation({}, assert); assert.equal(location.formatURL('/foo#bar'), '#/foo#bar'); } - ['@test HashLocation.willDestroy() cleans up hashchange event listener']( - assert - ) { + ['@test HashLocation.willDestroy() cleans up hashchange event listener'](assert) { assert.expect(1); createLocation({}, assert); diff --git a/packages/ember-routing/tests/location/history_location_test.js b/packages/ember-routing/tests/location/history_location_test.js index 3863e076fea..d236be8c5c1 100644 --- a/packages/ember-routing/tests/location/history_location_test.js +++ b/packages/ember-routing/tests/location/history_location_test.js @@ -28,7 +28,7 @@ function mockBrowserLocation(path) { pathname: pathname, port: tmp.port || '', protocol: protocol, - search: tmp.search + search: tmp.search, }; } @@ -48,11 +48,11 @@ moduleFor( pushState(state) { this.state = state; this._states.unshift(state); - } + }, }; HistoryTestLocation = HistoryLocation.extend({ - history: FakeHistory + history: FakeHistory, }); } @@ -74,7 +74,7 @@ moduleFor( }, initState() { assert.ok(false, 'initState() should not be called automatically'); - } + }, }); createLocation(); @@ -89,7 +89,7 @@ moduleFor( // these two should be equal to be able // to successfully detect webkit initial popstate assert.equal(this._previousURL, this.getURL()); - } + }, }); createLocation(); @@ -111,7 +111,7 @@ moduleFor( this._super(...arguments); assert.equal(this.getURL(), '/foo/bar'); - } + }, }); createLocation(); @@ -127,7 +127,7 @@ moduleFor( set(this, 'location', mockBrowserLocation('/base/foo/bar')); set(this, 'baseURL', '/base/'); - } + }, }); createLocation(); @@ -138,9 +138,7 @@ moduleFor( assert.ok(location._historyState.uuid); } - ['@test setURL continues to set even with a null state (iframes may set this)']( - assert - ) { + ['@test setURL continues to set even with a null state (iframes may set this)'](assert) { createLocation(); location.initState(); @@ -151,9 +149,7 @@ moduleFor( assert.ok(location._historyState.uuid); } - ['@test replaceURL continues to set even with a null state (iframes may set this)']( - assert - ) { + ['@test replaceURL continues to set even with a null state (iframes may set this)'](assert) { createLocation(); location.initState(); @@ -174,7 +170,7 @@ moduleFor( set(this, 'location', mockBrowserLocation('/base/foo/bar')); set(this, 'rootURL', '/app/'); set(this, 'baseURL', '/base/'); - } + }, }); createLocation(); @@ -191,7 +187,7 @@ moduleFor( set(this, 'location', mockBrowserLocation('/foo/bar/baz')); set(this, 'rootURL', '/bar/'); - } + }, }); createLocation(); @@ -207,7 +203,7 @@ moduleFor( this._super(...arguments); set(this, 'location', mockBrowserLocation('/bars/baz')); set(this, 'rootURL', '/bar/'); - } + }, }); createLocation(); @@ -224,7 +220,7 @@ moduleFor( set(this, 'location', mockBrowserLocation('/foo/bar/baz')); set(this, 'baseURL', '/bar/'); - } + }, }); createLocation(); @@ -240,7 +236,7 @@ moduleFor( this._super(...arguments); set(this, 'location', mockBrowserLocation('/bars/baz')); set(this, 'baseURL', '/bar/'); - } + }, }); createLocation(); @@ -253,7 +249,7 @@ moduleFor( init() { this._super(...arguments); set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin')); - } + }, }); createLocation(); @@ -265,12 +261,8 @@ moduleFor( HistoryTestLocation.reopen({ init() { this._super(...arguments); - set( - this, - 'location', - mockBrowserLocation('/foo/bar#pink-power-ranger') - ); - } + set(this, 'location', mockBrowserLocation('/foo/bar#pink-power-ranger')); + }, }); createLocation(); @@ -278,26 +270,17 @@ moduleFor( assert.equal(location.getURL(), '/foo/bar#pink-power-ranger'); } - ['@test HistoryLocation.getURL() includes location.hash and location.search']( - assert - ) { + ['@test HistoryLocation.getURL() includes location.hash and location.search'](assert) { HistoryTestLocation.reopen({ init() { this._super(...arguments); - set( - this, - 'location', - mockBrowserLocation('/foo/bar?time=morphin#pink-power-ranger') - ); - } + set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin#pink-power-ranger')); + }, }); createLocation(); - assert.equal( - location.getURL(), - '/foo/bar?time=morphin#pink-power-ranger' - ); + assert.equal(location.getURL(), '/foo/bar?time=morphin#pink-power-ranger'); } ['@test HistoryLocation.getURL() drops duplicate slashes'](assert) { @@ -307,7 +290,7 @@ moduleFor( let location = mockBrowserLocation('//'); location.pathname = '//'; // mockBrowserLocation does not allow for `//`, so force it set(this, 'location', location); - } + }, }); createLocation(); @@ -318,7 +301,7 @@ moduleFor( ['@test Existing state is preserved on init'](assert) { let existingState = { path: '/route/path', - uuid: 'abcd' + uuid: 'abcd', }; FakeHistory.state = existingState; @@ -327,7 +310,7 @@ moduleFor( init() { this._super(...arguments); set(this, 'location', mockBrowserLocation('/route/path')); - } + }, }); createLocation(); diff --git a/packages/ember-routing/tests/location/none_location_test.js b/packages/ember-routing/tests/location/none_location_test.js index 2dce54b108b..80d37204059 100644 --- a/packages/ember-routing/tests/location/none_location_test.js +++ b/packages/ember-routing/tests/location/none_location_test.js @@ -27,14 +27,12 @@ moduleFor( }); } - ['@test NoneLocation.formatURL() returns the current url always appending rootURL']( - assert - ) { + ['@test NoneLocation.formatURL() returns the current url always appending rootURL'](assert) { NoneTestLocation.reopen({ init() { this._super(...arguments); set(this, 'rootURL', '/en/'); - } + }, }); createLocation(); @@ -42,15 +40,13 @@ moduleFor( assert.equal(location.formatURL('/foo/bar'), '/en/foo/bar'); } - ['@test NoneLocation.getURL() returns the current path minus rootURL']( - assert - ) { + ['@test NoneLocation.getURL() returns the current path minus rootURL'](assert) { NoneTestLocation.reopen({ init() { this._super(...arguments); set(this, 'rootURL', '/foo/'); set(this, 'path', '/foo/bar'); - } + }, }); createLocation(); @@ -66,7 +62,7 @@ moduleFor( this._super(...arguments); set(this, 'rootURL', '/bar/'); set(this, 'path', '/foo/bar/baz'); - } + }, }); createLocation(); @@ -74,15 +70,13 @@ moduleFor( assert.equal(location.getURL(), '/foo/bar/baz'); } - ['@test NoneLocation.getURL() will not remove the rootURL when only a partial match']( - assert - ) { + ['@test NoneLocation.getURL() will not remove the rootURL when only a partial match'](assert) { NoneTestLocation.reopen({ init() { this._super(...arguments); set(this, 'rootURL', '/bar/'); set(this, 'path', '/bars/baz'); - } + }, }); createLocation(); diff --git a/packages/ember-routing/tests/location/util_test.js b/packages/ember-routing/tests/location/util_test.js index 6b118f742ac..a8b15a6244a 100644 --- a/packages/ember-routing/tests/location/util_test.js +++ b/packages/ember-routing/tests/location/util_test.js @@ -1,10 +1,5 @@ import { assign } from 'ember-utils'; -import { - replacePath, - getPath, - getQuery, - getFullPath -} from '../../location/util'; +import { replacePath, getPath, getQuery, getFullPath } from '../../location/util'; import { supportsHistory, supportsHashChange } from '../../location/util'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -16,11 +11,8 @@ function mockBrowserLocation(overrides, assert) { hash: '', search: '', replace() { - assert.ok( - false, - 'location.replace should not be called during testing' - ); - } + assert.ok(false, 'location.replace should not be called during testing'); + }, }, overrides ); @@ -29,9 +21,7 @@ function mockBrowserLocation(overrides, assert) { moduleFor( 'Location Utilities', class extends AbstractTestCase { - ['@test replacePath cannot be used to redirect to a different origin']( - assert - ) { + ['@test replacePath cannot be used to redirect to a different origin'](assert) { assert.expect(1); let expectedURL; @@ -43,7 +33,7 @@ moduleFor( replace(url) { assert.equal(url, expectedURL); - } + }, }; expectedURL = 'http://emberjs.com:1337//google.com'; @@ -54,11 +44,7 @@ moduleFor( assert ) { let location = mockBrowserLocation({ pathname: 'test' }, assert); - assert.equal( - getPath(location), - '/test', - 'When there is no leading slash, one is added.' - ); + assert.equal(getPath(location), '/test', 'When there is no leading slash, one is added.'); location = mockBrowserLocation({ pathname: '/test' }, assert); assert.equal( @@ -73,15 +59,13 @@ moduleFor( assert.equal(getQuery(location), '?foo=bar'); } - ['@test getFullPath() should return full pathname including query and hash']( - assert - ) { + ['@test getFullPath() should return full pathname including query and hash'](assert) { let location = mockBrowserLocation( { href: 'http://test.com/about?foo=bar#foo', pathname: '/about', search: '?foo=bar', - hash: '#foo' + hash: '#foo', }, assert ); @@ -123,11 +107,7 @@ moduleFor( false, "returns false if history.pushState doesn't exist" ); - assert.equal( - supportsHistory('', undefined), - false, - "returns false if history doesn't exist" - ); + assert.equal(supportsHistory('', undefined), false, "returns false if history doesn't exist"); assert.equal( supportsHistory( diff --git a/packages/ember-routing/tests/system/cache_test.js b/packages/ember-routing/tests/system/cache_test.js index 8b39a7e8766..f19fdb589d9 100644 --- a/packages/ember-routing/tests/system/cache_test.js +++ b/packages/ember-routing/tests/system/cache_test.js @@ -25,9 +25,7 @@ moduleFor( assert.strictEqual(this.cache.has('constructor'), true); } - ['@test lookup - returns stashed value if key does exist in bucket']( - assert - ) { + ['@test lookup - returns stashed value if key does exist in bucket'](assert) { let token = {}; let defaultValue = {}; @@ -36,35 +34,21 @@ moduleFor( assert.strictEqual(this.cache.lookup('foo', 'bar', defaultValue), token); } - ['@test lookup - returns default value if key does not exist in bucket']( - assert - ) { + ['@test lookup - returns default value if key does not exist in bucket'](assert) { let token = {}; let defaultValue = {}; this.cache.stash('foo', 'bar', token); - assert.strictEqual( - this.cache.lookup('foo', 'boo', defaultValue), - defaultValue - ); - assert.strictEqual( - this.cache.lookup('foo', 'constructor', defaultValue), - defaultValue - ); + assert.strictEqual(this.cache.lookup('foo', 'boo', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('foo', 'constructor', defaultValue), defaultValue); } ['@test lookup - returns default value if bucket does not exist'](assert) { let defaultValue = {}; - assert.strictEqual( - this.cache.lookup('boo', 'bar', defaultValue), - defaultValue - ); - assert.strictEqual( - this.cache.lookup('constructor', 'bar', defaultValue), - defaultValue - ); + assert.strictEqual(this.cache.lookup('boo', 'bar', defaultValue), defaultValue); + assert.strictEqual(this.cache.lookup('constructor', 'bar', defaultValue), defaultValue); } } ); diff --git a/packages/ember-routing/tests/system/controller_for_test.js b/packages/ember-routing/tests/system/controller_for_test.js index 5bae73045a7..e3d1b349127 100644 --- a/packages/ember-routing/tests/system/controller_for_test.js +++ b/packages/ember-routing/tests/system/controller_for_test.js @@ -51,34 +51,24 @@ moduleFor( }); } - ['@test generateController should return controller:basic if resolved']( - assert - ) { + ['@test generateController should return controller:basic if resolved'](assert) { let BasicController = Controller.extend(); this.add('controller:basic', BasicController); return this.visit('/').then(() => { let controller = generateController(this.applicationInstance, 'home'); - assert.ok( - controller instanceof BasicController, - 'should return controller' - ); + assert.ok(controller instanceof BasicController, 'should return controller'); }); } - ['@test generateController should return controller:basic if registered']( - assert - ) { + ['@test generateController should return controller:basic if registered'](assert) { let BasicController = Controller.extend(); this.application.register('controller:basic', BasicController); return this.visit('/').then(() => { let controller = generateController(this.applicationInstance, 'home'); - assert.ok( - controller instanceof BasicController, - 'should return base class of controller' - ); + assert.ok(controller instanceof BasicController, 'should return base class of controller'); }); } } diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js index 0698981b1eb..a757582f870 100644 --- a/packages/ember-routing/tests/system/dsl_test.js +++ b/packages/ember-routing/tests/system/dsl_test.js @@ -61,9 +61,7 @@ moduleFor( ); } - ['@test should add loading and error routes if _isRouterMapResult is true']( - assert - ) { + ['@test should add loading and error routes if _isRouterMapResult is true'](assert) { Router.map(function() { this.route('blork'); }); @@ -71,28 +69,20 @@ moduleFor( let router = Router.create({ _hasModuleBasedResolver() { return true; - } + }, }); router._initRouterJs(); - assert.ok( - router._routerMicrolib.recognizer.names['blork'], - 'main route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['blork'], 'main route was created'); assert.ok( router._routerMicrolib.recognizer.names['blork_loading'], 'loading route was added' ); - assert.ok( - router._routerMicrolib.recognizer.names['blork_error'], - 'error route was added' - ); + assert.ok(router._routerMicrolib.recognizer.names['blork_error'], 'error route was added'); } - ['@test should not add loading and error routes if _isRouterMapResult is false']( - assert - ) { + ['@test should not add loading and error routes if _isRouterMapResult is false'](assert) { Router.map(function() { this.route('blork'); }); @@ -100,10 +90,7 @@ moduleFor( let router = Router.create(); router._initRouterJs(false); - assert.ok( - router._routerMicrolib.recognizer.names['blork'], - 'main route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['blork'], 'main route was created'); assert.ok( !router._routerMicrolib.recognizer.names['blork_loading'], 'loading route was not added' @@ -127,15 +114,12 @@ moduleFor( let router = Router.create({ _hasModuleBasedResolver() { return true; - } + }, }); router._initRouterJs(); - assert.ok( - router._routerMicrolib.recognizer.names['blork.blorp'], - 'nested route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['blork.blorp'], 'nested route was created'); assert.ok( router._routerMicrolib.recognizer.names['blork.blorp_loading'], 'nested loading route was added' @@ -145,10 +129,7 @@ moduleFor( 'nested error route was added' ); - assert.ok( - router._routerMicrolib.recognizer.names['bleep'], - 'reset route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['bleep'], 'reset route was created'); assert.ok( router._routerMicrolib.recognizer.names['bleep_loading'], 'reset loading route was added' @@ -172,9 +153,7 @@ moduleFor( ); } - ['@test should throw an error when defining a route serializer outside an engine']( - assert - ) { + ['@test should throw an error when defining a route serializer outside an engine'](assert) { Router.map(function() { assert.throws(() => { this.route('posts', { serialize: function() {} }); @@ -210,7 +189,7 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create(); @@ -243,7 +222,7 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create(); @@ -271,7 +250,7 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create(); @@ -287,37 +266,26 @@ moduleFor( ); } - ['@test should add loading and error routes to a mount if _isRouterMapResult is true']( - assert - ) { + ['@test should add loading and error routes to a mount if _isRouterMapResult is true'](assert) { Router.map(function() { this.mount('chat'); }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create({ _hasModuleBasedResolver() { return true; - } + }, }); setOwner(router, engineInstance); router._initRouterJs(); - assert.ok( - router._routerMicrolib.recognizer.names['chat'], - 'main route was created' - ); - assert.ok( - router._routerMicrolib.recognizer.names['chat_loading'], - 'loading route was added' - ); - assert.ok( - router._routerMicrolib.recognizer.names['chat_error'], - 'error route was added' - ); + assert.ok(router._routerMicrolib.recognizer.names['chat'], 'main route was created'); + assert.ok(router._routerMicrolib.recognizer.names['chat_loading'], 'loading route was added'); + assert.ok(router._routerMicrolib.recognizer.names['chat_error'], 'error route was added'); } ['@test should add loading and error routes to a mount alias if _isRouterMapResult is true']( @@ -328,29 +296,23 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create({ _hasModuleBasedResolver() { return true; - } + }, }); setOwner(router, engineInstance); router._initRouterJs(); - assert.ok( - router._routerMicrolib.recognizer.names['shoutbox'], - 'main route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['shoutbox'], 'main route was created'); assert.ok( router._routerMicrolib.recognizer.names['shoutbox_loading'], 'loading route was added' ); - assert.ok( - router._routerMicrolib.recognizer.names['shoutbox_error'], - 'error route was added' - ); + assert.ok(router._routerMicrolib.recognizer.names['shoutbox_error'], 'error route was added'); } ['@test should not add loading and error routes to a mount if _isRouterMapResult is false']( @@ -361,17 +323,14 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create(); setOwner(router, engineInstance); router._initRouterJs(false); - assert.ok( - router._routerMicrolib.recognizer.names['chat'], - 'main route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['chat'], 'main route was created'); assert.ok( !router._routerMicrolib.recognizer.names['chat_loading'], 'loading route was not added' @@ -393,21 +352,18 @@ moduleFor( }); let engineInstance = buildOwner({ - ownerOptions: { routable: true } + ownerOptions: { routable: true }, }); let router = Router.create({ _hasModuleBasedResolver() { return true; - } + }, }); setOwner(router, engineInstance); router._initRouterJs(); - assert.ok( - router._routerMicrolib.recognizer.names['news.chat'], - 'nested route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['news.chat'], 'nested route was created'); assert.ok( router._routerMicrolib.recognizer.names['news.chat_loading'], 'nested loading route was added' @@ -417,10 +373,7 @@ moduleFor( 'nested error route was added' ); - assert.ok( - router._routerMicrolib.recognizer.names['blog'], - 'reset route was created' - ); + assert.ok(router._routerMicrolib.recognizer.names['blog'], 'reset route was created'); assert.ok( router._routerMicrolib.recognizer.names['blog_loading'], 'reset loading route was added' diff --git a/packages/ember-routing/tests/system/route_test.js b/packages/ember-routing/tests/system/route_test.js index 4f7935cb0be..be67233260c 100644 --- a/packages/ember-routing/tests/system/route_test.js +++ b/packages/ember-routing/tests/system/route_test.js @@ -1,10 +1,5 @@ import { setOwner } from 'ember-utils'; -import { - runDestroy, - buildOwner, - moduleFor, - AbstractTestCase -} from 'internal-test-helpers'; +import { runDestroy, buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers'; import { Service, Object as EmberObject, inject } from 'ember-runtime'; import EmberRoute from '../../system/route'; @@ -22,9 +17,7 @@ moduleFor( runDestroy(route); } - ['@test default store utilizes the container to acquire the model factory']( - assert - ) { + ['@test default store utilizes the container to acquire the model factory'](assert) { assert.expect(4); let Post = EmberObject.extend(); @@ -33,7 +26,7 @@ moduleFor( Post.reopenClass({ find() { return post; - } + }, }); let ownerOptions = { @@ -42,20 +35,16 @@ moduleFor( return true; }, factoryFor(fullName) { - assert.equal( - fullName, - 'model:post', - 'correct factory was looked up' - ); + assert.equal(fullName, 'model:post', 'correct factory was looked up'); return { class: Post, create() { return Post.create(); - } + }, }; - } - } + }, + }, }; setOwner(route, buildOwner(ownerOptions)); @@ -63,11 +52,7 @@ moduleFor( route.set('_qp', null); assert.equal(route.model({ post_id: 1 }), post); - assert.equal( - route.findModel('post', 1), - post, - '#findModel returns the correct post' - ); + assert.equal(route.findModel('post', 1), post, '#findModel returns the correct post'); } ["@test 'store' can be injected by data persistence frameworks"](assert) { @@ -77,7 +62,7 @@ moduleFor( let owner = buildOwner(); let post = { - id: 1 + id: 1, }; let Store = EmberObject.extend({ @@ -86,7 +71,7 @@ moduleFor( assert.equal(type, 'post', 'correct type was called'); assert.equal(value, 1, 'correct value was called'); return post; - } + }, }); owner.register('route:index', EmberRoute); @@ -96,16 +81,8 @@ moduleFor( route = owner.lookup('route:index'); - assert.equal( - route.model({ post_id: 1 }), - post, - '#model returns the correct post' - ); - assert.equal( - route.findModel('post', 1), - post, - '#findModel returns the correct post' - ); + assert.equal(route.model({ post_id: 1 }), post, '#model returns the correct post'); + assert.equal(route.findModel('post', 1), post, '#findModel returns the correct post'); } ["@test assert if 'store.find' method is not found"]() { @@ -160,7 +137,7 @@ moduleFor( let foo = { name: 'foo' }; let FooRoute = EmberRoute.extend({ - currentModel: foo + currentModel: foo, }); owner.register('route:foo', FooRoute); @@ -182,8 +159,8 @@ moduleFor( returnsFalse() { assert.ok(true, 'returnsFalse was called'); return false; - } - } + }, + }, }).create(); assert.equal(true, route.send('returnsTrue', 1, 2)); @@ -191,9 +168,7 @@ moduleFor( assert.equal(undefined, route.send('nonexistent', 1, 2, 3)); } - ['@test .send just calls an action if the routers internal router property is absent']( - assert - ) { + ['@test .send just calls an action if the routers internal router property is absent'](assert) { assert.expect(7); let route = EmberRoute.extend({ router: {}, @@ -208,8 +183,8 @@ moduleFor( returnsFalse() { assert.ok(true, 'returnsFalse was called'); return false; - } - } + }, + }, }).create(); assert.equal(true, route.send('returnsTrue', 1, 2)); @@ -240,9 +215,7 @@ moduleFor( runDestroy(route); } - ['@test returns the models properties if params does not include *_id']( - assert - ) { + ['@test returns the models properties if params does not include *_id'](assert) { let model = { id: 2, firstName: 'Ned', lastName: 'Ryerson' }; assert.deepEqual( @@ -255,31 +228,17 @@ moduleFor( ['@test returns model.id if params include *_id'](assert) { let model = { id: 2 }; - assert.deepEqual( - route.serialize(model, ['post_id']), - { post_id: 2 }, - 'serialized correctly' - ); + assert.deepEqual(route.serialize(model, ['post_id']), { post_id: 2 }, 'serialized correctly'); } - ['@test returns checks for existence of model.post_id before trying model.id']( - assert - ) { + ['@test returns checks for existence of model.post_id before trying model.id'](assert) { let model = { post_id: 3 }; - assert.deepEqual( - route.serialize(model, ['post_id']), - { post_id: 3 }, - 'serialized correctly' - ); + assert.deepEqual(route.serialize(model, ['post_id']), { post_id: 3 }, 'serialized correctly'); } ['@test returns undefined if model is not set'](assert) { - assert.equal( - route.serialize(undefined, ['post_id']), - undefined, - 'serialized correctly' - ); + assert.equal(route.serialize(undefined, ['post_id']), undefined, 'serialized correctly'); } } ); @@ -293,7 +252,7 @@ moduleFor( let owner = { lookup(fullName) { return lookupHash[fullName]; - } + }, }; routeOne = EmberRoute.create({ routeName: 'one' }); @@ -304,7 +263,7 @@ moduleFor( lookupHash = { 'route:one': routeOne, - 'route:two': routeTwo + 'route:two': routeTwo, }; } @@ -313,9 +272,7 @@ moduleFor( runDestroy(routeTwo); } - ['@test route._qp does not crash if the controller has no QP, or setProperties']( - assert - ) { + ['@test route._qp does not crash if the controller has no QP, or setProperties'](assert) { lookupHash['controller:test'] = {}; routeOne.controllerName = 'test'; @@ -346,7 +303,7 @@ moduleFor( owner.register( 'route:application', EmberRoute.extend({ - authService: inject.service('auth') + authService: inject.service('auth'), }) ); @@ -355,11 +312,7 @@ moduleFor( let appRoute = owner.lookup('route:application'); let authService = owner.lookup('service:auth'); - assert.equal( - authService, - appRoute.get('authService'), - 'service.auth is injected' - ); + assert.equal(authService, appRoute.get('authService'), 'service.auth is injected'); } } ); @@ -375,10 +328,10 @@ moduleFor( handlerInfos: [{ name: 'posts' }], params: { 'foo.bar': { a: 'b' }, - 'foo.bar.posts': { c: 'd' } - } - } - } + 'foo.bar.posts': { c: 'd' }, + }, + }, + }, }; let engineInstance = buildOwner({ @@ -393,19 +346,19 @@ moduleFor( } else if (name === 'route:application') { return applicationRoute; } - } - } + }, + }, }); let applicationRoute = EmberRoute.create({ _router: router, routeName: 'application', - fullRouteName: 'foo.bar' + fullRouteName: 'foo.bar', }); let postsRoute = EmberRoute.create({ _router: router, routeName: 'posts', - fullRouteName: 'foo.bar.posts' + fullRouteName: 'foo.bar.posts', }); let route = EmberRoute.create({ _router: router }); @@ -434,10 +387,10 @@ moduleFor( activeTransition: { resolvedModels: { 'foo.bar': applicationModel, - 'foo.bar.posts': postsModel - } - } - } + 'foo.bar.posts': postsModel, + }, + }, + }, }; let engineInstance = buildOwner({ @@ -452,17 +405,17 @@ moduleFor( } else if (name === 'route:application') { return applicationRoute; } - } - } + }, + }, }); let applicationRoute = EmberRoute.create({ _router: router, - routeName: 'application' + routeName: 'application', }); let postsRoute = EmberRoute.create({ _router: router, - routeName: 'posts' + routeName: 'posts', }); let route = EmberRoute.create({ _router: router }); @@ -478,14 +431,14 @@ moduleFor( let router = { transitionTo(route) { return route; - } + }, }; let engineInstance = buildOwner({ ownerOptions: { routable: true, - mountPoint: 'foo.bar' - } + mountPoint: 'foo.bar', + }, }); let route = EmberRoute.create({ _router: router }); @@ -501,10 +454,7 @@ moduleFor( 'foo.bar.posts', 'properly prefixes child routes' ); - assert.throws( - () => route.transitionTo('/posts'), - 'throws when trying to use a url' - ); + assert.throws(() => route.transitionTo('/posts'), 'throws when trying to use a url'); let queryParams = {}; assert.strictEqual( @@ -514,39 +464,29 @@ moduleFor( ); } - ["@test intermediateTransitionTo considers an engine's mountPoint"]( - assert - ) { + ["@test intermediateTransitionTo considers an engine's mountPoint"](assert) { let lastRoute; let router = { intermediateTransitionTo(route) { lastRoute = route; - } + }, }; let engineInstance = buildOwner({ ownerOptions: { routable: true, - mountPoint: 'foo.bar' - } + mountPoint: 'foo.bar', + }, }); let route = EmberRoute.create({ _router: router }); setOwner(route, engineInstance); route.intermediateTransitionTo('application'); - assert.strictEqual( - lastRoute, - 'foo.bar.application', - 'properly prefixes application route' - ); + assert.strictEqual(lastRoute, 'foo.bar.application', 'properly prefixes application route'); route.intermediateTransitionTo('posts'); - assert.strictEqual( - lastRoute, - 'foo.bar.posts', - 'properly prefixes child routes' - ); + assert.strictEqual(lastRoute, 'foo.bar.posts', 'properly prefixes child routes'); assert.throws( () => route.intermediateTransitionTo('/posts'), @@ -555,25 +495,21 @@ moduleFor( let queryParams = {}; route.intermediateTransitionTo(queryParams); - assert.strictEqual( - lastRoute, - queryParams, - 'passes query param only transitions through' - ); + assert.strictEqual(lastRoute, queryParams, 'passes query param only transitions through'); } ["@test replaceWith considers an engine's mountPoint"](assert) { let router = { replaceWith(route) { return route; - } + }, }; let engineInstance = buildOwner({ ownerOptions: { routable: true, - mountPoint: 'foo.bar' - } + mountPoint: 'foo.bar', + }, }); let route = EmberRoute.create({ _router: router }); @@ -589,10 +525,7 @@ moduleFor( 'foo.bar.posts', 'properly prefixes child routes' ); - assert.throws( - () => route.replaceWith('/posts'), - 'throws when trying to use a url' - ); + assert.throws(() => route.replaceWith('/posts'), 'throws when trying to use a url'); let queryParams = {}; assert.strictEqual( diff --git a/packages/ember-routing/tests/system/router_test.js b/packages/ember-routing/tests/system/router_test.js index fbf42f3deee..f8046c44e25 100644 --- a/packages/ember-routing/tests/system/router_test.js +++ b/packages/ember-routing/tests/system/router_test.js @@ -4,12 +4,7 @@ import HistoryLocation from '../../location/history_location'; import AutoLocation from '../../location/auto_location'; import NoneLocation from '../../location/none_location'; import Router, { triggerEvent } from '../../system/router'; -import { - runDestroy, - buildOwner, - moduleFor, - AbstractTestCase -} from 'internal-test-helpers'; +import { runDestroy, buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers'; let owner; @@ -50,10 +45,7 @@ moduleFor( ['@test can create a router without an owner'](assert) { createRouter(undefined, { disableSetup: true, skipOwner: true }); - assert.ok( - true, - 'no errors were thrown when creating without a container' - ); + assert.ok(true, 'no errors were thrown when creating without a container'); } ['@test [GH#15237] EmberError is imported correctly'](assert) { @@ -71,24 +63,14 @@ moduleFor( ['@test should not reify location until setupRouter is called'](assert) { let router = createRouter(undefined, { disableSetup: true }); - assert.equal( - typeof router.location, - 'string', - 'location is specified as a string' - ); + assert.equal(typeof router.location, 'string', 'location is specified as a string'); router.setupRouter(); - assert.equal( - typeof router.location, - 'object', - 'location is reified into an object' - ); + assert.equal(typeof router.location, 'object', 'location is reified into an object'); } - ['@test should destroy its location upon destroying the routers owner.']( - assert - ) { + ['@test should destroy its location upon destroying the routers owner.'](assert) { let router = createRouter(); let location = router.get('location'); @@ -99,7 +81,7 @@ moduleFor( ['@test should instantiate its location with its `rootURL`'](assert) { let router = createRouter({ - rootURL: '/rootdir/' + rootURL: '/rootdir/', }); let location = router.get('location'); @@ -119,7 +101,7 @@ moduleFor( search: '', replace(url) { assert.equal(url, 'http://test.com/rootdir/#/welcome'); - } + }, }; location.location = browserLocation; @@ -128,7 +110,7 @@ moduleFor( createRouter({ location: 'auto', - rootURL: '/rootdir/' + rootURL: '/rootdir/', }); } @@ -136,11 +118,9 @@ moduleFor( createRouter(); function routePath() { - let handlerInfos = Array.prototype.slice - .call(arguments) - .map(function(s) { - return { name: s }; - }); + let handlerInfos = Array.prototype.slice.call(arguments).map(function(s) { + return { name: s }; + }); handlerInfos.unshift({ name: 'ignored' }); return Router._routePath(handlerInfos); @@ -150,10 +130,7 @@ moduleFor( assert.equal(routePath('foo', 'bar', 'baz'), 'foo.bar.baz'); assert.equal(routePath('foo', 'foo.bar'), 'foo.bar'); assert.equal(routePath('foo', 'foo.bar', 'foo.bar.baz'), 'foo.bar.baz'); - assert.equal( - routePath('foo', 'foo.bar', 'foo.bar.baz.wow'), - 'foo.bar.baz.wow' - ); + assert.equal(routePath('foo', 'foo.bar', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); assert.equal(routePath('foo', 'foo.bar.baz.wow'), 'foo.bar.baz.wow'); assert.equal(routePath('foo.bar', 'bar.baz.wow'), 'foo.bar.baz.wow'); @@ -172,7 +149,7 @@ moduleFor( cancelRouterSetup: true, create() { return this; - } + }, }; owner.register('location:fake', FakeLocation); @@ -182,15 +159,13 @@ moduleFor( _setupRouter() { assert.ok(false, '_setupRouter should not be called'); - } + }, }); router.startRouting(); } - ["@test AutoLocation should replace the url when it's not in the preferred format"]( - assert - ) { + ["@test AutoLocation should replace the url when it's not in the preferred format"](assert) { assert.expect(1); let location = owner.lookup('location:auto'); @@ -203,37 +178,33 @@ moduleFor( search: '', replace(url) { assert.equal(url, 'http://test.com/rootdir/#/welcome'); - } + }, }; location.history = null; location.global = { - onhashchange() {} + onhashchange() {}, }; createRouter({ location: 'auto', - rootURL: '/rootdir/' + rootURL: '/rootdir/', }); } - ['@test Router#handleURL should remove any #hashes before doing URL transition']( - assert - ) { + ['@test Router#handleURL should remove any #hashes before doing URL transition'](assert) { assert.expect(2); let router = createRouter({ _doURLTransition(routerJsMethod, url) { assert.equal(routerJsMethod, 'handleURL'); assert.equal(url, '/foo/bar?time=morphin'); - } + }, }); router.handleURL('/foo/bar?time=morphin#pink-power-ranger'); } - ['@test Router#triggerEvent allows actions to bubble when returning true']( - assert - ) { + ['@test Router#triggerEvent allows actions to bubble when returning true'](assert) { assert.expect(2); let handlerInfos = [ @@ -243,9 +214,9 @@ moduleFor( actions: { loading() { assert.ok(false, 'loading not handled by application route'); - } - } - } + }, + }, + }, }, { name: 'about', @@ -254,9 +225,9 @@ moduleFor( loading() { assert.ok(true, 'loading handled by about route'); return false; - } - } - } + }, + }, + }, }, { name: 'about.me', @@ -265,18 +236,16 @@ moduleFor( loading() { assert.ok(true, 'loading handled by about.me route'); return true; - } - } - } - } + }, + }, + }, + }, ]; triggerEvent(handlerInfos, false, ['loading']); } - ['@test Router#triggerEvent ignores handlers that have not loaded yet']( - assert - ) { + ['@test Router#triggerEvent ignores handlers that have not loaded yet'](assert) { assert.expect(1); let handlerInfos = [ @@ -286,14 +255,14 @@ moduleFor( actions: { loading() { assert.ok(true, 'loading handled by about route'); - } - } - } + }, + }, + }, }, { name: 'about.me', - handler: undefined - } + handler: undefined, + }, ]; triggerEvent(handlerInfos, false, ['loading']); diff --git a/packages/ember-routing/tests/utils_test.js b/packages/ember-routing/tests/utils_test.js index 3d655737fbf..4cbc4d1c841 100644 --- a/packages/ember-routing/tests/utils_test.js +++ b/packages/ember-routing/tests/utils_test.js @@ -10,16 +10,8 @@ moduleFor( let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'turns the query param name into key'); - assert.equal( - normalized[paramName].as, - null, - "includes a blank alias in 'as' key" - ); - assert.equal( - normalized[paramName].scope, - 'model', - 'defaults scope to model' - ); + assert.equal(normalized[paramName].as, null, "includes a blank alias in 'as' key"); + assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } ["@test converts object style [{foo: 'an_alias'}]"](assert) { @@ -28,36 +20,18 @@ moduleFor( let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'retains the query param name as key'); - assert.equal( - normalized[paramName].as, - 'an_alias', - "includes the provided alias in 'as' key" - ); - assert.equal( - normalized[paramName].scope, - 'model', - 'defaults scope to model' - ); + assert.equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key"); + assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } - ["@test retains maximally verbose object style [{foo: {as: 'foo'}}]"]( - assert - ) { + ["@test retains maximally verbose object style [{foo: {as: 'foo'}}]"](assert) { let paramName = 'foo'; let params = [{ foo: { as: 'an_alias' } }]; let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'retains the query param name as key'); - assert.equal( - normalized[paramName].as, - 'an_alias', - "includes the provided alias in 'as' key" - ); - assert.equal( - normalized[paramName].scope, - 'model', - 'defaults scope to model' - ); + assert.equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key"); + assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } } ); diff --git a/packages/ember-runtime/lib/compare.js b/packages/ember-runtime/lib/compare.js index 8d872fe3669..04b6f95c524 100644 --- a/packages/ember-runtime/lib/compare.js +++ b/packages/ember-runtime/lib/compare.js @@ -12,7 +12,7 @@ const TYPE_ORDER = { instance: 7, function: 8, class: 9, - date: 10 + date: 10, }; // diff --git a/packages/ember-runtime/lib/computed/computed_macros.js b/packages/ember-runtime/lib/computed/computed_macros.js index b7993a894e4..329bb875eca 100644 --- a/packages/ember-runtime/lib/computed/computed_macros.js +++ b/packages/ember-runtime/lib/computed/computed_macros.js @@ -6,7 +6,7 @@ import { isEmpty, isNone, alias, - expandProperties + expandProperties, } from 'ember-metal'; import { assert, deprecate } from 'ember-debug'; @@ -737,6 +737,6 @@ export function deprecatingAlias(dependentKey, options) { ); set(this, dependentKey, value); return value; - } + }, }); } diff --git a/packages/ember-runtime/lib/computed/reduce_computed_macros.js b/packages/ember-runtime/lib/computed/reduce_computed_macros.js index cb93371856d..618c4191e41 100644 --- a/packages/ember-runtime/lib/computed/reduce_computed_macros.js +++ b/packages/ember-runtime/lib/computed/reduce_computed_macros.js @@ -2,13 +2,7 @@ @module @ember/object */ import { assert } from 'ember-debug'; -import { - get, - ComputedProperty, - addObserver, - removeObserver, - getProperties -} from 'ember-metal'; +import { get, ComputedProperty, addObserver, removeObserver, getProperties } from 'ember-metal'; import compare from '../compare'; import { isArray } from '../utils'; import { A as emberA } from '../mixins/array'; @@ -139,12 +133,7 @@ export function sum(dependentKey) { @public */ export function max(dependentKey) { - return reduceMacro( - dependentKey, - (max, item) => Math.max(max, item), - -Infinity, - 'max' - ); + return reduceMacro(dependentKey, (max, item) => Math.max(max, item), -Infinity, 'max'); } /** @@ -193,12 +182,7 @@ export function max(dependentKey) { @public */ export function min(dependentKey) { - return reduceMacro( - dependentKey, - (min, item) => Math.min(min, item), - Infinity, - 'min' - ); + return reduceMacro(dependentKey, (min, item) => Math.min(min, item), Infinity, 'min'); } /** @@ -290,9 +274,7 @@ export function mapBy(dependentKey, propertyKey) { !/[\[\]\{\}]/g.test(dependentKey) ); - return map(`${dependentKey}.@each.${propertyKey}`, item => - get(item, propertyKey) - ); + return map(`${dependentKey}.@each.${propertyKey}`, item => get(item, propertyKey)); } /** @@ -672,10 +654,7 @@ export function intersect(...args) { @public */ export function setDiff(setAProperty, setBProperty) { - assert( - '`computed.setDiff` requires exactly two dependent arrays.', - arguments.length === 2 - ); + assert('`computed.setDiff` requires exactly two dependent arrays.', arguments.length === 2); assert( `Dependent keys passed to \`computed.setDiff\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(setAProperty) && !/[\[\]\{\}]/g.test(setBProperty) @@ -697,7 +676,7 @@ export function setDiff(setAProperty, setBProperty) { }, { dependentKeys: [`${setAProperty}.[]`, `${setBProperty}.[]`], - readOnly: true + readOnly: true, } ); @@ -853,13 +832,11 @@ function propertySort(itemsKey, sortPropertiesKey) { assert( `The sort definition for '${key}' on ${this} must be a function or an array of strings`, - isArray(sortProperties) && - sortProperties.every(s => typeof s === 'string') + isArray(sortProperties) && sortProperties.every(s => typeof s === 'string') ); // Add/remove property observers as required. - let activeObserversMap = - cp._activeObserverMap || (cp._activeObserverMap = new WeakMap()); + let activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new WeakMap()); let activeObservers = activeObserversMap.get(this); if (activeObservers !== undefined) { @@ -873,9 +850,7 @@ function propertySort(itemsKey, sortPropertiesKey) { let itemsKeyIsAtThis = itemsKey === '@this'; let normalizedSortProperties = normalizeSortProperties(sortProperties); activeObservers = normalizedSortProperties.map(([prop]) => { - let path = itemsKeyIsAtThis - ? `@each.${prop}` - : `${itemsKey}.@each.${prop}`; + let path = itemsKeyIsAtThis ? `@each.${prop}` : `${itemsKey}.@each.${prop}`; addObserver(this, path, sortPropertyDidChange); return [this, path, sortPropertyDidChange]; }); diff --git a/packages/ember-runtime/lib/controllers/controller.js b/packages/ember-runtime/lib/controllers/controller.js index ccec3ddc257..3c9da324985 100644 --- a/packages/ember-runtime/lib/controllers/controller.js +++ b/packages/ember-runtime/lib/controllers/controller.js @@ -17,8 +17,7 @@ const Controller = EmberObject.extend(Mixin); function controllerInjectionHelper(factory) { assert( - 'Defining an injected controller property on a ' + - 'non-controller is not allowed.', + 'Defining an injected controller property on a ' + 'non-controller is not allowed.', Mixin.detect(factory.PrototypeMixin) ); } diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index 2274f923769..7c2279b7966 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -80,7 +80,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { writable: true, value: function() { return computed(...arguments, this); - } + }, }); /** @@ -116,7 +116,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { writable: true, value: function() { return observer(...arguments, this); - } + }, }); Object.defineProperty(FunctionPrototype, '_observesImmediately', { @@ -139,7 +139,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { // observes handles property expansion return this.observes(...arguments); - } + }, }); /** @@ -173,6 +173,6 @@ if (ENV.EXTEND_PROTOTYPES.Function) { writable: true, value: function() { return on(...arguments, this); - } + }, }); } diff --git a/packages/ember-runtime/lib/ext/rsvp.js b/packages/ember-runtime/lib/ext/rsvp.js index c7631606d5c..301c93f4bb1 100644 --- a/packages/ember-runtime/lib/ext/rsvp.js +++ b/packages/ember-runtime/lib/ext/rsvp.js @@ -33,12 +33,7 @@ function errorFor(reason) { } if (reason.name === 'UnrecognizedURLError') { - assert( - `The URL '${ - reason.message - }' did not match any routes in your application`, - false - ); + assert(`The URL '${reason.message}' did not match any routes in your application`, false); return; } @@ -56,7 +51,7 @@ function unwrapErrorThrown(reason) { } Object.defineProperty(error, '__reason_with_error_thrown__', { value: reason, - enumerable: false + enumerable: false, }); return error; } diff --git a/packages/ember-runtime/lib/ext/string.js b/packages/ember-runtime/lib/ext/string.js index dc05fa46ee7..80c6aaafa79 100644 --- a/packages/ember-runtime/lib/ext/string.js +++ b/packages/ember-runtime/lib/ext/string.js @@ -11,7 +11,7 @@ import { dasherize, underscore, capitalize, - classify + classify, } from '../system/string'; const StringPrototype = String.prototype; @@ -31,7 +31,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return w(this); - } + }, }); /** @@ -48,7 +48,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function(...args) { return loc(this, args); - } + }, }); /** @@ -65,7 +65,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return camelize(this); - } + }, }); /** @@ -82,7 +82,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return decamelize(this); - } + }, }); /** @@ -99,7 +99,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return dasherize(this); - } + }, }); /** @@ -116,7 +116,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return underscore(this); - } + }, }); /** @@ -133,7 +133,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return classify(this); - } + }, }); /** @@ -150,6 +150,6 @@ if (ENV.EXTEND_PROTOTYPES.String) { writeable: true, value: function() { return capitalize(this); - } + }, }); } diff --git a/packages/ember-runtime/lib/index.js b/packages/ember-runtime/lib/index.js index c6bc9d4f72e..0de8abba677 100644 --- a/packages/ember-runtime/lib/index.js +++ b/packages/ember-runtime/lib/index.js @@ -12,7 +12,7 @@ export { NativeArray, A, MutableArray, - removeAt + removeAt, } from './mixins/array'; export { default as Comparable } from './mixins/comparable'; export { default as Namespace } from './system/namespace'; @@ -22,10 +22,7 @@ export { default as CoreObject } from './system/core_object'; export { default as ActionHandler } from './mixins/action_handler'; export { default as Copyable } from './mixins/copyable'; export { default as Enumerable } from './mixins/enumerable'; -export { - default as _ProxyMixin, - contentFor as _contentFor -} from './mixins/-proxy'; +export { default as _ProxyMixin, contentFor as _contentFor } from './mixins/-proxy'; export { onLoad, runLoadHooks, _loaded } from './system/lazy_load'; export { default as Observable } from './mixins/observable'; export { default as MutableEnumerable } from './mixins/mutable_enumerable'; @@ -49,7 +46,7 @@ export { readOnly, deprecatingAlias, and, - or + or, } from './computed/computed_macros'; export { @@ -66,7 +63,7 @@ export { uniqBy, union, intersect, - collect + collect, } from './computed/reduce_computed_macros'; export { default as Controller } from './controllers/controller'; diff --git a/packages/ember-runtime/lib/inject.js b/packages/ember-runtime/lib/inject.js index 6b6259b618a..c52f763cb60 100644 --- a/packages/ember-runtime/lib/inject.js +++ b/packages/ember-runtime/lib/inject.js @@ -15,9 +15,7 @@ import { EMBER_MODULE_UNIFICATION } from 'ember/features'; */ export default function inject() { assert( - `Injected properties must be created through helpers, see '${Object.keys( - inject - ) + `Injected properties must be created through helpers, see '${Object.keys(inject) .map(k => `'inject.${k}'`) .join(' or ')}'` ); diff --git a/packages/ember-runtime/lib/mixins/-proxy.js b/packages/ember-runtime/lib/mixins/-proxy.js index 31e1a4bb0ed..0df88e07068 100644 --- a/packages/ember-runtime/lib/mixins/-proxy.js +++ b/packages/ember-runtime/lib/mixins/-proxy.js @@ -2,12 +2,7 @@ @module ember */ -import { - combine, - CONSTANT_TAG, - DirtyableTag, - UpdatableTag -} from '@glimmer/reference'; +import { combine, CONSTANT_TAG, DirtyableTag, UpdatableTag } from '@glimmer/reference'; import { get, set, @@ -17,7 +12,7 @@ import { notifyPropertyChange, defineProperty, Mixin, - tagFor + tagFor, } from 'ember-metal'; import { setProxy } from 'ember-utils'; import { assert } from 'ember-debug'; @@ -63,9 +58,7 @@ export default Mixin.create({ this._super(...arguments); setProxy(this); let m = meta(this); - m.writableTag(() => - combine([DirtyableTag.create(), UpdatableTag.create(CONSTANT_TAG)]) - ); + m.writableTag(() => combine([DirtyableTag.create(), UpdatableTag.create(CONSTANT_TAG)])); }, isTruthy: bool('content'), @@ -105,5 +98,5 @@ export default Mixin.create({ ); return set(content, key, value); - } + }, }); diff --git a/packages/ember-runtime/lib/mixins/action_handler.js b/packages/ember-runtime/lib/mixins/action_handler.js index aeb2429534e..eb5f1fed45e 100644 --- a/packages/ember-runtime/lib/mixins/action_handler.js +++ b/packages/ember-runtime/lib/mixins/action_handler.js @@ -216,7 +216,7 @@ const ActionHandler = Mixin.create({ ); target.send(...arguments); } - } + }, }); export default ActionHandler; diff --git a/packages/ember-runtime/lib/mixins/array.js b/packages/ember-runtime/lib/mixins/array.js index d98a852e76e..1a7bda68234 100644 --- a/packages/ember-runtime/lib/mixins/array.js +++ b/packages/ember-runtime/lib/mixins/array.js @@ -19,7 +19,7 @@ import { addArrayObserver, removeArrayObserver, arrayContentWillChange, - arrayContentDidChange + arrayContentDidChange, } from 'ember-metal'; import { assert, deprecate } from 'ember-debug'; import Enumerable from './enumerable'; @@ -41,9 +41,7 @@ export function isEmberArray(obj) { function iter(key, value) { let valueProvided = arguments.length === 2; - return valueProvided - ? item => value === get(item, key) - : item => !!get(item, key); + return valueProvided ? item => value === get(item, key) : item => !!get(item, key); } // .......................................................... @@ -164,7 +162,7 @@ const ArrayMixin = Mixin.create(Enumerable, { set(key, value) { this.replace(0, get(this, 'length'), value); return this; - } + }, }), /** @@ -376,9 +374,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ hasArrayObservers: computed(function() { - return ( - hasListeners(this, '@array:change') || hasListeners(this, '@array:before') - ); + return hasListeners(this, '@array:change') || hasListeners(this, '@array:before'); }), /** @@ -446,10 +442,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ forEach(callback, target = null) { - assert( - 'forEach expects a function as first argument.', - typeof callback === 'function' - ); + assert('forEach expects a function as first argument.', typeof callback === 'function'); let length = get(this, 'length'); @@ -515,10 +508,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ map(callback, target) { - assert( - 'map expects a function as first argument.', - typeof callback === 'function' - ); + assert('map expects a function as first argument.', typeof callback === 'function'); let ret = A(); @@ -570,10 +560,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ filter(callback, target) { - assert( - 'filter expects a function as first argument.', - typeof callback === 'function' - ); + assert('filter expects a function as first argument.', typeof callback === 'function'); let ret = A(); @@ -614,10 +601,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ reject(callback, target) { - assert( - 'reject expects a function as first argument.', - typeof callback === 'function' - ); + assert('reject expects a function as first argument.', typeof callback === 'function'); return this.filter(function() { return !callback.apply(target, arguments); @@ -688,10 +672,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ find(callback, target = null) { - assert( - 'find expects a function as first argument.', - typeof callback === 'function' - ); + assert('find expects a function as first argument.', typeof callback === 'function'); let length = get(this, 'length'); @@ -758,10 +739,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ every(callback, target) { - assert( - 'every expects a function as first argument.', - typeof callback === 'function' - ); + assert('every expects a function as first argument.', typeof callback === 'function'); return !this.find((x, idx, i) => !callback.call(target, x, idx, i)); }, @@ -824,10 +802,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ any(callback, target = null) { - assert( - 'any expects a function as first argument.', - typeof callback === 'function' - ); + assert('any expects a function as first argument.', typeof callback === 'function'); let length = get(this, 'length'); @@ -894,10 +869,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ reduce(callback, initialValue, reducerProperty) { - assert( - 'reduce expects a function as first argument.', - typeof callback === 'function' - ); + assert('reduce expects a function as first argument.', typeof callback === 'function'); let ret = initialValue; @@ -1160,19 +1132,14 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ '@each': computed(function() { - deprecate( - `Getting the '@each' property on object ${toString(this)} is deprecated`, - false, - { - id: 'ember-metal.getting-each', - until: '3.5.0', - url: - 'https://emberjs.com/deprecations/v3.x#toc_getting-the-each-property' - } - ); + deprecate(`Getting the '@each' property on object ${toString(this)} is deprecated`, false, { + id: 'ember-metal.getting-each', + until: '3.5.0', + url: 'https://emberjs.com/deprecations/v3.x#toc_getting-the-each-property', + }); return eachProxyFor(this); - }).readOnly() + }).readOnly(), }); const OUT_OF_RANGE_EXCEPTION = 'Index out of range'; @@ -1579,7 +1546,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { objects.forEach(obj => this.addObject(obj)); endPropertyChanges(this); return this; - } + }, }); /** @@ -1654,10 +1621,7 @@ let NativeArray = Mixin.create(MutableArray, Observable, Copyable, { // primitive for array support. replace(start, deleteCount, items = EMPTY_ARRAY) { - assert( - 'The third argument to replace needs to be an array.', - Array.isArray(items) - ); + assert('The third argument to replace needs to be an array.', Array.isArray(items)); replaceInNativeArray(this, start, deleteCount, items); @@ -1683,7 +1647,7 @@ let NativeArray = Mixin.create(MutableArray, Observable, Copyable, { } return this.slice(); - } + }, }); // Remove any methods implemented natively so we don't override them diff --git a/packages/ember-runtime/lib/mixins/comparable.js b/packages/ember-runtime/lib/mixins/comparable.js index 8a041b45a04..80c8b09a657 100644 --- a/packages/ember-runtime/lib/mixins/comparable.js +++ b/packages/ember-runtime/lib/mixins/comparable.js @@ -34,5 +34,5 @@ export default Mixin.create({ @return {Number} the result of the comparison @private */ - compare: null + compare: null, }); diff --git a/packages/ember-runtime/lib/mixins/container_proxy.js b/packages/ember-runtime/lib/mixins/container_proxy.js index bea1c35dbe2..65f5ca149b8 100644 --- a/packages/ember-runtime/lib/mixins/container_proxy.js +++ b/packages/ember-runtime/lib/mixins/container_proxy.js @@ -145,7 +145,7 @@ let containerProxyMixin = { */ factoryFor(fullName, options = {}) { return this.__container__.factoryFor(fullName, options); - } + }, }; export default Mixin.create(containerProxyMixin); diff --git a/packages/ember-runtime/lib/mixins/controller.js b/packages/ember-runtime/lib/mixins/controller.js index 3fbb795fb28..3e897091878 100644 --- a/packages/ember-runtime/lib/mixins/controller.js +++ b/packages/ember-runtime/lib/mixins/controller.js @@ -38,5 +38,5 @@ export default Mixin.create(ActionHandler, { @property model @public */ - model: null + model: null, }); diff --git a/packages/ember-runtime/lib/mixins/copyable.js b/packages/ember-runtime/lib/mixins/copyable.js index bbe6916e206..080ad5ab3ec 100644 --- a/packages/ember-runtime/lib/mixins/copyable.js +++ b/packages/ember-runtime/lib/mixins/copyable.js @@ -29,5 +29,5 @@ export default Mixin.create({ @return {Object} copy of receiver @private */ - copy: null + copy: null, }); diff --git a/packages/ember-runtime/lib/mixins/evented.js b/packages/ember-runtime/lib/mixins/evented.js index 12d79ea5b09..a660a609202 100644 --- a/packages/ember-runtime/lib/mixins/evented.js +++ b/packages/ember-runtime/lib/mixins/evented.js @@ -1,10 +1,4 @@ -import { - Mixin, - addListener, - removeListener, - hasListeners, - sendEvent -} from 'ember-metal'; +import { Mixin, addListener, removeListener, hasListeners, sendEvent } from 'ember-metal'; /** @module @ember/object @@ -151,5 +145,5 @@ export default Mixin.create({ */ has(name) { return hasListeners(this, name); - } + }, }); diff --git a/packages/ember-runtime/lib/mixins/observable.js b/packages/ember-runtime/lib/mixins/observable.js index f96f1eb02c7..c530d71ba7b 100644 --- a/packages/ember-runtime/lib/mixins/observable.js +++ b/packages/ember-runtime/lib/mixins/observable.js @@ -18,7 +18,7 @@ import { addObserver, removeObserver, getCachedValueFor, - isNone + isNone, } from 'ember-metal'; import { assert } from 'ember-debug'; @@ -427,11 +427,7 @@ export default Mixin.create({ 'Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment) ); - return set( - this, - keyName, - (parseFloat(get(this, keyName)) || 0) + increment - ); + return set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment); }, /** @@ -489,5 +485,5 @@ export default Mixin.create({ */ cacheFor(keyName) { return getCachedValueFor(this, keyName); - } + }, }); diff --git a/packages/ember-runtime/lib/mixins/promise_proxy.js b/packages/ember-runtime/lib/mixins/promise_proxy.js index 380e4cd4e9b..8b5274caac2 100644 --- a/packages/ember-runtime/lib/mixins/promise_proxy.js +++ b/packages/ember-runtime/lib/mixins/promise_proxy.js @@ -9,7 +9,7 @@ import { not, or } from '../computed/computed_macros'; function tap(proxy, promise) { setProperties(proxy, { isFulfilled: false, - isRejected: false + isRejected: false, }); return promise.then( @@ -17,7 +17,7 @@ function tap(proxy, promise) { if (!proxy.isDestroyed && !proxy.isDestroying) { setProperties(proxy, { content: value, - isFulfilled: true + isFulfilled: true, }); } return value; @@ -26,7 +26,7 @@ function tap(proxy, promise) { if (!proxy.isDestroyed && !proxy.isDestroying) { setProperties(proxy, { reason, - isRejected: true + isRejected: true, }); } throw reason; @@ -171,7 +171,7 @@ export default Mixin.create({ }, set(key, promise) { return tap(this, promise); - } + }, }), /** @@ -210,7 +210,7 @@ export default Mixin.create({ @since 1.3.0 @public */ - finally: promiseAlias('finally') + finally: promiseAlias('finally'), }); function promiseAlias(name) { diff --git a/packages/ember-runtime/lib/mixins/registry_proxy.js b/packages/ember-runtime/lib/mixins/registry_proxy.js index 4095d269108..8afed96a6ae 100644 --- a/packages/ember-runtime/lib/mixins/registry_proxy.js +++ b/packages/ember-runtime/lib/mixins/registry_proxy.js @@ -24,10 +24,7 @@ export default Mixin.create({ @return {Function} fullName's factory */ resolveRegistration(fullName, options) { - assert( - 'fullName must be a proper full name', - this.__registry__.isValidFullName(fullName) - ); + assert('fullName must be a proper full name', this.__registry__.isValidFullName(fullName)); return this.__registry__.resolve(fullName, options); }, @@ -258,7 +255,7 @@ export default Mixin.create({ @param property {String} @param injectionName {String} **/ - inject: registryAlias('injection') + inject: registryAlias('injection'), }); function registryAlias(name) { diff --git a/packages/ember-runtime/lib/mixins/target_action_support.js b/packages/ember-runtime/lib/mixins/target_action_support.js index 85fca5e48f4..259a84b4dd2 100644 --- a/packages/ember-runtime/lib/mixins/target_action_support.js +++ b/packages/ember-runtime/lib/mixins/target_action_support.js @@ -33,7 +33,7 @@ export default Mixin.create({ let options = { id: 'ember-runtime.using-targetObject', until: '3.5.0' }; deprecate(message, false, options); this._targetObject = value; - } + }, }), action: null, actionContext: null, @@ -137,7 +137,7 @@ export default Mixin.create({ } return false; - } + }, }); function getTarget(instance) { diff --git a/packages/ember-runtime/lib/system/array_proxy.js b/packages/ember-runtime/lib/system/array_proxy.js index efa7b3a9678..87191ffa09b 100644 --- a/packages/ember-runtime/lib/system/array_proxy.js +++ b/packages/ember-runtime/lib/system/array_proxy.js @@ -9,7 +9,7 @@ import { alias, PROPERTY_DID_CHANGE, addArrayObserver, - removeArrayObserver + removeArrayObserver, } from 'ember-metal'; import { isArray } from '../utils'; import EmberObject from './object'; @@ -18,7 +18,7 @@ import { assert } from 'ember-debug'; const ARRAY_OBSERVER_MAPPING = { willChange: '_arrangedContentArrayWillChange', - didChange: '_arrangedContentArrayDidChange' + didChange: '_arrangedContentArrayDidChange', }; /** @@ -210,10 +210,7 @@ export default EmberObject.extend(MutableArray, { _addArrangedContentArrayObsever() { let arrangedContent = get(this, 'arrangedContent'); if (arrangedContent) { - assert( - "Can't set ArrayProxy's content to itself", - arrangedContent !== this - ); + assert("Can't set ArrayProxy's content to itself", arrangedContent !== this); assert( `ArrayProxy expects an Array or ArrayProxy, but you passed ${typeof arrangedContent}`, isArray(arrangedContent) || arrangedContent.isDestroyed @@ -253,5 +250,5 @@ export default EmberObject.extend(MutableArray, { this._lengthDirty = true; this.arrayContentDidChange(idx, removedCnt, addedCnt); - } + }, }); diff --git a/packages/ember-runtime/lib/system/core_object.js b/packages/ember-runtime/lib/system/core_object.js index 2e8272df06a..43a3ee90735 100644 --- a/packages/ember-runtime/lib/system/core_object.js +++ b/packages/ember-runtime/lib/system/core_object.js @@ -12,7 +12,7 @@ import { setName, makeArray, HAS_NATIVE_PROXY, - isInternalSymbol + isInternalSymbol, } from 'ember-utils'; import { PROXY_CONTENT, @@ -29,18 +29,14 @@ import { schedule, deleteMeta, descriptor, - classToString + classToString, } from 'ember-metal'; import ActionHandler from '../mixins/action_handler'; import { validatePropertyInjections } from '../inject'; import { assert } from 'ember-debug'; import { DEBUG } from 'ember-env-flags'; import { ENV } from 'ember-environment'; -import { - MANDATORY_GETTER, - MANDATORY_SETTER, - EMBER_METAL_ES5_GETTERS -} from 'ember/features'; +import { MANDATORY_GETTER, MANDATORY_SETTER, EMBER_METAL_ES5_GETTERS } from 'ember/features'; const applyMixin = Mixin._apply; const reopen = Mixin.prototype.reopen; @@ -94,9 +90,7 @@ function makeCtor(base) { ) { let messageFor = (obj, property) => { return ( - `You attempted to access the \`${String( - property - )}\` property (of ${obj}).\n` + + `You attempted to access the \`${String(property)}\` property (of ${obj}).\n` + `Since Ember 3.1, this is usually fine as you no longer need to use \`.get()\`\n` + `to access computed properties. However, in this case, the object in question\n` + `is a special kind of Ember object (a proxy). Therefore, it is still necessary\n` + @@ -135,7 +129,7 @@ function makeCtor(base) { let value = target.unknownProperty.call(receiver, property); assert(messageFor(receiver, property), value === undefined); - } + }, }); } @@ -158,10 +152,8 @@ function makeCtor(base) { let concatenatedProperties = self.concatenatedProperties; let mergedProperties = self.mergedProperties; let hasConcatenatedProps = - concatenatedProperties !== undefined && - concatenatedProperties.length > 0; - let hasMergedProps = - mergedProperties !== undefined && mergedProperties.length > 0; + concatenatedProperties !== undefined && concatenatedProperties.length > 0; + let hasMergedProps = mergedProperties !== undefined && mergedProperties.length > 0; let keyNames = Object.keys(properties); @@ -181,10 +173,7 @@ function makeCtor(base) { ); assert( 'EmberObject.create no longer supports defining methods that call _super.', - !( - typeof value === 'function' && - value.toString().indexOf('._super') !== -1 - ) + !(typeof value === 'function' && value.toString().indexOf('._super') !== -1) ); assert( '`actions` must be provided at extend time, not at create time, ' + @@ -198,10 +187,7 @@ function makeCtor(base) { if (!isDescriptor) { let baseValue = self[keyName]; - if ( - hasConcatenatedProps && - concatenatedProperties.indexOf(keyName) > -1 - ) { + if (hasConcatenatedProps && concatenatedProperties.indexOf(keyName) > -1) { if (baseValue) { value = makeArray(baseValue).concat(value); } else { @@ -216,10 +202,7 @@ function makeCtor(base) { if (isDescriptor) { possibleDesc.set(self, keyName, value); - } else if ( - typeof self.setUnknownProperty === 'function' && - !(keyName in self) - ) { + } else if (typeof self.setUnknownProperty === 'function' && !(keyName in self)) { self.setUnknownProperty(keyName, value); } else { if (MANDATORY_SETTER) { @@ -295,7 +278,7 @@ const IS_DESTROYED = descriptor({ `You cannot set \`${this}.isDestroyed\` directly, please use \`.destroy()\`.`, value === IS_DESTROYED ); - } + }, }); const IS_DESTROYING = descriptor({ @@ -311,7 +294,7 @@ const IS_DESTROYING = descriptor({ `You cannot set \`${this}.isDestroying\` directly, please use \`.destroy()\`.`, value === IS_DESTROYING ); - } + }, }); /** @@ -631,12 +614,12 @@ CoreObject.PrototypeMixin = Mixin.create({ let hasToStringExtension = typeof this.toStringExtension === 'function'; let extension = hasToStringExtension ? `:${this.toStringExtension()}` : ''; - let ret = `<${getName(this) || - FACTORY_FOR.get(this) || - this.constructor.toString()}:${guidFor(this)}${extension}>`; + let ret = `<${getName(this) || FACTORY_FOR.get(this) || this.constructor.toString()}:${guidFor( + this + )}${extension}>`; return ret; - } + }, }); CoreObject.PrototypeMixin.ownerConstructor = CoreObject; @@ -1000,7 +983,7 @@ let ClassMixinProps = { callback.call(binding, name, meta); } }); - } + }, }; if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT) { @@ -1016,8 +999,7 @@ function flattenProps(...props) { let { concatenatedProperties, mergedProperties } = this; let hasConcatenatedProps = concatenatedProperties !== undefined && concatenatedProperties.length > 0; - let hasMergedProps = - mergedProperties !== undefined && mergedProperties.length > 0; + let hasMergedProps = mergedProperties !== undefined && mergedProperties.length > 0; let initProperties = {}; @@ -1036,10 +1018,7 @@ function flattenProps(...props) { let keyName = keyNames[j]; let value = properties[keyName]; - if ( - hasConcatenatedProps && - concatenatedProperties.indexOf(keyName) > -1 - ) { + if (hasConcatenatedProps && concatenatedProperties.indexOf(keyName) > -1) { let baseValue = initProperties[keyName]; if (baseValue) { @@ -1090,7 +1069,7 @@ if (DEBUG) { injections[key] = { namespace: desc.namespace, source: desc.source, - specifier: `${desc.type}:${desc.name || key}` + specifier: `${desc.type}:${desc.name || key}`, }; } } diff --git a/packages/ember-runtime/lib/system/namespace.js b/packages/ember-runtime/lib/system/namespace.js index a6acc9b969c..adea33ca10b 100644 --- a/packages/ember-runtime/lib/system/namespace.js +++ b/packages/ember-runtime/lib/system/namespace.js @@ -10,7 +10,7 @@ import { get, processNamespace, processAllNamespaces, - removeNamespace + removeNamespace, } from 'ember-metal'; // Preloaded into namespaces import { getName } from 'ember-utils'; import EmberObject from './object'; @@ -57,14 +57,14 @@ const Namespace = EmberObject.extend({ destroy() { removeNamespace(this); this._super(...arguments); - } + }, }); Namespace.reopenClass({ NAMESPACES, NAMESPACES_BY_ID, processAll: processAllNamespaces, - byName: findNamespace + byName: findNamespace, }); export default Namespace; diff --git a/packages/ember-runtime/lib/system/object.js b/packages/ember-runtime/lib/system/object.js index fed8367654c..7f85b508b82 100644 --- a/packages/ember-runtime/lib/system/object.js +++ b/packages/ember-runtime/lib/system/object.js @@ -29,7 +29,7 @@ const EmberObject = CoreObject.extend(Observable, { let factory = FACTORY_FOR.get(this); return factory !== undefined && factory.fullName; - } + }, }), [OWNER]: descriptor({ @@ -48,8 +48,8 @@ const EmberObject = CoreObject.extend(Observable, { // folks calling `owner.ownerInjection()` API set(value) { this[OVERRIDE_OWNER] = value; - } - }) + }, + }), }); setName(EmberObject, 'Ember.Object'); @@ -71,7 +71,7 @@ if (DEBUG) { `You must call \`this._super(...arguments);\` when overriding \`init\` on a framework object. Please update ${this} to call \`this._super(...arguments);\` from \`init\`.`, this[INIT_WAS_CALLED] ); - }) + }), }); } diff --git a/packages/ember-runtime/lib/system/service.js b/packages/ember-runtime/lib/system/service.js index abb1744f361..2c57ae090ba 100644 --- a/packages/ember-runtime/lib/system/service.js +++ b/packages/ember-runtime/lib/system/service.js @@ -49,7 +49,7 @@ createInjectionHelper('service'); const Service = EmberObject.extend(); Service.reopenClass({ - isServiceFactory: true + isServiceFactory: true, }); export default Service; diff --git a/packages/ember-runtime/lib/system/string.js b/packages/ember-runtime/lib/system/string.js index fa13c4ea1bd..1ecabc14c9e 100644 --- a/packages/ember-runtime/lib/system/string.js +++ b/packages/ember-runtime/lib/system/string.js @@ -17,13 +17,8 @@ const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; const CAMELIZE_CACHE = new Cache(1000, key => key - .replace( - STRING_CAMELIZE_REGEXP_1, - (match, separator, chr) => (chr ? chr.toUpperCase() : '') - ) - .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => - match.toLowerCase() - ) + .replace(STRING_CAMELIZE_REGEXP_1, (match, separator, chr) => (chr ? chr.toUpperCase() : '')) + .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase()) ); const STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; @@ -31,8 +26,7 @@ const STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; const STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; const CLASSIFY_CACHE = new Cache(1000, str => { - let replace1 = (match, separator, chr) => - chr ? `_${chr.toUpperCase()}` : ''; + let replace1 = (match, separator, chr) => (chr ? `_${chr.toUpperCase()}` : ''); let replace2 = (match, initialChar, separator, chr) => initialChar + (chr ? chr.toUpperCase() : ''); let parts = str.split('/'); @@ -43,9 +37,7 @@ const CLASSIFY_CACHE = new Cache(1000, str => { } return parts .join('/') - .replace(STRING_CLASSIFY_REGEXP_3, (match /*, separator, chr */) => - match.toUpperCase() - ); + .replace(STRING_CLASSIFY_REGEXP_3, (match /*, separator, chr */) => match.toUpperCase()); }); const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; @@ -61,9 +53,7 @@ const UNDERSCORE_CACHE = new Cache(1000, str => const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g; const CAPITALIZE_CACHE = new Cache(1000, str => - str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => - match.toUpperCase() - ) + str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase()) ); const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; @@ -297,16 +287,7 @@ export default { @return {String} The capitalized string. @public */ - capitalize + capitalize, }; -export { - loc, - w, - decamelize, - dasherize, - camelize, - classify, - underscore, - capitalize -}; +export { loc, w, decamelize, dasherize, camelize, classify, underscore, capitalize }; diff --git a/packages/ember-runtime/lib/utils.js b/packages/ember-runtime/lib/utils.js index 2b0b0601894..8332e9bf43d 100644 --- a/packages/ember-runtime/lib/utils.js +++ b/packages/ember-runtime/lib/utils.js @@ -13,7 +13,7 @@ const TYPE_MAP = { '[object Date]': 'date', '[object RegExp]': 'regexp', '[object Object]': 'object', - '[object FileList]': 'filelist' + '[object FileList]': 'filelist', }; const { toString } = Object.prototype; diff --git a/packages/ember-runtime/tests/array/any-test.js b/packages/ember-runtime/tests/array/any-test.js index 12b27445f82..bd112e8c73b 100644 --- a/packages/ember-runtime/tests/array/any-test.js +++ b/packages/ember-runtime/tests/array/any-test.js @@ -31,16 +31,8 @@ class AnyTests extends AbstractTestCase { return --cnt <= 0; }); this.assert.equal(result, true, 'return value of obj.any'); - this.assert.equal( - found.length, - exp, - 'should invoke proper number of times' - ); - this.assert.deepEqual( - found, - ary.slice(0, -2), - 'items passed during any() should match' - ); + this.assert.equal(found.length, exp, 'should invoke proper number of times'); + this.assert.deepEqual(found, ary.slice(0, -2), 'items passed during any() should match'); } '@test any should return true if any object matches the callback'() { @@ -51,9 +43,7 @@ class AnyTests extends AbstractTestCase { this.assert.equal(result, true, 'return value of obj.any'); } - '@test any should produce correct results even if the matching element is undefined'( - assert - ) { + '@test any should produce correct results even if the matching element is undefined'(assert) { let obj = emberA([undefined]); let result; diff --git a/packages/ember-runtime/tests/array/every-test.js b/packages/ember-runtime/tests/array/every-test.js index faeb26e766a..2ca8d8faf89 100644 --- a/packages/ember-runtime/tests/array/every-test.js +++ b/packages/ember-runtime/tests/array/every-test.js @@ -14,11 +14,7 @@ class EveryTest extends AbstractTestCase { return true; }); this.assert.equal(result, true, 'return value of obj.every'); - this.assert.deepEqual( - found, - ary, - 'items passed during every() should match' - ); + this.assert.deepEqual(found, ary, 'items passed during every() should match'); } '@test every should stop invoking when you return false'() { @@ -34,16 +30,8 @@ class EveryTest extends AbstractTestCase { return --cnt > 0; }); this.assert.equal(result, false, 'return value of obj.every'); - this.assert.equal( - found.length, - exp, - 'should invoke proper number of times' - ); - this.assert.deepEqual( - found, - ary.slice(0, -2), - 'items passed during every() should match' - ); + this.assert.equal(found.length, exp, 'should invoke proper number of times'); + this.assert.deepEqual(found, ary.slice(0, -2), 'items passed during every() should match'); } } @@ -51,7 +39,7 @@ class IsEveryTest extends AbstractTestCase { '@test should return true of every property matches'() { let obj = this.newObject([ { foo: 'foo', bar: 'BAZ' }, - EmberObject.create({ foo: 'foo', bar: 'bar' }) + EmberObject.create({ foo: 'foo', bar: 'bar' }), ]); this.assert.equal(obj.isEvery('foo', 'foo'), true, 'isEvery(foo)'); @@ -61,7 +49,7 @@ class IsEveryTest extends AbstractTestCase { '@test should return true of every property is true'() { let obj = this.newObject([ { foo: 'foo', bar: true }, - EmberObject.create({ foo: 'bar', bar: false }) + EmberObject.create({ foo: 'bar', bar: false }), ]); // different values - all eval to true @@ -72,7 +60,7 @@ class IsEveryTest extends AbstractTestCase { '@test should return true if every property matches null'() { let obj = this.newObject([ { foo: null, bar: 'BAZ' }, - EmberObject.create({ foo: null, bar: null }) + EmberObject.create({ foo: null, bar: null }), ]); this.assert.equal(obj.isEvery('foo', null), true, "isEvery('foo', null)"); @@ -82,19 +70,11 @@ class IsEveryTest extends AbstractTestCase { '@test should return true if every property is undefined'() { let obj = this.newObject([ { foo: undefined, bar: 'BAZ' }, - EmberObject.create({ bar: undefined }) + EmberObject.create({ bar: undefined }), ]); - this.assert.equal( - obj.isEvery('foo', undefined), - true, - "isEvery('foo', undefined)" - ); - this.assert.equal( - obj.isEvery('bar', undefined), - false, - "isEvery('bar', undefined)" - ); + this.assert.equal(obj.isEvery('foo', undefined), true, "isEvery('foo', undefined)"); + this.assert.equal(obj.isEvery('bar', undefined), false, "isEvery('bar', undefined)"); } } diff --git a/packages/ember-runtime/tests/array/filter-test.js b/packages/ember-runtime/tests/array/filter-test.js index aeeb717272c..d5bc4891eaa 100644 --- a/packages/ember-runtime/tests/array/filter-test.js +++ b/packages/ember-runtime/tests/array/filter-test.js @@ -16,11 +16,7 @@ class FilterTest extends AbstractTestCase { return --cnt >= 0; }); this.assert.deepEqual(found, ary, 'should have invoked on each item'); - this.assert.deepEqual( - result, - ary.slice(0, -2), - 'filtered array should exclude items' - ); + this.assert.deepEqual(result, ary.slice(0, -2), 'filtered array should exclude items'); } } @@ -28,28 +24,18 @@ class FilterByTest extends AbstractTestCase { '@test should filter based on object'() { let obj, ary; - ary = [ - { foo: 'foo', bar: 'BAZ' }, - EmberObject.create({ foo: 'foo', bar: 'bar' }) - ]; + ary = [{ foo: 'foo', bar: 'BAZ' }, EmberObject.create({ foo: 'foo', bar: 'bar' })]; obj = this.newObject(ary); this.assert.deepEqual(obj.filterBy('foo', 'foo'), ary, 'filterBy(foo)'); - this.assert.deepEqual( - obj.filterBy('bar', 'bar'), - [ary[1]], - 'filterBy(bar)' - ); + this.assert.deepEqual(obj.filterBy('bar', 'bar'), [ary[1]], 'filterBy(bar)'); } '@test should include in result if property is true'() { let obj, ary; - ary = [ - { foo: 'foo', bar: true }, - EmberObject.create({ foo: 'bar', bar: false }) - ]; + ary = [{ foo: 'foo', bar: true }, EmberObject.create({ foo: 'bar', bar: false })]; obj = this.newObject(ary); @@ -65,16 +51,12 @@ class FilterByTest extends AbstractTestCase { { name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, - EmberObject.create({ name: 'obj4', foo: 3 }) + EmberObject.create({ name: 'obj4', foo: 3 }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.filterBy('foo', 3), - [ary[0], ary[3]], - "filterBy('foo', 3)')" - ); + this.assert.deepEqual(obj.filterBy('foo', 3), [ary[0], ary[3]], "filterBy('foo', 3)')"); } '@test should correctly filter null second argument'() { @@ -84,33 +66,22 @@ class FilterByTest extends AbstractTestCase { { name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, - EmberObject.create({ name: 'obj4', foo: 3 }) + EmberObject.create({ name: 'obj4', foo: 3 }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.filterBy('foo', null), - [ary[1], ary[2]], - "filterBy('foo', 3)')" - ); + this.assert.deepEqual(obj.filterBy('foo', null), [ary[1], ary[2]], "filterBy('foo', 3)')"); } '@test should not return all objects on undefined second argument'() { let obj, ary; - ary = [ - { name: 'obj1', foo: 3 }, - EmberObject.create({ name: 'obj2', foo: 2 }) - ]; + ary = [{ name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: 2 })]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.filterBy('foo', undefined), - [], - "filterBy('foo', 3)')" - ); + this.assert.deepEqual(obj.filterBy('foo', undefined), [], "filterBy('foo', 3)')"); } '@test should correctly filter explicit undefined second argument'() { @@ -122,16 +93,12 @@ class FilterByTest extends AbstractTestCase { { name: 'obj3', foo: undefined }, EmberObject.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, - EmberObject.create({ name: 'obj6' }) + EmberObject.create({ name: 'obj6' }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.filterBy('foo', undefined), - ary.slice(2), - "filterBy('foo', 3)')" - ); + this.assert.deepEqual(obj.filterBy('foo', undefined), ary.slice(2), "filterBy('foo', 3)')"); } '@test should not match undefined properties without second argument'() { @@ -143,16 +110,12 @@ class FilterByTest extends AbstractTestCase { { name: 'obj3', foo: undefined }, EmberObject.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, - EmberObject.create({ name: 'obj6' }) + EmberObject.create({ name: 'obj6' }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.filterBy('foo'), - ary.slice(0, 2), - "filterBy('foo', 3)')" - ); + this.assert.deepEqual(obj.filterBy('foo'), ary.slice(0, 2), "filterBy('foo', 3)')"); } } diff --git a/packages/ember-runtime/tests/array/find-test.js b/packages/ember-runtime/tests/array/find-test.js index e9bd57bf6b1..1fc093d35a5 100644 --- a/packages/ember-runtime/tests/array/find-test.js +++ b/packages/ember-runtime/tests/array/find-test.js @@ -14,11 +14,7 @@ class FindTests extends AbstractTestCase { return false; }); this.assert.equal(result, undefined, 'return value of obj.find'); - this.assert.deepEqual( - found, - ary, - 'items passed during find() should match' - ); + this.assert.deepEqual(found, ary, 'items passed during find() should match'); } '@test every should stop invoking when you return true'() { @@ -34,16 +30,8 @@ class FindTests extends AbstractTestCase { return --cnt >= 0; }); this.assert.equal(result, ary[exp - 1], 'return value of obj.find'); - this.assert.equal( - found.length, - exp, - 'should invoke proper number of times' - ); - this.assert.deepEqual( - found, - ary.slice(0, -2), - 'items passed during find() should match' - ); + this.assert.equal(found.length, exp, 'should invoke proper number of times'); + this.assert.deepEqual(found, ary.slice(0, -2), 'items passed during find() should match'); } } @@ -51,10 +39,7 @@ class FindByTests extends AbstractTestCase { '@test should return first object of property matches'() { let ary, obj; - ary = [ - { foo: 'foo', bar: 'BAZ' }, - EmberObject.create({ foo: 'foo', bar: 'bar' }) - ]; + ary = [{ foo: 'foo', bar: 'BAZ' }, EmberObject.create({ foo: 'foo', bar: 'bar' })]; obj = this.newObject(ary); @@ -65,10 +50,7 @@ class FindByTests extends AbstractTestCase { '@test should return first object with truthy prop'() { let ary, obj; - ary = [ - { foo: 'foo', bar: false }, - EmberObject.create({ foo: 'bar', bar: true }) - ]; + ary = [{ foo: 'foo', bar: false }, EmberObject.create({ foo: 'bar', bar: true })]; obj = this.newObject(ary); @@ -80,10 +62,7 @@ class FindByTests extends AbstractTestCase { '@test should return first null property match'() { let ary, obj; - ary = [ - { foo: null, bar: 'BAZ' }, - EmberObject.create({ foo: null, bar: null }) - ]; + ary = [{ foo: null, bar: 'BAZ' }, EmberObject.create({ foo: null, bar: null })]; obj = this.newObject(ary); @@ -98,16 +77,8 @@ class FindByTests extends AbstractTestCase { obj = this.newObject(ary); - this.assert.equal( - obj.findBy('foo', undefined), - ary[0], - "findBy('foo', undefined)" - ); - this.assert.equal( - obj.findBy('bar', undefined), - ary[1], - "findBy('bar', undefined)" - ); + this.assert.equal(obj.findBy('foo', undefined), ary[0], "findBy('foo', undefined)"); + this.assert.equal(obj.findBy('bar', undefined), ary[1], "findBy('bar', undefined)"); } } diff --git a/packages/ember-runtime/tests/array/forEach-test.js b/packages/ember-runtime/tests/array/forEach-test.js index 45dc3484de8..8fe848af3fd 100644 --- a/packages/ember-runtime/tests/array/forEach-test.js +++ b/packages/ember-runtime/tests/array/forEach-test.js @@ -10,11 +10,7 @@ class ForEachTests extends AbstractTestCase { let found = []; obj.forEach(i => found.push(i)); - this.assert.deepEqual( - found, - ary, - 'items passed during forEach should match' - ); + this.assert.deepEqual(found, ary, 'items passed during forEach should match'); } '@test forEach should iterate over list after mutation'() { @@ -28,22 +24,14 @@ class ForEachTests extends AbstractTestCase { let found = []; obj.forEach(i => found.push(i)); - this.assert.deepEqual( - found, - ary, - 'items passed during forEach should match' - ); + this.assert.deepEqual(found, ary, 'items passed during forEach should match'); this.mutate(obj); ary = this.toArray(obj); found = []; obj.forEach(i => found.push(i)); - this.assert.deepEqual( - found, - ary, - 'items passed during forEach should match' - ); + this.assert.deepEqual(found, ary, 'items passed during forEach should match'); } '@test 2nd target parameter'() { @@ -59,11 +47,7 @@ class ForEachTests extends AbstractTestCase { }); obj.forEach(() => { - this.assert.equal( - guidFor(this), - guidFor(target), - 'should pass target as this if context' - ); + this.assert.equal(guidFor(this), guidFor(target), 'should pass target as this if context'); }, target); } diff --git a/packages/ember-runtime/tests/array/includes-test.js b/packages/ember-runtime/tests/array/includes-test.js index a2c411f56c7..c8119057d9e 100644 --- a/packages/ember-runtime/tests/array/includes-test.js +++ b/packages/ember-runtime/tests/array/includes-test.js @@ -6,43 +6,23 @@ class IncludesTests extends AbstractTestCase { let data = newFixture(3); let obj = this.newObject(data); - this.assert.equal( - obj.includes(data[1], 1), - true, - 'should return true if included' - ); - this.assert.equal( - obj.includes(data[0], 1), - false, - 'should return false if not included' - ); + this.assert.equal(obj.includes(data[1], 1), true, 'should return true if included'); + this.assert.equal(obj.includes(data[0], 1), false, 'should return false if not included'); } '@test includes returns correct value if startAt is negative'() { let data = newFixture(3); let obj = this.newObject(data); - this.assert.equal( - obj.includes(data[1], -2), - true, - 'should return true if included' - ); - this.assert.equal( - obj.includes(data[0], -2), - false, - 'should return false if not included' - ); + this.assert.equal(obj.includes(data[1], -2), true, 'should return true if included'); + this.assert.equal(obj.includes(data[0], -2), false, 'should return false if not included'); } '@test includes returns true if startAt + length is still negative'() { let data = newFixture(1); let obj = this.newObject(data); - this.assert.equal( - obj.includes(data[0], -2), - true, - 'should return true if included' - ); + this.assert.equal(obj.includes(data[0], -2), true, 'should return true if included'); this.assert.equal( obj.includes(newFixture(1), -2), false, @@ -54,11 +34,7 @@ class IncludesTests extends AbstractTestCase { let data = newFixture(1); let obj = this.newObject(data); - this.assert.equal( - obj.includes(data[0], 2), - false, - 'should return false if startAt >= length' - ); + this.assert.equal(obj.includes(data[0], 2), false, 'should return false if startAt >= length'); this.assert.equal( obj.includes(newFixture(1), 2), false, diff --git a/packages/ember-runtime/tests/array/invoke-test.js b/packages/ember-runtime/tests/array/invoke-test.js index 019f2e31eec..c5bdbce7d96 100644 --- a/packages/ember-runtime/tests/array/invoke-test.js +++ b/packages/ember-runtime/tests/array/invoke-test.js @@ -17,7 +17,7 @@ class InvokeTests extends AbstractTestCase { // NOTE: does not impl foo - invoke should just skip EmberObject.create({ bar: F }), - { foo: F } + { foo: F }, ]; obj = this.newObject(ary); diff --git a/packages/ember-runtime/tests/array/isAny-test.js b/packages/ember-runtime/tests/array/isAny-test.js index 3ef9b64d072..9846fd45cb2 100644 --- a/packages/ember-runtime/tests/array/isAny-test.js +++ b/packages/ember-runtime/tests/array/isAny-test.js @@ -6,7 +6,7 @@ class IsAnyTests extends AbstractTestCase { '@test should return true of any property matches'() { let obj = this.newObject([ { foo: 'foo', bar: 'BAZ' }, - EmberObject.create({ foo: 'foo', bar: 'bar' }) + EmberObject.create({ foo: 'foo', bar: 'bar' }), ]); this.assert.equal(obj.isAny('foo', 'foo'), true, 'isAny(foo)'); @@ -17,7 +17,7 @@ class IsAnyTests extends AbstractTestCase { '@test should return true of any property is true'() { let obj = this.newObject([ { foo: 'foo', bar: true }, - EmberObject.create({ foo: 'bar', bar: false }) + EmberObject.create({ foo: 'bar', bar: false }), ]); // different values - all eval to true @@ -29,7 +29,7 @@ class IsAnyTests extends AbstractTestCase { '@test should return true if any property matches null'() { let obj = this.newObject([ { foo: null, bar: 'bar' }, - EmberObject.create({ foo: 'foo', bar: null }) + EmberObject.create({ foo: 'foo', bar: null }), ]); this.assert.equal(obj.isAny('foo', null), true, "isAny('foo', null)"); @@ -37,21 +37,10 @@ class IsAnyTests extends AbstractTestCase { } '@test should return true if any property is undefined'() { - let obj = this.newObject([ - { foo: undefined, bar: 'bar' }, - EmberObject.create({ foo: 'foo' }) - ]); + let obj = this.newObject([{ foo: undefined, bar: 'bar' }, EmberObject.create({ foo: 'foo' })]); - this.assert.equal( - obj.isAny('foo', undefined), - true, - "isAny('foo', undefined)" - ); - this.assert.equal( - obj.isAny('bar', undefined), - true, - "isAny('bar', undefined)" - ); + this.assert.equal(obj.isAny('foo', undefined), true, "isAny('foo', undefined)"); + this.assert.equal(obj.isAny('bar', undefined), true, "isAny('bar', undefined)"); } '@test should not match undefined properties without second argument'() { diff --git a/packages/ember-runtime/tests/array/lastIndexOf-test.js b/packages/ember-runtime/tests/array/lastIndexOf-test.js index 9ce1fa704dd..b03913c27c9 100644 --- a/packages/ember-runtime/tests/array/lastIndexOf-test.js +++ b/packages/ember-runtime/tests/array/lastIndexOf-test.js @@ -49,11 +49,7 @@ class LastIndexOfTests extends AbstractTestCase { let obj = this.newObject(newFixture(3)); let foo = {}; - this.assert.equal( - obj.lastIndexOf(foo), - -1, - 'obj.lastIndexOf(foo) should be -1' - ); + this.assert.equal(obj.lastIndexOf(foo), -1, 'obj.lastIndexOf(foo) should be -1'); } '@test should return -1 when no match is found even startAt search location is equal to length'() { diff --git a/packages/ember-runtime/tests/array/map-test.js b/packages/ember-runtime/tests/array/map-test.js index 1977be43b0e..c0b1dce1acb 100644 --- a/packages/ember-runtime/tests/array/map-test.js +++ b/packages/ember-runtime/tests/array/map-test.js @@ -26,20 +26,12 @@ class MapTests extends AbstractTestCase { let found; found = obj.map(mapFunc); - this.assert.deepEqual( - found, - ary, - 'items passed during forEach should match' - ); + this.assert.deepEqual(found, ary, 'items passed during forEach should match'); this.mutate(obj); ary = this.toArray(obj).map(mapFunc); found = obj.map(mapFunc); - this.assert.deepEqual( - found, - ary, - 'items passed during forEach should match' - ); + this.assert.deepEqual(found, ary, 'items passed during forEach should match'); } '@test 2nd target parameter'() { @@ -55,11 +47,7 @@ class MapTests extends AbstractTestCase { }); obj.map(() => { - this.assert.equal( - guidFor(this), - guidFor(target), - 'should pass target as this if context' - ); + this.assert.equal(guidFor(this), guidFor(target), 'should pass target as this if context'); }, target); } diff --git a/packages/ember-runtime/tests/array/objectAt-test.js b/packages/ember-runtime/tests/array/objectAt-test.js index 18e09d81659..ff2572b65a8 100644 --- a/packages/ember-runtime/tests/array/objectAt-test.js +++ b/packages/ember-runtime/tests/array/objectAt-test.js @@ -8,11 +8,7 @@ class ObjectAtTests extends AbstractTestCase { let len = expected.length; for (let idx = 0; idx < len; idx++) { - this.assert.equal( - obj.objectAt(idx), - expected[idx], - `obj.objectAt(${idx}) should match` - ); + this.assert.equal(obj.objectAt(idx), expected[idx], `obj.objectAt(${idx}) should match`); } } diff --git a/packages/ember-runtime/tests/array/reduce-test.js b/packages/ember-runtime/tests/array/reduce-test.js index 05b9d842ebf..cf549f7ce08 100644 --- a/packages/ember-runtime/tests/array/reduce-test.js +++ b/packages/ember-runtime/tests/array/reduce-test.js @@ -10,19 +10,13 @@ class ReduceTests extends AbstractTestCase { '@test passes index of item to callback'() { let obj = this.newObject([1, 2, 3]); - let res = obj.reduce( - (previousValue, item, index) => previousValue + index, - 0 - ); + let res = obj.reduce((previousValue, item, index) => previousValue + index, 0); this.assert.equal(res, 3); } '@test passes enumerable object to callback'() { let obj = this.newObject([1, 2, 3]); - let res = obj.reduce( - (previousValue, item, index, enumerable) => enumerable, - 0 - ); + let res = obj.reduce((previousValue, item, index, enumerable) => enumerable, 0); this.assert.equal(res, obj); } } diff --git a/packages/ember-runtime/tests/array/reject-test.js b/packages/ember-runtime/tests/array/reject-test.js index a88784f68ff..96156639e12 100644 --- a/packages/ember-runtime/tests/array/reject-test.js +++ b/packages/ember-runtime/tests/array/reject-test.js @@ -28,28 +28,18 @@ class RejectByTest extends AbstractTestCase { '@test should reject based on object'() { let obj, ary; - ary = [ - { foo: 'foo', bar: 'BAZ' }, - EmberObject.create({ foo: 'foo', bar: 'bar' }) - ]; + ary = [{ foo: 'foo', bar: 'BAZ' }, EmberObject.create({ foo: 'foo', bar: 'bar' })]; obj = this.newObject(ary); this.assert.deepEqual(obj.rejectBy('foo', 'foo'), [], 'rejectBy(foo)'); - this.assert.deepEqual( - obj.rejectBy('bar', 'bar'), - [ary[0]], - 'rejectBy(bar)' - ); + this.assert.deepEqual(obj.rejectBy('bar', 'bar'), [ary[0]], 'rejectBy(bar)'); } '@test should include in result if property is false'() { let obj, ary; - ary = [ - { foo: false, bar: true }, - EmberObject.create({ foo: false, bar: false }) - ]; + ary = [{ foo: false, bar: true }, EmberObject.create({ foo: false, bar: false })]; obj = this.newObject(ary); @@ -64,16 +54,12 @@ class RejectByTest extends AbstractTestCase { { name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: 2 }), { name: 'obj3', foo: 2 }, - EmberObject.create({ name: 'obj4', foo: 3 }) + EmberObject.create({ name: 'obj4', foo: 3 }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.rejectBy('foo', 3), - [ary[1], ary[2]], - "rejectBy('foo', 3)')" - ); + this.assert.deepEqual(obj.rejectBy('foo', 3), [ary[1], ary[2]], "rejectBy('foo', 3)')"); } '@test should correctly reject null second argument'() { @@ -83,33 +69,22 @@ class RejectByTest extends AbstractTestCase { { name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: null }), { name: 'obj3', foo: null }, - EmberObject.create({ name: 'obj4', foo: 3 }) + EmberObject.create({ name: 'obj4', foo: 3 }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.rejectBy('foo', null), - [ary[0], ary[3]], - "rejectBy('foo', null)')" - ); + this.assert.deepEqual(obj.rejectBy('foo', null), [ary[0], ary[3]], "rejectBy('foo', null)')"); } '@test should correctly reject undefined second argument'() { let obj, ary; - ary = [ - { name: 'obj1', foo: 3 }, - EmberObject.create({ name: 'obj2', foo: 2 }) - ]; + ary = [{ name: 'obj1', foo: 3 }, EmberObject.create({ name: 'obj2', foo: 2 })]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.rejectBy('bar', undefined), - [], - "rejectBy('bar', undefined)')" - ); + this.assert.deepEqual(obj.rejectBy('bar', undefined), [], "rejectBy('bar', undefined)')"); } '@test should correctly reject explicit undefined second argument'() { @@ -121,7 +96,7 @@ class RejectByTest extends AbstractTestCase { { name: 'obj3', foo: undefined }, EmberObject.create({ name: 'obj4', foo: undefined }), { name: 'obj5' }, - EmberObject.create({ name: 'obj6' }) + EmberObject.create({ name: 'obj6' }), ]; obj = this.newObject(ary); @@ -146,16 +121,12 @@ class RejectByTest extends AbstractTestCase { { name: 'obj7', foo: null }, EmberObject.create({ name: 'obj8', foo: null }), { name: 'obj9', foo: false }, - EmberObject.create({ name: 'obj10', foo: false }) + EmberObject.create({ name: 'obj10', foo: false }), ]; obj = this.newObject(ary); - this.assert.deepEqual( - obj.rejectBy('foo'), - ary.slice(2), - "rejectBy('foo')')" - ); + this.assert.deepEqual(obj.rejectBy('foo'), ary.slice(2), "rejectBy('foo')')"); } } diff --git a/packages/ember-runtime/tests/array/uniq-test.js b/packages/ember-runtime/tests/array/uniq-test.js index f064ed8732e..59b43afeef2 100644 --- a/packages/ember-runtime/tests/array/uniq-test.js +++ b/packages/ember-runtime/tests/array/uniq-test.js @@ -12,11 +12,7 @@ class UniqTests extends AbstractTestCase { ret = obj.uniq(); this.assert.deepEqual(this.toArray(ret), after, 'should have removed item'); - this.assert.deepEqual( - this.toArray(obj), - before, - 'should not have changed original' - ); + this.assert.deepEqual(this.toArray(obj), before, 'should not have changed original'); } '@test should return duplicate of same content if no duplicates found'() { @@ -24,11 +20,7 @@ class UniqTests extends AbstractTestCase { obj = this.newObject(newFixture(3)); ret = obj.uniq(item); this.assert.ok(ret !== obj, 'should not be same object'); - this.assert.deepEqual( - this.toArray(ret), - this.toArray(obj), - 'should be the same content' - ); + this.assert.deepEqual(this.toArray(ret), this.toArray(obj), 'should be the same content'); } } diff --git a/packages/ember-runtime/tests/array/uniqBy-test.js b/packages/ember-runtime/tests/array/uniqBy-test.js index f04613a591c..d9c0531cf39 100644 --- a/packages/ember-runtime/tests/array/uniqBy-test.js +++ b/packages/ember-runtime/tests/array/uniqBy-test.js @@ -6,12 +6,9 @@ class UniqByTests extends AbstractTestCase { let numbers = this.newObject([ { id: 1, value: 'one' }, { id: 2, value: 'two' }, - { id: 1, value: 'one' } - ]); - this.assert.deepEqual(numbers.uniqBy('id'), [ { id: 1, value: 'one' }, - { id: 2, value: 'two' } ]); + this.assert.deepEqual(numbers.uniqBy('id'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); } } diff --git a/packages/ember-runtime/tests/array/without-test.js b/packages/ember-runtime/tests/array/without-test.js index bfbdc78b326..ce0479234a5 100644 --- a/packages/ember-runtime/tests/array/without-test.js +++ b/packages/ember-runtime/tests/array/without-test.js @@ -11,11 +11,7 @@ class WithoutTests extends AbstractTestCase { ret = obj.without(before[1]); this.assert.deepEqual(this.toArray(ret), after, 'should have removed item'); - this.assert.deepEqual( - this.toArray(obj), - before, - 'should not have changed original' - ); + this.assert.deepEqual(this.toArray(obj), before, 'should not have changed original'); } '@test should remove NaN value'() { diff --git a/packages/ember-runtime/tests/computed/computed_macros_test.js b/packages/ember-runtime/tests/computed/computed_macros_test.js index 0d72cf31c57..7efa3116969 100644 --- a/packages/ember-runtime/tests/computed/computed_macros_test.js +++ b/packages/ember-runtime/tests/computed/computed_macros_test.js @@ -14,7 +14,7 @@ import { readOnly, deprecatingAlias, and, - or + or, } from '../../computed/computed_macros'; import EmberObject from '../../system/object'; @@ -30,35 +30,19 @@ moduleFor( lannisters: null, bestLannisterUnspecified: empty('bestLannister'), - noLannistersKnown: empty('lannisters') + noLannistersKnown: empty('lannisters'), }).create({ - lannisters: emberA() + lannisters: emberA(), }); - assert.equal( - get(obj, 'bestLannisterUnspecified'), - true, - 'bestLannister initially empty' - ); - assert.equal( - get(obj, 'noLannistersKnown'), - true, - 'lannisters initially empty' - ); + assert.equal(get(obj, 'bestLannisterUnspecified'), true, 'bestLannister initially empty'); + assert.equal(get(obj, 'noLannistersKnown'), true, 'lannisters initially empty'); get(obj, 'lannisters').pushObject('Tyrion'); set(obj, 'bestLannister', 'Tyrion'); - assert.equal( - get(obj, 'bestLannisterUnspecified'), - false, - 'empty respects strings' - ); - assert.equal( - get(obj, 'noLannistersKnown'), - false, - 'empty respects array mutations' - ); + assert.equal(get(obj, 'bestLannisterUnspecified'), false, 'empty respects strings'); + assert.equal(get(obj, 'noLannistersKnown'), false, 'empty respects array mutations'); } ['@test Ember.computed.notEmpty'](assert) { @@ -67,35 +51,19 @@ moduleFor( lannisters: null, bestLannisterSpecified: notEmpty('bestLannister'), - LannistersKnown: notEmpty('lannisters') + LannistersKnown: notEmpty('lannisters'), }).create({ - lannisters: emberA() + lannisters: emberA(), }); - assert.equal( - get(obj, 'bestLannisterSpecified'), - false, - 'bestLannister initially empty' - ); - assert.equal( - get(obj, 'LannistersKnown'), - false, - 'lannisters initially empty' - ); + assert.equal(get(obj, 'bestLannisterSpecified'), false, 'bestLannister initially empty'); + assert.equal(get(obj, 'LannistersKnown'), false, 'lannisters initially empty'); get(obj, 'lannisters').pushObject('Tyrion'); set(obj, 'bestLannister', 'Tyrion'); - assert.equal( - get(obj, 'bestLannisterSpecified'), - true, - 'empty respects strings' - ); - assert.equal( - get(obj, 'LannistersKnown'), - true, - 'empty respects array mutations' - ); + assert.equal(get(obj, 'bestLannisterSpecified'), true, 'empty respects strings'); + assert.equal(get(obj, 'LannistersKnown'), true, 'empty respects array mutations'); } ['@test computed.not'](assert) { @@ -183,7 +151,7 @@ moduleFor( }, set: function() { return constantValue; - } + }, }) ); defineProperty(obj, 'aliased', alias('original')); @@ -319,11 +287,7 @@ moduleFor( set(obj, 'one', false); - assert.equal( - get(obj, 'oneTwoThree'), - false, - 'one and not two and not three' - ); + assert.equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); set(obj, 'one', true); set(obj, 'two', 2); @@ -340,11 +304,7 @@ moduleFor( set(obj, 'one', false); - assert.equal( - get(obj, 'oneTwoThree'), - false, - 'one and not two and not three' - ); + assert.equal(get(obj, 'oneTwoThree'), false, 'one and not two and not three'); set(obj, 'one', true); set(obj, 'two', 2); @@ -369,11 +329,7 @@ moduleFor( set(obj, 'two', null); - assert.equal( - get(obj, 'oneOrTwo'), - null, - 'returns last falsy value as in ||' - ); + assert.equal(get(obj, 'oneOrTwo'), null, 'returns last falsy value as in ||'); set(obj, 'two', true); @@ -404,11 +360,7 @@ moduleFor( set(obj, 'three', null); - assert.equal( - get(obj, 'oneTwoThree'), - null, - 'returns last falsy value as in ||' - ); + assert.equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); set(obj, 'two', true); @@ -439,11 +391,7 @@ moduleFor( set(obj, 'three', null); - assert.equal( - get(obj, 'oneTwoThree'), - null, - 'returns last falsy value as in ||' - ); + assert.equal(get(obj, 'oneTwoThree'), null, 'returns last falsy value as in ||'); set(obj, 'two', true); @@ -468,7 +416,7 @@ moduleFor( ['@test computed.oneWay'](assert) { let obj = { firstName: 'Teddy', - lastName: 'Zeenny' + lastName: 'Zeenny', }; defineProperty(obj, 'nickName', oneWay('firstName')); @@ -492,7 +440,7 @@ moduleFor( ['@test computed.readOnly'](assert) { let obj = { firstName: 'Teddy', - lastName: 'Zeenny' + lastName: 'Zeenny', }; defineProperty(obj, 'nickName', readOnly('firstName')); diff --git a/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js b/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js index e01a84bbd1d..90afa5561ab 100644 --- a/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js +++ b/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js @@ -6,7 +6,7 @@ import { set, addObserver, computed, - observer + observer, } from 'ember-metal'; import EmberObject from '../../system/object'; import ObjectProxy from '../../system/object_proxy'; @@ -24,7 +24,7 @@ import { uniqBy, union, intersect, - collect + collect, } from '../../computed/reduce_computed_macros'; import { isArray } from '../../utils'; import { A as emberA, removeAt } from '../../mixins/array'; @@ -39,15 +39,12 @@ moduleFor( obj = EmberObject.extend({ mapped: map('array.@each.v', item => item.v), mappedObjects: map('arrayObjects.@each.v', item => ({ - name: item.v.name - })) + name: item.v.name, + })), }).create({ - arrayObjects: emberA([ - { v: { name: 'Robert' } }, - { v: { name: 'Leanna' } } - ]), + arrayObjects: emberA([{ v: { name: 'Robert' } }, { v: { name: 'Leanna' } }]), - array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]), }); } @@ -77,9 +74,9 @@ moduleFor( let array = emberA(); obj = EmberObject.extend({ - mapped: map('array', item => item.toUpperCase()) + mapped: map('array', item => item.toUpperCase()), }).create({ - array + array, }); array.unshiftObject('c'); @@ -103,9 +100,9 @@ moduleFor( }), upperCase(string) { return string.toUpperCase(); - } + }, }).create({ - array: ['a', 'b', 'c'] + array: ['a', 'b', 'c'], }); assert.deepEqual( @@ -119,47 +116,34 @@ moduleFor( let array = ['a', 'b', 'c']; obj = EmberObject.extend({ - mapped: map('array', (item, index) => index) + mapped: map('array', (item, index) => index), }).create({ - array + array, }); - assert.deepEqual( - obj.get('mapped'), - [0, 1, 2], - 'index is passed to callback correctly' - ); + assert.deepEqual(obj.get('mapped'), [0, 1, 2], 'index is passed to callback correctly'); } ['@test it maps objects'](assert) { - assert.deepEqual(obj.get('mappedObjects'), [ - { name: 'Robert' }, - { name: 'Leanna' } - ]); + assert.deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }]); obj.get('arrayObjects').pushObject({ - v: { name: 'Eddard' } + v: { name: 'Eddard' }, }); assert.deepEqual(obj.get('mappedObjects'), [ { name: 'Robert' }, { name: 'Leanna' }, - { name: 'Eddard' } + { name: 'Eddard' }, ]); removeAt(obj.get('arrayObjects'), 1); - assert.deepEqual(obj.get('mappedObjects'), [ - { name: 'Robert' }, - { name: 'Eddard' } - ]); + assert.deepEqual(obj.get('mappedObjects'), [{ name: 'Robert' }, { name: 'Eddard' }]); set(obj.get('arrayObjects')[0], 'v', { name: 'Stannis' }); - assert.deepEqual(obj.get('mappedObjects'), [ - { name: 'Stannis' }, - { name: 'Eddard' } - ]); + assert.deepEqual(obj.get('mappedObjects'), [{ name: 'Stannis' }, { name: 'Eddard' }]); } ['@test it maps unshifted objects with property observers'](assert) { @@ -167,9 +151,9 @@ moduleFor( let cObj = { v: 'c' }; obj = EmberObject.extend({ - mapped: map('array.@each.v', item => get(item, 'v').toUpperCase()) + mapped: map('array.@each.v', item => get(item, 'v').toUpperCase()), }).create({ - array + array, }); array.unshiftObject(cObj); @@ -178,11 +162,7 @@ moduleFor( set(cObj, 'v', 'd'); - assert.deepEqual( - array.mapBy('v'), - ['a', 'b', 'd'], - 'precond - unmapped array is correct' - ); + assert.deepEqual(array.mapBy('v'), ['a', 'b', 'd'], 'precond - unmapped array is correct'); assert.deepEqual( obj.get('mapped'), ['A', 'B', 'D'], @@ -197,9 +177,9 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - mapped: mapBy('array', 'v') + mapped: mapBy('array', 'v'), }).create({ - array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]), }); } @@ -244,9 +224,9 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - filtered: filter('array', item => item % 2 === 0) + filtered: filter('array', item => item % 2 === 0), }).create({ - array: emberA([1, 2, 3, 4, 5, 6, 7, 8]) + array: emberA([1, 2, 3, 4, 5, 6, 7, 8]), }); } @@ -270,16 +250,12 @@ moduleFor( ['@test it passes the index to the callback'](assert) { obj = EmberObject.extend({ - filtered: filter('array', (item, index) => index === 1) + filtered: filter('array', (item, index) => index === 1), }).create({ - array: ['a', 'b', 'c'] + array: ['a', 'b', 'c'], }); - assert.deepEqual( - get(obj, 'filtered'), - ['b'], - 'index is passed to callback correctly' - ); + assert.deepEqual(get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); } ['@test it has the correct `this`'](assert) { @@ -290,33 +266,22 @@ moduleFor( }), isOne(value) { return value === 1; - } + }, }).create({ - array: ['a', 'b', 'c'] + array: ['a', 'b', 'c'], }); - assert.deepEqual( - get(obj, 'filtered'), - ['b'], - 'index is passed to callback correctly' - ); + assert.deepEqual(get(obj, 'filtered'), ['b'], 'index is passed to callback correctly'); } ['@test it passes the array to the callback'](assert) { obj = EmberObject.extend({ - filtered: filter( - 'array', - (item, index, array) => index === get(array, 'length') - 2 - ) + filtered: filter('array', (item, index, array) => index === get(array, 'length') - 2), }).create({ - array: emberA(['a', 'b', 'c']) + array: emberA(['a', 'b', 'c']), }); - assert.deepEqual( - obj.get('filtered'), - ['b'], - 'array is passed to callback correctly' - ); + assert.deepEqual(obj.get('filtered'), ['b'], 'array is passed to callback correctly'); } ['@test it caches properly'](assert) { @@ -385,11 +350,7 @@ moduleFor( array.removeObject(5); array.removeObject(7); - assert.deepEqual( - obj.get('filtered'), - [], - 'filtered array cleared correctly' - ); + assert.deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); } ['@test the dependent array can be `clear`ed directly (#3272)'](assert) { @@ -401,11 +362,7 @@ moduleFor( obj.get('array').clear(); - assert.deepEqual( - obj.get('filtered'), - [], - 'filtered array cleared correctly' - ); + assert.deepEqual(obj.get('filtered'), [], 'filtered array cleared correctly'); } ['@test it updates as the array is replaced'](assert) { @@ -430,9 +387,9 @@ moduleFor( obj = EmberObject.extend({ filtered: filter('items.@each.{prop}', function(item) { return item.get('prop') === true; - }) + }), }).create({ - items: emberA([item]) + items: emberA([item]), }); assert.deepEqual(obj.get('filtered'), [item]); @@ -451,14 +408,14 @@ moduleFor( obj = EmberObject.extend({ a1s: filterBy('array', 'a', 1), as: filterBy('array', 'a'), - bs: filterBy('array', 'b') + bs: filterBy('array', 'b'), }).create({ array: emberA([ { name: 'one', a: 1, b: false }, { name: 'two', a: 2, b: false }, { name: 'three', a: 1, b: true }, - { name: 'four', b: true } - ]) + { name: 'four', b: true }, + ]), }); } @@ -478,11 +435,7 @@ moduleFor( ['one', 'two', 'three'], 'properties can be filtered by existence' ); - assert.deepEqual( - obj.get('bs').mapBy('name'), - ['three', 'four'], - 'booleans can be filtered' - ); + assert.deepEqual(obj.get('bs').mapBy('name'), ['three', 'four'], 'booleans can be filtered'); set(obj.get('array')[0], 'a', undefined); set(obj.get('array')[3], 'a', true); @@ -577,9 +530,9 @@ moduleFor( ['@test properties values can be replaced'](assert) { obj = EmberObject.extend({ a1s: filterBy('array', 'a', 1), - a1bs: filterBy('a1s', 'b') + a1bs: filterBy('a1s', 'b'), }).create({ - array: [] + array: [], }); assert.deepEqual( @@ -607,11 +560,11 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - union: macro('array', 'array2', 'array3') + union: macro('array', 'array2', 'array3'), }).create({ array: emberA([1, 2, 3, 4, 5, 6]), array2: emberA([4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9]), - array3: emberA([1, 8, 10]) + array3: emberA([1, 8, 10]), }); } @@ -703,13 +656,9 @@ moduleFor( beforeEach() { obj = EmberObject.extend({ list: null, - uniqueById: uniqBy('list', 'id') + uniqueById: uniqBy('list', 'id'), }).create({ - list: emberA([ - { id: 1, value: 'one' }, - { id: 2, value: 'two' }, - { id: 1, value: 'one' } - ]) + list: emberA([{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' }]), }); } @@ -723,33 +672,24 @@ moduleFor( }, /Cannot set read-only property "uniqueById" on object:/); } ['@test does not include duplicates'](assert) { - assert.deepEqual(obj.get('uniqueById'), [ - { id: 1, value: 'one' }, - { id: 2, value: 'two' } - ]); + assert.deepEqual(obj.get('uniqueById'), [{ id: 1, value: 'one' }, { id: 2, value: 'two' }]); } ['@test it does not share state among instances'](assert) { let MyObject = EmberObject.extend({ list: [], - uniqueByName: uniqBy('list', 'name') + uniqueByName: uniqBy('list', 'name'), }); let a = MyObject.create({ - list: [{ name: 'bob' }, { name: 'mitch' }, { name: 'mitch' }] + list: [{ name: 'bob' }, { name: 'mitch' }, { name: 'mitch' }], }); let b = MyObject.create({ - list: [{ name: 'warren' }, { name: 'mitch' }] + list: [{ name: 'warren' }, { name: 'mitch' }], }); - assert.deepEqual(a.get('uniqueByName'), [ - { name: 'bob' }, - { name: 'mitch' } - ]); + assert.deepEqual(a.get('uniqueByName'), [{ name: 'bob' }, { name: 'mitch' }]); // Making sure that 'mitch' appears - assert.deepEqual(b.get('uniqueByName'), [ - { name: 'warren' }, - { name: 'mitch' } - ]); + assert.deepEqual(b.get('uniqueByName'), [{ name: 'warren' }, { name: 'mitch' }]); } ['@test it handles changes to the dependent array'](assert) { @@ -757,11 +697,7 @@ moduleFor( assert.deepEqual( obj.get('uniqueById'), - [ - { id: 1, value: 'one' }, - { id: 2, value: 'two' }, - { id: 3, value: 'three' } - ], + [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list includes three' ); @@ -769,11 +705,7 @@ moduleFor( assert.deepEqual( obj.get('uniqueById'), - [ - { id: 1, value: 'one' }, - { id: 2, value: 'two' }, - { id: 3, value: 'three' } - ], + [{ id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 3, value: 'three' }], 'The list does not include a duplicate three' ); } @@ -781,7 +713,7 @@ moduleFor( ['@test it returns an empty array when computed on a non-array'](assert) { let MyObject = EmberObject.extend({ list: null, - uniq: uniqBy('list', 'name') + uniq: uniqBy('list', 'name'), }); let a = MyObject.create({ list: 'not an array' }); @@ -795,11 +727,11 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - intersection: intersect('array', 'array2', 'array3') + intersection: intersect('array', 'array2', 'array3'), }).create({ array: emberA([1, 2, 3, 4, 5, 6]), array2: emberA([3, 3, 3, 4, 5]), - array3: emberA([3, 5, 6, 7, 8]) + array3: emberA([3, 5, 6, 7, 8]), }); } @@ -871,10 +803,10 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - diff: setDiff('array', 'array2') + diff: setDiff('array', 'array2'), }).create({ array: emberA([1, 2, 3, 4, 5, 6, 7]), - array2: emberA([3, 4, 5, 10]) + array2: emberA([3, 4, 5, 10]), }); } @@ -892,10 +824,10 @@ moduleFor( expectAssertion( function() { EmberObject.extend({ - diff: setDiff('array') + diff: setDiff('array'), }).create({ array: emberA([1, 2, 3, 4, 5, 6, 7]), - array2: emberA([3, 4, 5]) + array2: emberA([3, 4, 5]), }); }, /\`computed\.setDiff\` requires exactly two dependent arrays/, @@ -905,11 +837,11 @@ moduleFor( expectAssertion( function() { EmberObject.extend({ - diff: setDiff('array', 'array2', 'array3') + diff: setDiff('array', 'array2', 'array3'), }).create({ array: emberA([1, 2, 3, 4, 5, 6, 7]), array2: emberA([3, 4, 5]), - array3: emberA([7]) + array3: emberA([7]), }); }, /\`computed\.setDiff\` requires exactly two dependent arrays/, @@ -975,15 +907,15 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - sortedItems: sort('items', 'itemSorting') + sortedItems: sort('items', 'itemSorting'), }).create({ itemSorting: emberA(['lname', 'fname']), items: emberA([ { fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, - { fname: 'Bran', lname: 'Stark', age: 8 } - ]) + { fname: 'Bran', lname: 'Stark', age: 8 }, + ]), }); } @@ -1024,7 +956,7 @@ moduleFor( { fname: 'Roose', lname: 'Bolton' }, { fname: 'Theon', lname: 'Greyjoy' }, { fname: 'Ramsey', lname: 'Bolton' }, - { fname: 'Stannis', lname: 'Baratheon' } + { fname: 'Stannis', lname: 'Baratheon' }, ]); assert.deepEqual( @@ -1045,7 +977,7 @@ moduleFor( items.pushObject({ fname: 'Tyrion', - lname: 'Lannister' + lname: 'Lannister', }); assert.deepEqual( @@ -1055,9 +987,7 @@ moduleFor( ); } - ['@test removing from the dependent array updates the sorted array']( - assert - ) { + ['@test removing from the dependent array updates the sorted array'](assert) { assert.deepEqual( obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], @@ -1081,13 +1011,13 @@ moduleFor( let jaimeInDisguise = { fname: 'Cersei', lname: 'Lannister', - age: 34 + age: 34, }; let jaime = { fname: 'Jaime', lname: 'Lannister', - age: 34 + age: 34, }; let items = obj.get('items'); @@ -1123,13 +1053,13 @@ moduleFor( ) { let tyrion = { fname: 'Tyrion', - lname: 'Lannister' + lname: 'Lannister', }; let tyrionInDisguise = ObjectProxy.create({ fname: 'Yollo', lname: '', - content: tyrion + content: tyrion, }); let items = obj.get('items'); @@ -1141,7 +1071,7 @@ moduleFor( 'Jaime', 'Tyrion', 'Bran', - 'Robb' + 'Robb', ]); items.pushObject(tyrionInDisguise); @@ -1152,13 +1082,11 @@ moduleFor( 'Jaime', 'Tyrion', 'Bran', - 'Robb' + 'Robb', ]); } - ['@test updating sort properties detaches observers for old sort properties']( - assert - ) { + ['@test updating sort properties detaches observers for old sort properties'](assert) { let objectToRemove = obj.get('items')[3]; assert.deepEqual( @@ -1198,9 +1126,7 @@ moduleFor( obj.set('items', null); assert.deepEqual(obj.get('sortedItems'), []); obj.set('items', emberA([{ fname: 'Cersei', lname: 'Lanister' }])); - assert.deepEqual(obj.get('sortedItems'), [ - { fname: 'Cersei', lname: 'Lanister' } - ]); + assert.deepEqual(obj.get('sortedItems'), [{ fname: 'Cersei', lname: 'Lanister' }]); } ['@test updating sort properties updates the sorted array'](assert) { @@ -1238,9 +1164,7 @@ moduleFor( ); } - ['@test updating new sort properties invalidates the sorted array']( - assert - ) { + ['@test updating new sort properties invalidates the sorted array'](assert) { assert.deepEqual( obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], @@ -1265,17 +1189,10 @@ moduleFor( } ['@test sort direction defaults to ascending'](assert) { - assert.deepEqual(obj.get('sortedItems').mapBy('fname'), [ - 'Cersei', - 'Jaime', - 'Bran', - 'Robb' - ]); + assert.deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb']); } - ['@test sort direction defaults to ascending (with sort property change)']( - assert - ) { + ['@test sort direction defaults to ascending (with sort property change)'](assert) { assert.deepEqual( obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], @@ -1291,9 +1208,7 @@ moduleFor( ); } - ["@test updating an item's sort properties updates the sorted array"]( - assert - ) { + ["@test updating an item's sort properties updates the sorted array"](assert) { let tyrionInDisguise = obj.get('items')[1]; assert.deepEqual( @@ -1311,9 +1226,7 @@ moduleFor( ); } - ["@test updating several of an item's sort properties updated the sorted array"]( - assert - ) { + ["@test updating several of an item's sort properties updated the sorted array"](assert) { let sansaInDisguise = obj.get('items')[1]; assert.deepEqual( @@ -1324,7 +1237,7 @@ moduleFor( setProperties(sansaInDisguise, { fname: 'Sansa', - lname: 'Stark' + lname: 'Stark', }); assert.deepEqual( @@ -1339,19 +1252,19 @@ moduleFor( ) { let jaime = { name: 'Jaime', - status: 1 + status: 1, }; let cersei = { name: 'Cersei', - status: 2 + status: 2, }; let obj = EmberObject.extend({ sortProps: ['status'], - sortedPeople: sort('people', 'sortProps') + sortedPeople: sort('people', 'sortProps'), }).create({ - people: [jaime, cersei] + people: [jaime, cersei], }); assert.deepEqual( @@ -1362,32 +1275,22 @@ moduleFor( set(cersei, 'status', 3); - assert.deepEqual( - obj.get('sortedPeople'), - [jaime, cersei], - 'array is sorted correctly' - ); + assert.deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); set(cersei, 'status', 2); - assert.deepEqual( - obj.get('sortedPeople'), - [jaime, cersei], - 'array is sorted correctly' - ); + assert.deepEqual(obj.get('sortedPeople'), [jaime, cersei], 'array is sorted correctly'); } - ['@test array should not be sorted if sort properties array is empty']( - assert - ) { + ['@test array should not be sorted if sort properties array is empty'](assert) { var o = EmberObject.extend({ - sortedItems: sort('items', 'itemSorting') + sortedItems: sort('items', 'itemSorting'), }).create({ itemSorting: emberA([]), // This bug only manifests when array.sort(() => 0) is not equal to array. // In order for this to happen, the browser must use an unstable sort and the // array must be sufficient large. On Chrome, 12 items is currently sufficient. - items: emberA([6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5]) + items: emberA([6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5]), }); assert.deepEqual( @@ -1406,9 +1309,9 @@ moduleFor( let sortProps = emberA(['name']); let jaime = EmberObject.extend({ sortedPeople: sort('sisters', 'sortProps'), - sortProps + sortProps, }).create({ - sisters + sisters, }); jaime.get('sortedPeople'); @@ -1416,7 +1319,7 @@ moduleFor( try { sortProps.pushObject({ - name: 'Anna' + name: 'Anna', }); assert.ok(true); } catch (e) { @@ -1424,26 +1327,24 @@ moduleFor( } } - ['@test property paths in sort properties update the sorted array']( - assert - ) { + ['@test property paths in sort properties update the sorted array'](assert) { let jaime = { - relatedObj: { status: 1, firstName: 'Jaime', lastName: 'Lannister' } + relatedObj: { status: 1, firstName: 'Jaime', lastName: 'Lannister' }, }; let cersei = { - relatedObj: { status: 2, firstName: 'Cersei', lastName: 'Lannister' } + relatedObj: { status: 2, firstName: 'Cersei', lastName: 'Lannister' }, }; let sansa = EmberObject.create({ - relatedObj: { status: 3, firstName: 'Sansa', lastName: 'Stark' } + relatedObj: { status: 3, firstName: 'Sansa', lastName: 'Stark' }, }); let obj = EmberObject.extend({ sortProps: ['relatedObj.status'], - sortedPeople: sort('people', 'sortProps') + sortedPeople: sort('people', 'sortProps'), }).create({ - people: [jaime, cersei, sansa] + people: [jaime, cersei, sansa], }); assert.deepEqual( @@ -1526,14 +1427,14 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - sortedItems: sort('items.@each.fname', sortByLnameFname) + sortedItems: sort('items.@each.fname', sortByLnameFname), }).create({ items: emberA([ { fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, - { fname: 'Bran', lname: 'Stark', age: 8 } - ]) + { fname: 'Bran', lname: 'Stark', age: 8 }, + ]), }); } @@ -1549,14 +1450,14 @@ moduleFor( }), sortByLastName(a, b) { return sortByFnameAsc(a, b); - } + }, }).create({ items: emberA([ { fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, - { fname: 'Bran', lname: 'Stark', age: 8 } - ]) + { fname: 'Bran', lname: 'Stark', age: 8 }, + ]), }); obj.get('sortedItems'); @@ -1595,7 +1496,7 @@ moduleFor( { fname: 'Roose', lname: 'Bolton' }, { fname: 'Theon', lname: 'Greyjoy' }, { fname: 'Ramsey', lname: 'Bolton' }, - { fname: 'Stannis', lname: 'Baratheon' } + { fname: 'Stannis', lname: 'Baratheon' }, ]); assert.deepEqual( @@ -1616,7 +1517,7 @@ moduleFor( items.pushObject({ fname: 'Tyrion', - lname: 'Lannister' + lname: 'Lannister', }); assert.deepEqual( @@ -1626,9 +1527,7 @@ moduleFor( ); } - ['@test removing from the dependent array updates the sorted array']( - assert - ) { + ['@test removing from the dependent array updates the sorted array'](assert) { assert.deepEqual( obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], @@ -1652,13 +1551,13 @@ moduleFor( let jaimeInDisguise = { fname: 'Cersei', lname: 'Lannister', - age: 34 + age: 34, }; let jaime = { fname: 'Jaime', lname: 'Lannister', - age: 34 + age: 34, }; let items = obj.get('items'); @@ -1694,13 +1593,13 @@ moduleFor( ) { let tyrion = { fname: 'Tyrion', - lname: 'Lannister' + lname: 'Lannister', }; let tyrionInDisguise = ObjectProxy.create({ fname: 'Yollo', lname: '', - content: tyrion + content: tyrion, }); let items = obj.get('items'); @@ -1712,7 +1611,7 @@ moduleFor( 'Jaime', 'Tyrion', 'Bran', - 'Robb' + 'Robb', ]); items.pushObject(tyrionInDisguise); @@ -1723,7 +1622,7 @@ moduleFor( 'Jaime', 'Tyrion', 'Bran', - 'Robb' + 'Robb', ]); } @@ -1749,9 +1648,7 @@ moduleFor( ); } - ['@test changing item properties not specified via @each does not trigger a resort']( - assert - ) { + ['@test changing item properties not specified via @each does not trigger a resort'](assert) { if (!EMBER_METAL_TRACKED_PROPERTIES) { let items = obj.get('items'); let cersei = items[1]; @@ -1785,14 +1682,14 @@ moduleFor( beforeEach() { obj = EmberObject.extend({ sortProps: ['count', 'name'], - sortedItems: sort('items', 'sortProps') + sortedItems: sort('items', 'sortProps'), }).create({ items: [ { name: 'A', count: 1, thing: 4 }, { name: 'B', count: 1, thing: 3 }, { name: 'C', count: 1, thing: 2 }, - { name: 'D', count: 1, thing: 4 } - ] + { name: 'D', count: 1, thing: 4 }, + ], }); } @@ -1801,19 +1698,11 @@ moduleFor( } ['@test sorts correctly as only one property changes'](assert) { - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'B', 'C', 'D'], - 'initial' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); set(obj.get('items')[3], 'count', 2); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'B', 'C', 'D'], - 'final' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'final'); } } ); @@ -1826,18 +1715,15 @@ moduleFor( klass = EmberObject.extend({ sortProps: ['count'], sortedItems: sort('items', 'sortProps'), - customSortedItems: sort( - 'items.@each.count', - (a, b) => a.count - b.count - ) + customSortedItems: sort('items.@each.count', (a, b) => a.count - b.count), }); obj = klass.create({ items: emberA([ { name: 'A', count: 1, thing: 4, id: 1 }, { name: 'B', count: 2, thing: 3, id: 2 }, { name: 'C', count: 3, thing: 2, id: 3 }, - { name: 'D', count: 4, thing: 1, id: 4 } - ]) + { name: 'D', count: 4, thing: 1, id: 4 }, + ]), }); } @@ -1852,34 +1738,18 @@ moduleFor( set(obj.get('items')[1], 'count', 5); set(obj.get('items')[2], 'count', 6); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'D', 'B', 'C'], - 'final' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); } ['@test sort correctly after mutation to the sort'](assert) { - assert.deepEqual( - obj.get('customSortedItems').mapBy('name'), - ['A', 'B', 'C', 'D'], - 'initial' - ); + assert.deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); set(obj.get('items')[1], 'count', 5); set(obj.get('items')[2], 'count', 6); - assert.deepEqual( - obj.get('customSortedItems').mapBy('name'), - ['A', 'D', 'B', 'C'], - 'final' - ); + assert.deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'D', 'B', 'C'], - 'final' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); } ['@test sort correctly on multiple instances of the same class'](assert) { @@ -1888,55 +1758,31 @@ moduleFor( { name: 'W', count: 23, thing: 4 }, { name: 'X', count: 24, thing: 3 }, { name: 'Y', count: 25, thing: 2 }, - { name: 'Z', count: 26, thing: 1 } - ]) + { name: 'Z', count: 26, thing: 1 }, + ]), }); - assert.deepEqual( - obj2.get('sortedItems').mapBy('name'), - ['W', 'X', 'Y', 'Z'], - 'initial' - ); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'B', 'C', 'D'], - 'initial' - ); + assert.deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'X', 'Y', 'Z'], 'initial'); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); set(obj.get('items')[1], 'count', 5); set(obj.get('items')[2], 'count', 6); set(obj2.get('items')[1], 'count', 27); set(obj2.get('items')[2], 'count', 28); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['A', 'D', 'B', 'C'], - 'final' - ); - assert.deepEqual( - obj2.get('sortedItems').mapBy('name'), - ['W', 'Z', 'X', 'Y'], - 'final' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); + assert.deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'Z', 'X', 'Y'], 'final'); obj.set('sortProps', ['thing']); - assert.deepEqual( - obj.get('sortedItems').mapBy('name'), - ['D', 'C', 'B', 'A'], - 'final' - ); + assert.deepEqual(obj.get('sortedItems').mapBy('name'), ['D', 'C', 'B', 'A'], 'final'); obj2.notifyPropertyChange('sortedItems'); // invalidate to flush, to get DK refreshed obj2.get('sortedItems'); // flush to get updated DK obj2.set('items.firstObject.count', 9999); - assert.deepEqual( - obj2.get('sortedItems').mapBy('name'), - ['Z', 'X', 'Y', 'W'], - 'final' - ); + assert.deepEqual(obj2.get('sortedItems').mapBy('name'), ['Z', 'X', 'Y', 'W'], 'final'); } ['@test sort correctly when multiple sorts are chained on the same instance of a class']( @@ -1949,10 +1795,10 @@ moduleFor( }), asdf: observer('sibling.sortedItems.[]', function() { this.get('sibling.sortedItems'); - }) + }), }) .create({ - sibling: obj + sibling: obj, }); /* @@ -2018,9 +1864,9 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - max: max('items') + max: max('items'), }).create({ - items: emberA([1, 2, 3]) + items: emberA([1, 2, 3]), }); } @@ -2041,19 +1887,11 @@ moduleFor( items.pushObject(5); - assert.equal( - obj.get('max'), - 5, - 'max updates when a larger number is added' - ); + assert.equal(obj.get('max'), 5, 'max updates when a larger number is added'); items.pushObject(2); - assert.equal( - obj.get('max'), - 5, - 'max does not update when a smaller number is added' - ); + assert.equal(obj.get('max'), 5, 'max does not update when a smaller number is added'); } ['@test max recomputes when the current max is removed'](assert) { @@ -2061,19 +1899,11 @@ moduleFor( obj.get('items').removeObject(2); - assert.equal( - obj.get('max'), - 3, - 'max is unchanged when a non-max item is removed' - ); + assert.equal(obj.get('max'), 3, 'max is unchanged when a non-max item is removed'); obj.get('items').removeObject(3); - assert.equal( - obj.get('max'), - 1, - 'max is recomputed when the current max is removed' - ); + assert.equal(obj.get('max'), 1, 'max is recomputed when the current max is removed'); } } ); @@ -2083,9 +1913,9 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - min: min('items') + min: min('items'), }).create({ - items: emberA([1, 2, 3]) + items: emberA([1, 2, 3]), }); } @@ -2104,19 +1934,11 @@ moduleFor( obj.get('items').pushObject(-2); - assert.equal( - obj.get('min'), - -2, - 'min updates when a smaller number is added' - ); + assert.equal(obj.get('min'), -2, 'min updates when a smaller number is added'); obj.get('items').pushObject(2); - assert.equal( - obj.get('min'), - -2, - 'min does not update when a larger number is added' - ); + assert.equal(obj.get('min'), -2, 'min does not update when a larger number is added'); } ['@test min recomputes when the current min is removed'](assert) { @@ -2126,19 +1948,11 @@ moduleFor( items.removeObject(2); - assert.equal( - obj.get('min'), - 1, - 'min is unchanged when a non-min item is removed' - ); + assert.equal(obj.get('min'), 1, 'min is unchanged when a non-min item is removed'); items.removeObject(1); - assert.equal( - obj.get('min'), - 3, - 'min is recomputed when the current min is removed' - ); + assert.equal(obj.get('min'), 3, 'min is recomputed when the current min is removed'); } } ); @@ -2154,14 +1968,14 @@ moduleFor( starks: filterBy('items', 'lname', 'Stark'), starkAges: mapBy('starks', 'age'), - oldestStarkAge: max('starkAges') + oldestStarkAge: max('starkAges'), }).create({ items: emberA([ { fname: 'Jaime', lname: 'Lannister', age: 34 }, { fname: 'Cersei', lname: 'Lannister', age: 34 }, { fname: 'Robb', lname: 'Stark', age: 16 }, - { fname: 'Bran', lname: 'Stark', age: 8 } - ]) + { fname: 'Bran', lname: 'Stark', age: 8 }, + ]), }); } @@ -2192,11 +2006,7 @@ moduleFor( ['@test filtering, sorting and reduce (max) can be combined'](assert) { let items = obj.get('items'); - assert.equal( - 16, - obj.get('oldestStarkAge'), - 'precond - end of chain is initially correct' - ); + assert.equal(16, obj.get('oldestStarkAge'), 'precond - end of chain is initially correct'); items.pushObject({ fname: 'Rickon', lname: 'Stark', age: 5 }); @@ -2232,15 +2042,9 @@ moduleFor( beforeEach() { obj = EmberObject.extend({ sorted: sort('todos.@each.priority', priorityComparator), - filtered: filter('sorted.@each.priority', evenPriorities) + filtered: filter('sorted.@each.priority', evenPriorities), }).create({ - todos: emberA([ - todo('E', 4), - todo('D', 3), - todo('C', 2), - todo('B', 1), - todo('A', 0) - ]) + todos: emberA([todo('E', 4), todo('D', 3), todo('C', 2), todo('B', 1), todo('A', 0)]), }); } @@ -2248,9 +2052,7 @@ moduleFor( run(obj, 'destroy'); } - ['@test it can filter and sort when both depend on the same item property']( - assert - ) { + ['@test it can filter and sort when both depend on the same item property'](assert) { assert.deepEqual( obj.get('todos').mapBy('name'), ['E', 'D', 'C', 'B', 'A'], @@ -2297,9 +2099,9 @@ moduleFor( obj = EmberObject.extend({ mapped: mapBy('array', 'v'), max: max('mapped'), - maxDidChange: observer('max', () => userFnCalls++) + maxDidChange: observer('max', () => userFnCalls++), }).create({ - array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]) + array: emberA([{ v: 1 }, { v: 3 }, { v: 2 }, { v: 1 }]), }); } @@ -2308,11 +2110,7 @@ moduleFor( } ['@test it computes interdependent array computed properties'](assert) { - assert.equal( - obj.get('max'), - 3, - 'sanity - it properly computes the maximum value' - ); + assert.equal(obj.get('max'), 3, 'sanity - it properly computes the maximum value'); let calls = 0; @@ -2332,9 +2130,9 @@ moduleFor( class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ - total: sum('array') + total: sum('array'), }).create({ - array: emberA([1, 2, 3]) + array: emberA([1, 2, 3]), }); } @@ -2352,9 +2150,7 @@ moduleFor( assert.equal(obj.get('total'), 6, 'sums the values'); } - ['@test if the dependentKey is neither an array nor object, it will return `0`']( - assert - ) { + ['@test if the dependentKey is neither an array nor object, it will return `0`'](assert) { set(obj, 'array', null); assert.equal(get(obj, 'total'), 0, 'returns 0'); @@ -2384,29 +2180,17 @@ moduleFor( let obj = { one: 'foo', two: 'bar', three: null }; defineProperty(obj, 'all', collect('one', 'two', 'three', 'four')); - assert.deepEqual( - get(obj, 'all'), - ['foo', 'bar', null, null], - 'have all of them' - ); + assert.deepEqual(get(obj, 'all'), ['foo', 'bar', null, null], 'have all of them'); set(obj, 'four', true); - assert.deepEqual( - get(obj, 'all'), - ['foo', 'bar', null, true], - 'have all of them' - ); + assert.deepEqual(get(obj, 'all'), ['foo', 'bar', null, true], 'have all of them'); let a = []; set(obj, 'one', 0); set(obj, 'three', a); - assert.deepEqual( - get(obj, 'all'), - [0, 'bar', a, true], - 'have all of them' - ); + assert.deepEqual(get(obj, 'all'), [0, 'bar', a, true], 'have all of them'); } } ); diff --git a/packages/ember-runtime/tests/controllers/controller_test.js b/packages/ember-runtime/tests/controllers/controller_test.js index 1484a1f83b6..75af3fcd1e8 100644 --- a/packages/ember-runtime/tests/controllers/controller_test.js +++ b/packages/ember-runtime/tests/controllers/controller_test.js @@ -17,24 +17,22 @@ moduleFor( actions: { poke() { assert.ok(true, 'poked'); - } - } + }, + }, }); let controller = TestController.create(); controller.send('poke'); } - ['@test A handled action can be bubbled to the target for continued processing']( - assert - ) { + ['@test A handled action can be bubbled to the target for continued processing'](assert) { assert.expect(2); let TestController = Controller.extend({ actions: { poke() { assert.ok(true, 'poked 1'); return true; - } - } + }, + }, }); let controller = TestController.create({ @@ -42,9 +40,9 @@ moduleFor( actions: { poke() { assert.ok(true, 'poked 2'); - } - } - }).create() + }, + }, + }).create(), }); controller.send('poke'); } @@ -59,8 +57,8 @@ moduleFor( }, bar(msg) { assert.equal(msg, 'HELLO'); - } - } + }, + }, }); let BarControllerMixin = Mixin.create({ @@ -68,16 +66,16 @@ moduleFor( bar(msg) { assert.equal(msg, 'HELLO'); this._super(msg); - } - } + }, + }, }); let IndexController = SuperController.extend(BarControllerMixin, { actions: { baz() { assert.ok(true, 'baz'); - } - } + }, + }, }); let controller = IndexController.create({}); @@ -94,7 +92,7 @@ moduleFor( Controller.extend({ toString() { return 'controller:rip-alley'; - } + }, }) ); @@ -117,20 +115,12 @@ moduleFor( ignoreDeprecation(function() { controller = Controller.extend({ - content: 'foo-bar' + content: 'foo-bar', }).create(); }); - assert.notEqual( - controller.get('model'), - 'foo-bar', - 'model is set properly' - ); - assert.equal( - controller.get('content'), - 'foo-bar', - 'content is not set properly' - ); + assert.notEqual(controller.get('model'), 'foo-bar', 'model is set properly'); + assert.equal(controller.get('content'), 'foo-bar', 'content is not set properly'); } ['@test specifying `content` (without `model` specified) does not result in deprecation']( @@ -140,21 +130,19 @@ moduleFor( expectNoDeprecation(); let controller = Controller.extend({ - content: 'foo-bar' + content: 'foo-bar', }).create(); assert.equal(get(controller, 'content'), 'foo-bar'); } - ['@test specifying `content` (with `model` specified) does not result in deprecation']( - assert - ) { + ['@test specifying `content` (with `model` specified) does not result in deprecation'](assert) { assert.expect(3); expectNoDeprecation(); let controller = Controller.extend({ content: 'foo-bar', - model: 'blammo' + model: 'blammo', }).create(); assert.equal(get(controller, 'content'), 'foo-bar'); @@ -166,15 +154,13 @@ moduleFor( moduleFor( 'Controller deprecations -> Controller injected properties', class extends AbstractTestCase { - ['@test defining a controller on a non-controller should fail assertion']( - assert - ) { + ['@test defining a controller on a non-controller should fail assertion'](assert) { if (!EmberDev.runningProdBuild) { expectAssertion(function() { let owner = buildOwner(); let AnObject = EmberObject.extend({ - foo: inject.controller('bar') + foo: inject.controller('bar'), }); owner.register('controller:bar', EmberObject.extend()); @@ -193,7 +179,7 @@ moduleFor( owner.register( 'controller:post', Controller.extend({ - postsController: inject.controller('posts') + postsController: inject.controller('posts'), }) ); @@ -215,7 +201,7 @@ moduleFor( owner.register( 'controller:application', Controller.extend({ - authService: inject.service('auth') + authService: inject.service('auth'), }) ); @@ -224,11 +210,7 @@ moduleFor( let appController = owner.lookup('controller:application'); let authService = owner.lookup('service:auth'); - assert.equal( - authService, - appController.get('authService'), - 'service.auth is injected' - ); + assert.equal(authService, appController.get('authService'), 'service.auth is injected'); } } ); diff --git a/packages/ember-runtime/tests/copyable-array/copy-test.js b/packages/ember-runtime/tests/copyable-array/copy-test.js index 58b877b149a..999cacb34bb 100644 --- a/packages/ember-runtime/tests/copyable-array/copy-test.js +++ b/packages/ember-runtime/tests/copyable-array/copy-test.js @@ -5,10 +5,7 @@ class CopyTest extends AbstractTestCase { '@test should return an equivalent copy'() { let obj = this.newObject(); let copy = obj.copy(); - this.assert.ok( - this.isEqual(obj, copy), - 'old object and new object should be equivalent' - ); + this.assert.ok(this.isEqual(obj, copy), 'old object and new object should be equivalent'); } } diff --git a/packages/ember-runtime/tests/core/compare_test.js b/packages/ember-runtime/tests/core/compare_test.js index 0311f113a56..9e14d9f8021 100644 --- a/packages/ember-runtime/tests/core/compare_test.js +++ b/packages/ember-runtime/tests/core/compare_test.js @@ -10,7 +10,7 @@ let Comp = EmberObject.extend(Comparable); Comp.reopenClass({ compare(obj) { return obj.get('val'); - } + }, }); moduleFor( @@ -43,17 +43,9 @@ moduleFor( for (suspectIndex = 0; suspectIndex < data.length; suspectIndex++) { suspect = data[suspectIndex]; - assert.equal( - compare(suspect, suspect), - 0, - suspectIndex + ' should equal itself' - ); + assert.equal(compare(suspect, suspect), 0, suspectIndex + ' should equal itself'); - for ( - comparableIndex = suspectIndex + 1; - comparableIndex < data.length; - comparableIndex++ - ) { + for (comparableIndex = suspectIndex + 1; comparableIndex < data.length; comparableIndex++) { comparable = data[comparableIndex]; failureMessage = @@ -72,52 +64,26 @@ moduleFor( } } - ['@test comparables should return values in the range of -1, 0, 1']( - assert - ) { + ['@test comparables should return values in the range of -1, 0, 1'](assert) { let negOne = Comp.create({ - val: -1 + val: -1, }); let zero = Comp.create({ - val: 0 + val: 0, }); let one = Comp.create({ - val: 1 + val: 1, }); - assert.equal( - compare(negOne, 'a'), - -1, - 'First item comparable - returns -1 (not negated)' - ); - assert.equal( - compare(zero, 'b'), - 0, - 'First item comparable - returns 0 (not negated)' - ); - assert.equal( - compare(one, 'c'), - 1, - 'First item comparable - returns 1 (not negated)' - ); + assert.equal(compare(negOne, 'a'), -1, 'First item comparable - returns -1 (not negated)'); + assert.equal(compare(zero, 'b'), 0, 'First item comparable - returns 0 (not negated)'); + assert.equal(compare(one, 'c'), 1, 'First item comparable - returns 1 (not negated)'); - assert.equal( - compare('a', negOne), - 1, - 'Second item comparable - returns -1 (negated)' - ); - assert.equal( - compare('b', zero), - 0, - 'Second item comparable - returns 0 (negated)' - ); - assert.equal( - compare('c', one), - -1, - 'Second item comparable - returns 1 (negated)' - ); + assert.equal(compare('a', negOne), 1, 'Second item comparable - returns -1 (negated)'); + assert.equal(compare('b', zero), 0, 'Second item comparable - returns 0 (negated)'); + assert.equal(compare('c', one), -1, 'Second item comparable - returns 1 (negated)'); } } ); diff --git a/packages/ember-runtime/tests/core/copy_test.js b/packages/ember-runtime/tests/core/copy_test.js index 00e8028e085..45d32df10ae 100644 --- a/packages/ember-runtime/tests/core/copy_test.js +++ b/packages/ember-runtime/tests/core/copy_test.js @@ -14,11 +14,7 @@ moduleFor( let date = new Date(2014, 7, 22); let dateCopy = copy(date); - assert.equal( - date.getTime(), - dateCopy.getTime(), - 'dates should be equivalent' - ); + assert.equal(date.getTime(), dateCopy.getTime(), 'dates should be equivalent'); } ['@test Ember.copy null prototype object'](assert) { @@ -33,11 +29,7 @@ moduleFor( let array = [1, null, new Date(2015, 9, 9), 'four']; let arrayCopy = copy(array); - assert.deepEqual( - array, - arrayCopy, - 'array content cloned successfully in new array' - ); + assert.deepEqual(array, arrayCopy, 'array content cloned successfully in new array'); } } ); diff --git a/packages/ember-runtime/tests/core/isEqual_test.js b/packages/ember-runtime/tests/core/isEqual_test.js index 3d7b6bd2085..b8fd4e82d0a 100644 --- a/packages/ember-runtime/tests/core/isEqual_test.js +++ b/packages/ember-runtime/tests/core/isEqual_test.js @@ -5,10 +5,7 @@ moduleFor( 'isEqual', class extends AbstractTestCase { ['@test undefined and null'](assert) { - assert.ok( - isEqual(undefined, undefined), - 'undefined is equal to undefined' - ); + assert.ok(isEqual(undefined, undefined), 'undefined is equal to undefined'); assert.ok(!isEqual(undefined, null), 'undefined is not equal to null'); assert.ok(isEqual(null, null), 'null is equal to null'); assert.ok(!isEqual(null, undefined), 'null is not equal to undefined'); @@ -25,10 +22,7 @@ moduleFor( } ['@test dates should be equal'](assert) { - assert.ok( - isEqual(new Date(1985, 7, 22), new Date(1985, 7, 22)), - 'same dates are equal' - ); + assert.ok(isEqual(new Date(1985, 7, 22), new Date(1985, 7, 22)), 'same dates are equal'); assert.ok( !isEqual(new Date(2014, 7, 22), new Date(1985, 7, 22)), 'different dates are not equal' @@ -53,7 +47,7 @@ moduleFor( { isEqual() { return true; - } + }, }, null ), @@ -63,13 +57,9 @@ moduleFor( let obj = { isEqual() { return false; - } + }, }; - assert.equal( - isEqual(obj, obj), - false, - 'should return false because isEqual returns false' - ); + assert.equal(isEqual(obj, obj), false, 'should return false because isEqual returns false'); } } ); diff --git a/packages/ember-runtime/tests/core/is_array_test.js b/packages/ember-runtime/tests/core/is_array_test.js index 79b20523485..22110ef8cce 100644 --- a/packages/ember-runtime/tests/core/is_array_test.js +++ b/packages/ember-runtime/tests/core/is_array_test.js @@ -33,10 +33,7 @@ moduleFor( } ['@test Ember.isArray(fileList)'](assert) { - if ( - environment.window && - typeof environment.window.FileList === 'function' - ) { + if (environment.window && typeof environment.window.FileList === 'function') { let fileListElement = document.createElement('input'); fileListElement.type = 'file'; let fileList = fileListElement.files; diff --git a/packages/ember-runtime/tests/core/is_empty_test.js b/packages/ember-runtime/tests/core/is_empty_test.js index f9198825e55..4bb98e25083 100644 --- a/packages/ember-runtime/tests/core/is_empty_test.js +++ b/packages/ember-runtime/tests/core/is_empty_test.js @@ -9,11 +9,7 @@ moduleFor( ['@test Ember.isEmpty'](assert) { let arrayProxy = ArrayProxy.create({ content: emberA() }); - assert.equal( - true, - isEmpty(arrayProxy), - 'for an ArrayProxy that has empty content' - ); + assert.equal(true, isEmpty(arrayProxy), 'for an ArrayProxy that has empty content'); } } ); diff --git a/packages/ember-runtime/tests/core/type_of_test.js b/packages/ember-runtime/tests/core/type_of_test.js index bd454884c5b..1c260b02c67 100644 --- a/packages/ember-runtime/tests/core/type_of_test.js +++ b/packages/ember-runtime/tests/core/type_of_test.js @@ -35,20 +35,13 @@ moduleFor( assert.equal(typeOf(arr), 'array', 'item of type array'); assert.equal(typeOf(obj), 'object', 'item of type object'); assert.equal(typeOf(instance), 'instance', 'item of type instance'); - assert.equal( - typeOf(instance.method), - 'function', - 'item of type function' - ); + assert.equal(typeOf(instance.method), 'function', 'item of type function'); assert.equal(typeOf(EmberObject.extend()), 'class', 'item of type class'); assert.equal(typeOf(new Error()), 'error', 'item of type error'); } ['@test Ember.typeOf(fileList)'](assert) { - if ( - environment.window && - typeof environment.window.FileList === 'function' - ) { + if (environment.window && typeof environment.window.FileList === 'function') { let fileListElement = document.createElement('input'); fileListElement.type = 'file'; let fileList = fileListElement.files; diff --git a/packages/ember-runtime/tests/ext/function_test.js b/packages/ember-runtime/tests/ext/function_test.js index 3218ada1505..e283b6cbbef 100644 --- a/packages/ember-runtime/tests/ext/function_test.js +++ b/packages/ember-runtime/tests/ext/function_test.js @@ -21,15 +21,11 @@ moduleFor( foo: function() { set(this, 'count', get(this, 'count') + 1); - }.observes('bar', 'baz') + }.observes('bar', 'baz'), }); let obj = mixin({}, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); set(obj, 'baz', 'BAZ'); @@ -41,9 +37,7 @@ moduleFor( moduleFor( 'Function.prototype.on() helper', class extends AbstractTestCase { - ['@test sets up an event listener, and can trigger the function on multiple events']( - assert - ) { + ['@test sets up an event listener, and can trigger the function on multiple events'](assert) { if (!ENV.EXTEND_PROTOTYPES.Function) { assert.ok( 'undefined' === typeof Function.prototype.on, @@ -57,23 +51,15 @@ moduleFor( foo: function() { set(this, 'count', get(this, 'count') + 1); - }.on('bar', 'baz') + }.on('bar', 'baz'), }); let obj = mixin({}, Evented, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke listener immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); obj.trigger('bar'); obj.trigger('baz'); - assert.equal( - get(obj, 'count'), - 2, - 'should invoke listeners when events trigger' - ); + assert.equal(get(obj, 'count'), 2, 'should invoke listeners when events trigger'); } ['@test can be chained with observes'](assert) { @@ -89,15 +75,11 @@ moduleFor( set(this, 'count', get(this, 'count') + 1); } .observes('bay') - .on('bar') + .on('bar'), }); let obj = mixin({}, Evented, MyMixin); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke listener immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); set(obj, 'bay', 'BAY'); obj.trigger('bar'); @@ -123,29 +105,17 @@ moduleFor( lastName: null, fullName: function() { return get(this, 'firstName') + ' ' + get(this, 'lastName'); - }.property('firstName', 'lastName') + }.property('firstName', 'lastName'), }); let obj = MyClass.create({ firstName: 'Fred', lastName: 'Flinstone' }); - assert.equal( - get(obj, 'fullName'), - 'Fred Flinstone', - 'should return the computed value' - ); + assert.equal(get(obj, 'fullName'), 'Fred Flinstone', 'should return the computed value'); set(obj, 'firstName', 'Wilma'); - assert.equal( - get(obj, 'fullName'), - 'Wilma Flinstone', - 'should return the new computed value' - ); + assert.equal(get(obj, 'fullName'), 'Wilma Flinstone', 'should return the new computed value'); set(obj, 'lastName', ''); - assert.equal( - get(obj, 'fullName'), - 'Wilma ', - 'should return the new computed value' - ); + assert.equal(get(obj, 'fullName'), 'Wilma ', 'should return the new computed value'); } } ); diff --git a/packages/ember-runtime/tests/ext/rsvp_test.js b/packages/ember-runtime/tests/ext/rsvp_test.js index 107aef2fd94..32f4a983be2 100644 --- a/packages/ember-runtime/tests/ext/rsvp_test.js +++ b/packages/ember-runtime/tests/ext/rsvp_test.js @@ -12,9 +12,7 @@ moduleFor( setOnerror(ORIGINAL_ONERROR); } - ['@test Ensure that errors thrown from within a promise are sent to the console']( - assert - ) { + ['@test Ensure that errors thrown from within a promise are sent to the console'](assert) { let error = new Error('Error thrown in a promise for testing purposes.'); try { @@ -35,10 +33,7 @@ moduleFor( run(RSVP, 'reject', fakeTransitionAbort); - assert.ok( - true, - 'did not throw an error when dealing with TransitionAborted' - ); + assert.ok(true, 'did not throw an error when dealing with TransitionAborted'); } ['@test Can reject with non-Error object'](assert) { @@ -71,9 +66,7 @@ moduleFor( assert.ok(true); } - ['@test rejections like jqXHR which have errorThrown property work']( - assert - ) { + ['@test rejections like jqXHR which have errorThrown property work'](assert) { assert.expect(2); let wasEmberTesting = isTesting(); @@ -82,11 +75,7 @@ moduleFor( try { setTesting(false); setOnerror(error => { - assert.equal( - error, - actualError, - 'expected the real error on the jqXHR' - ); + assert.equal(error, actualError, 'expected the real error on the jqXHR'); assert.equal( error.__reason_with_error_thrown__, jqXHR, @@ -96,7 +85,7 @@ moduleFor( let actualError = new Error('OMG what really happened'); let jqXHR = { - errorThrown: actualError + errorThrown: actualError, }; run(RSVP, 'reject', jqXHR); @@ -117,11 +106,7 @@ moduleFor( try { setTesting(false); setOnerror(error => { - assert.equal( - error.message, - actualError, - 'expected the real error on the jqXHR' - ); + assert.equal(error.message, actualError, 'expected the real error on the jqXHR'); assert.equal( error.__reason_with_error_thrown__, jqXHR, @@ -131,7 +116,7 @@ moduleFor( let actualError = 'OMG what really happened'; let jqXHR = { - errorThrown: actualError + errorThrown: actualError, }; run(RSVP, 'reject', jqXHR); @@ -155,7 +140,7 @@ moduleFor( }); let jqXHR = { - errorThrown: new Error('a fail') + errorThrown: new Error('a fail'), }; run(RSVP, 'reject', jqXHR); @@ -192,9 +177,7 @@ moduleFor( assert.ok(true, 'reached end of test'); } - ['@test handled within the same micro-task (via Ember.RVP.Promise)']( - assert - ) { + ['@test handled within the same micro-task (via Ember.RVP.Promise)'](assert) { run(function() { let rejection = RSVP.Promise.reject(reason); RSVP.Promise.resolve(1).then(() => rejection.catch(function() {})); @@ -230,15 +213,13 @@ moduleFor( // this is very likely an issue. } - ['@test handled in the same microTask Queue flush do to data locality']( - assert - ) { + ['@test handled in the same microTask Queue flush do to data locality'](assert) { // an ambiguous scenario, this may or may not assert // it depends on the locality of `user#1` let store = { find() { return RSVP.Promise.resolve(1); - } + }, }; run(function() { let rejection = RSVP.Promise.reject(reason); @@ -248,16 +229,14 @@ moduleFor( assert.ok(true, 'reached end of test'); } - ['@test handled in a different microTask Queue flush do to data locality']( - assert - ) { + ['@test handled in a different microTask Queue flush do to data locality'](assert) { let done = assert.async(); // an ambiguous scenario, this may or may not assert // it depends on the locality of `user#1` let store = { find() { return ajax(); - } + }, }; assert.throws(function() { run(function() { diff --git a/packages/ember-runtime/tests/helpers/array.js b/packages/ember-runtime/tests/helpers/array.js index 731c7cfe727..b8f7cab2d16 100644 --- a/packages/ember-runtime/tests/helpers/array.js +++ b/packages/ember-runtime/tests/helpers/array.js @@ -8,7 +8,7 @@ import { addArrayObserver, removeArrayObserver, arrayContentWillChange, - arrayContentDidChange + arrayContentDidChange, } from 'ember-metal'; import EmberObject from '../../system/object'; import Copyable from '../../mixins/copyable'; @@ -81,20 +81,12 @@ const ArrayTestsObserverClass = EmberObject.extend({ }, arrayWillChange() { - QUnit.config.current.assert.equal( - this._before, - null, - 'should only call once' - ); + QUnit.config.current.assert.equal(this._before, null, 'should only call once'); this._before = Array.prototype.slice.call(arguments); }, arrayDidChange() { - QUnit.config.current.assert.equal( - this._after, - null, - 'should only call once' - ); + QUnit.config.current.assert.equal(this._after, null, 'should only call once'); this._after = Array.prototype.slice.call(arguments); }, @@ -116,7 +108,7 @@ const ArrayTestsObserverClass = EmberObject.extend({ timesCalled(key) { return this._keys[key] || 0; - } + }, }); class AbstractArrayHelper { @@ -232,7 +224,7 @@ const TestArray = EmberObject.extend(EmberArray, { length: computed(function() { return this._content.length; - }) + }), }); /* @@ -270,7 +262,7 @@ const TestMutableArray = EmberObject.extend(MutableArray, { slice() { return this._content.slice(); - } + }, }); const CopyableObject = EmberObject.extend(Copyable, { @@ -285,7 +277,7 @@ const CopyableObject = EmberObject.extend(Copyable, { let ret = new CopyableObject(); set(ret, 'id', get(this, 'id')); return ret; - } + }, }); class MutableArrayHelpers extends NativeArrayHelpers { diff --git a/packages/ember-runtime/tests/inject_test.js b/packages/ember-runtime/tests/inject_test.js index dec3d3ff06f..1b57ea2b28a 100644 --- a/packages/ember-runtime/tests/inject_test.js +++ b/packages/ember-runtime/tests/inject_test.js @@ -29,7 +29,7 @@ moduleFor( let AnObject = EmberObject.extend({ bar: inject.foo(), - baz: inject.foo() + baz: inject.foo(), }); owner.register('foo:main', AnObject); @@ -43,13 +43,11 @@ moduleFor( } } - ['@test attempting to inject a nonexistent container key should error']( - assert - ) { + ['@test attempting to inject a nonexistent container key should error'](assert) { if (!EmberDev.runningProdBuild) { let owner = buildOwner(); let AnObject = EmberObject.extend({ - foo: new InjectedProperty('bar', 'baz') + foo: new InjectedProperty('bar', 'baz'), }); owner.register('foo:main', AnObject); @@ -62,13 +60,11 @@ moduleFor( } } - ['@test factories should return a list of lazy injection full names']( - assert - ) { + ['@test factories should return a list of lazy injection full names'](assert) { if (DEBUG) { let AnObject = EmberObject.extend({ foo: new InjectedProperty('foo', 'bar'), - bar: new InjectedProperty('quux') + bar: new InjectedProperty('quux'), }); assert.deepEqual( @@ -77,13 +73,13 @@ moduleFor( foo: { specifier: 'foo:bar', source: undefined, - namespace: undefined + namespace: undefined, }, bar: { specifier: 'quux:bar', source: undefined, - namespace: undefined - } + namespace: undefined, + }, }, 'should return injected container keys' ); diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js index 3c2144e4e7d..d42f51cee0b 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js @@ -38,27 +38,15 @@ moduleFor( observerFiredCount = 0; run(() => get(momma, 'children').setEach('name', 'Juan')); - assert.equal( - observerFiredCount, - 3, - 'observer fired after changing child names' - ); + assert.equal(observerFiredCount, 3, 'observer fired after changing child names'); observerFiredCount = 0; run(() => get(momma, 'children').pushObject(child4)); - assert.equal( - observerFiredCount, - 1, - 'observer fired after adding a new item' - ); + assert.equal(observerFiredCount, 1, 'observer fired after adding a new item'); observerFiredCount = 0; run(() => set(child4, 'name', 'Herbert')); - assert.equal( - observerFiredCount, - 1, - 'observer fired after changing property on new object' - ); + assert.equal(observerFiredCount, 1, 'observer fired after changing property on new object'); set(momma, 'children', []); diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js index 66753082a9a..3e22b0ef229 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js @@ -54,12 +54,12 @@ moduleFor( unknownProperty(key) { this.lastUnknownProperty = key; return 'unknown'; - } + }, }).create({ normal: 'value', numberVal: 24, toggleVal: true, - nullProperty: null + nullProperty: null, }); } @@ -103,17 +103,17 @@ moduleFor( unknownProperty(key) { this.lastUnknownProperty = key; return 'unknown'; - } + }, }).create({ normal: 'value', numberVal: 24, toggleVal: true, - nullProperty: null + nullProperty: null, }); objectB = { normal: 'value', - nullProperty: null + nullProperty: null, }; } @@ -121,28 +121,20 @@ moduleFor( assert.equal(get(objectA, 'normal'), 'value'); } - ['@test should call computed properties on Ember.Observable and return their result']( - assert - ) { + ['@test should call computed properties on Ember.Observable and return their result'](assert) { assert.equal(get(objectA, 'computed'), 'value'); } - ['@test should return the function for a non-computed property on Ember.Observable']( - assert - ) { + ['@test should return the function for a non-computed property on Ember.Observable'](assert) { var value = get(objectA, 'method'); assert.equal(typeof value, 'function'); } - ['@test should return null when property value is null on Ember.Observable']( - assert - ) { + ['@test should return null when property value is null on Ember.Observable'](assert) { assert.equal(get(objectA, 'nullProperty'), null); } - ['@test should call unknownProperty when value is undefined on Ember.Observable']( - assert - ) { + ['@test should call unknownProperty when value is undefined on Ember.Observable'](assert) { assert.equal(get(objectA, 'unknown'), 'unknown'); assert.equal(objectA.lastUnknownProperty, 'unknown'); } @@ -151,9 +143,7 @@ moduleFor( assert.equal(get(objectB, 'normal'), 'value'); } - ['@test should return null when property is null on standard objects']( - assert - ) { + ['@test should return null when property is null on standard objects'](assert) { assert.equal(get(objectB, 'nullProperty'), null); } @@ -176,15 +166,13 @@ moduleFor( moduleFor( 'Ember.get() with paths', class extends AbstractTestCase { - ['@test should return a property at a given path relative to the passed object']( - assert - ) { + ['@test should return a property at a given path relative to the passed object'](assert) { var foo = ObservableObject.create({ bar: ObservableObject.extend({ baz: computed(function() { return 'blargh'; - }).volatile() - }).create() + }).volatile(), + }).create(), }); assert.equal(get(foo, 'bar.baz'), 'blargh'); @@ -195,8 +183,8 @@ moduleFor( ) { var foo = { bar: { - baz: 'blargh' - } + baz: 'blargh', + }, }; assert.equal(get(foo, 'bar.baz'), 'blargh'); @@ -220,7 +208,7 @@ moduleFor( set(key, value) { this._computed = value; return this._computed; - } + }, }).volatile(), method(key, value) { @@ -250,7 +238,7 @@ moduleFor( nullProperty: null, // unknown property - _unknown: 'unknown' + _unknown: 'unknown', }).create(); } @@ -260,9 +248,7 @@ moduleFor( assert.equal(ret, 'changed'); } - ['@test should call computed properties passing value and return the value']( - assert - ) { + ['@test should call computed properties passing value and return the value'](assert) { var ret = object.set('computed', 'changed'); assert.equal(object.get('_computed'), 'changed'); assert.equal(ret, 'changed'); @@ -274,9 +260,7 @@ moduleFor( assert.equal(ret, undefined); } - ['@test should replace the function for a non-computed property and return the value']( - assert - ) { + ['@test should replace the function for a non-computed property and return the value'](assert) { var ret = object.set('method', 'changed'); assert.equal(object.get('_method'), 'method'); // make sure this was NOT run assert.ok(typeof object.get('method') !== 'function'); @@ -289,9 +273,7 @@ moduleFor( assert.equal(ret, 'changed'); } - ['@test should call unknownProperty with value when property is undefined']( - assert - ) { + ['@test should call unknownProperty with value when property is undefined'](assert) { var ret = object.set('unknown', 'changed'); assert.equal(object.get('_unknown'), 'changed'); assert.equal(ret, 'changed'); @@ -317,7 +299,7 @@ moduleFor( }, set(key, value) { this.computedCalls.push(value); - } + }, }).volatile(), computedCached: computed({ @@ -327,7 +309,7 @@ moduleFor( }, set: function(key, value) { this.computedCachedCalls.push(value); - } + }, }), dependent: computed({ @@ -337,7 +319,7 @@ moduleFor( }, set(key, value) { this.dependentCalls.push(value); - } + }, }) .property('changer') .volatile(), @@ -348,7 +330,7 @@ moduleFor( }, set(key, value) { this.dependentFrontCalls.push(value); - } + }, }).volatile(), dependentCached: computed({ get() { @@ -357,7 +339,7 @@ moduleFor( }, set(key, value) { this.dependentCachedCalls.push(value); - } + }, }).property('changer'), inc: computed('changer', function() { @@ -376,7 +358,7 @@ moduleFor( set() { this.set('state', 'on'); return this.get('state') === 'on'; - } + }, }) .property('state') .volatile(), @@ -388,10 +370,10 @@ moduleFor( set() { this.set('state', 'off'); return this.get('state') === 'off'; - } + }, }) .property('state') - .volatile() + .volatile(), }).create({ computedCalls: [], computedCachedCalls: [], @@ -401,7 +383,7 @@ moduleFor( dependentCachedCalls: [], incCallCount: 0, nestedIncCallCount: 0, - state: 'on' + state: 'on', }); } afterEach() { @@ -410,46 +392,26 @@ moduleFor( ['@test getting values should call function return value'](assert) { // get each property twice. Verify return. - var keys = w( - 'computed computedCached dependent dependentFront dependentCached' - ); + var keys = w('computed computedCached dependent dependentFront dependentCached'); keys.forEach(function(key) { - assert.equal( - object.get(key), - key, - `Try #1: object.get(${key}) should run function` - ); - assert.equal( - object.get(key), - key, - `Try #2: object.get(${key}) should run function` - ); + assert.equal(object.get(key), key, `Try #1: object.get(${key}) should run function`); + assert.equal(object.get(key), key, `Try #2: object.get(${key}) should run function`); }); // verify each call count. cached should only be called once w('computedCalls dependentFrontCalls dependentCalls').forEach(key => { - assert.equal( - object[key].length, - 2, - `non-cached property ${key} should be called 2x` - ); + assert.equal(object[key].length, 2, `non-cached property ${key} should be called 2x`); }); w('computedCachedCalls dependentCachedCalls').forEach(key => { - assert.equal( - object[key].length, - 1, - `non-cached property ${key} should be called 1x` - ); + assert.equal(object[key].length, 1, `non-cached property ${key} should be called 1x`); }); } ['@test setting values should call function return value'](assert) { // get each property twice. Verify return. - var keys = w( - 'computed dependent dependentFront computedCached dependentCached' - ); + var keys = w('computed dependent dependentFront computedCached dependentCached'); var values = w('value1 value2'); keys.forEach(key => { @@ -491,9 +453,7 @@ moduleFor( assert.equal( calls[idx], values[idx], - `call #${idx + 1} to set(${key}) should have passed value ${ - values[idx] - }` + `call #${idx + 1} to set(${key}) should have passed value ${values[idx]}` ); } }); @@ -507,57 +467,33 @@ moduleFor( object.notifyPropertyChange('computedCached'); object.get('computedCached'); // should run again - assert.equal( - object.computedCachedCalls.length, - 2, - 'should have invoked method 2x' - ); + assert.equal(object.computedCachedCalls.length, 2, 'should have invoked method 2x'); } ['@test change dependent should clear cache'](assert) { // call get several times to collect call count var ret1 = object.get('inc'); // should run func - assert.equal( - object.get('inc'), - ret1, - 'multiple calls should not run cached prop' - ); + assert.equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); object.set('changer', 'bar'); - assert.equal( - object.get('inc'), - ret1 + 1, - 'should increment after dependent key changes' - ); // should run again + assert.equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again } ['@test just notifying change of dependent should clear cache'](assert) { // call get several times to collect call count var ret1 = object.get('inc'); // should run func - assert.equal( - object.get('inc'), - ret1, - 'multiple calls should not run cached prop' - ); + assert.equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); object.notifyPropertyChange('changer'); - assert.equal( - object.get('inc'), - ret1 + 1, - 'should increment after dependent key changes' - ); // should run again + assert.equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again } ['@test changing dependent should clear nested cache'](assert) { // call get several times to collect call count var ret1 = object.get('nestedInc'); // should run func - assert.equal( - object.get('nestedInc'), - ret1, - 'multiple calls should not run cached prop' - ); + assert.equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); object.set('changer', 'bar'); @@ -568,16 +504,10 @@ moduleFor( ); // should run again } - ['@test just notifying change of dependent should clear nested cache']( - assert - ) { + ['@test just notifying change of dependent should clear nested cache'](assert) { // call get several times to collect call count var ret1 = object.get('nestedInc'); // should run func - assert.equal( - object.get('nestedInc'), - ret1, - 'multiple calls should not run cached prop' - ); + assert.equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop'); object.notifyPropertyChange('changer'); @@ -590,24 +520,14 @@ moduleFor( // This verifies a specific bug encountered where observers for computed // properties would fire before their prop caches were cleared. - ['@test change dependent should clear cache when observers of dependent are called']( - assert - ) { + ['@test change dependent should clear cache when observers of dependent are called'](assert) { // call get several times to collect call count var ret1 = object.get('inc'); // should run func - assert.equal( - object.get('inc'), - ret1, - 'multiple calls should not run cached prop' - ); + assert.equal(object.get('inc'), ret1, 'multiple calls should not run cached prop'); // add observer to verify change... object.addObserver('inc', this, function() { - assert.equal( - object.get('inc'), - ret1 + 1, - 'should increment after dependent key changes' - ); // should run again + assert.equal(object.get('inc'), ret1 + 1, 'should increment after dependent key changes'); // should run again }); // now run @@ -627,24 +547,18 @@ moduleFor( assert.equal(object.get('isOn'), false, 'object.isOn should be false'); } - ['@test dependent keys should be able to be specified as property paths']( - assert - ) { + ['@test dependent keys should be able to be specified as property paths'](assert) { var depObj = ObservableObject.extend({ menuPrice: computed(function() { return this.get('menu.price'); - }).property('menu.price') + }).property('menu.price'), }).create({ menu: ObservableObject.create({ - price: 5 - }) + price: 5, + }), }); - assert.equal( - depObj.get('menuPrice'), - 5, - 'precond - initial value returns 5' - ); + assert.equal(depObj.get('menuPrice'), 5, 'precond - initial value returns 5'); depObj.set('menu.price', 6); @@ -655,9 +569,7 @@ moduleFor( ); } - ['@test cacheable nested dependent keys should clear after their dependencies update']( - assert - ) { + ['@test cacheable nested dependent keys should clear after their dependencies update'](assert) { assert.ok(true); var DepObj; @@ -666,21 +578,17 @@ moduleFor( lookup.DepObj = DepObj = ObservableObject.extend({ price: computed('restaurant.menu.price', function() { return this.get('restaurant.menu.price'); - }) + }), }).create({ restaurant: ObservableObject.create({ menu: ObservableObject.create({ - price: 5 - }) - }) + price: 5, + }), + }), }); }); - assert.equal( - DepObj.get('price'), - 5, - 'precond - computed property is correct' - ); + assert.equal(DepObj.get('price'), 5, 'precond - computed property is correct'); run(function() { DepObj.set('restaurant.menu.price', 10); @@ -709,7 +617,7 @@ moduleFor( DepObj.set( 'restaurant.menu', ObservableObject.create({ - price: 15 + price: 15, }) ); }); @@ -724,7 +632,7 @@ moduleFor( DepObj.set( 'restaurant.menu', ObservableObject.create({ - price: 25 + price: 25, }) ); }); @@ -766,7 +674,7 @@ moduleFor( testArrayObserver: observer('normalArray.[]', function() { this.abnormal = 'notifiedObserver'; - }) + }), }).create({ normal: 'value', abnormal: 'zeroValue', @@ -774,7 +682,7 @@ moduleFor( toggleVal: true, observedProperty: 'beingWatched', testRemove: 'observerToBeRemoved', - normalArray: emberA([1, 2, 3, 4, 5]) + normalArray: emberA([1, 2, 3, 4, 5]), }); } @@ -787,25 +695,13 @@ moduleFor( assert.equal(23, newValue, 'numerical value decremented'); object.numberVal = 25; newValue = object.incrementProperty('numberVal', 5); - assert.equal( - 30, - newValue, - 'numerical value incremented by specified increment' - ); + assert.equal(30, newValue, 'numerical value incremented by specified increment'); object.numberVal = 25; newValue = object.incrementProperty('numberVal', -5); - assert.equal( - 20, - newValue, - 'minus numerical value incremented by specified increment' - ); + assert.equal(20, newValue, 'minus numerical value incremented by specified increment'); object.numberVal = 25; newValue = object.incrementProperty('numberVal', 0); - assert.equal( - 25, - newValue, - 'zero numerical value incremented by specified increment' - ); + assert.equal(25, newValue, 'zero numerical value incremented by specified increment'); expectAssertion(function() { newValue = object.incrementProperty('numberVal', 0 - void 0); // Increment by NaN @@ -827,25 +723,13 @@ moduleFor( object.numberVal = 25; newValue = object.decrementProperty('numberVal', 5); - assert.equal( - 20, - newValue, - 'numerical value decremented by specified increment' - ); + assert.equal(20, newValue, 'numerical value decremented by specified increment'); object.numberVal = 25; newValue = object.decrementProperty('numberVal', -5); - assert.equal( - 30, - newValue, - 'minus numerical value decremented by specified increment' - ); + assert.equal(30, newValue, 'minus numerical value decremented by specified increment'); object.numberVal = 25; newValue = object.decrementProperty('numberVal', 0); - assert.equal( - 25, - newValue, - 'zero numerical value decremented by specified increment' - ); + assert.equal(25, newValue, 'zero numerical value decremented by specified increment'); expectAssertion(function() { newValue = object.decrementProperty('numberVal', 0 - void 0); // Decrement by NaN @@ -867,14 +751,8 @@ moduleFor( } ['@test toggle function, should be boolean'](assert) { - assert.equal( - object.toggleProperty('toggleVal', true, false), - object.get('toggleVal') - ); - assert.equal( - object.toggleProperty('toggleVal', true, false), - object.get('toggleVal') - ); + assert.equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); + assert.equal(object.toggleProperty('toggleVal', true, false), object.get('toggleVal')); assert.equal( object.toggleProperty('toggleVal', undefined, undefined), object.get('toggleVal') @@ -883,11 +761,7 @@ moduleFor( ['@test should notify array observer when array changes'](assert) { get(object, 'normalArray').replace(0, 0, [6]); - assert.equal( - object.abnormal, - 'notifiedObserver', - 'observer should be notified' - ); + assert.equal(object.abnormal, 'notifiedObserver', 'observer should be notified'); } } ); @@ -898,7 +772,7 @@ moduleFor( beforeEach() { ObjectC = ObservableObject.create({ objectE: ObservableObject.create({ - propertyVal: 'chainedProperty' + propertyVal: 'chainedProperty', }), normal: 'value', @@ -916,7 +790,7 @@ moduleFor( chainedObserver() { this.normal2 = 'chainedPropertyObserved'; - } + }, }); } @@ -945,7 +819,7 @@ moduleFor( beforeEach() { ObjectD = ObservableObject.create({ objectF: ObservableObject.create({ - propertyVal: 'chainedProperty' + propertyVal: 'chainedProperty', }), normal: 'value', @@ -976,7 +850,7 @@ moduleFor( }, observer3() { // Just an observer - } + }, }); } @@ -995,17 +869,9 @@ moduleFor( ["@test should unregister an observer for a property - special case when key has a '.' in it."]( assert ) { - ObjectD.addObserver( - 'objectF.propertyVal', - ObjectD, - 'removeChainedObserver' - ); + ObjectD.addObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); ObjectD.objectF.set('propertyVal', 'chainedPropertyValue'); - ObjectD.removeObserver( - 'objectF.propertyVal', - ObjectD, - 'removeChainedObserver' - ); + ObjectD.removeObserver('objectF.propertyVal', ObjectD, 'removeChainedObserver'); ObjectD.normal2 = 'dependentValue'; ObjectD.objectF.set('propertyVal', 'removedPropertyValue'); assert.equal('dependentValue', ObjectD.normal2); @@ -1013,9 +879,7 @@ moduleFor( assert.equal('dependentValue', ObjectD.normal2); } - ['@test removing an observer inside of an observer shouldn’t cause any problems']( - assert - ) { + ['@test removing an observer inside of an observer shouldn’t cause any problems'](assert) { // The observable system should be protected against clients removing // observers in the middle of observer notification. var encounteredError = false; diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js index 8d3213b84c3..004f25e0687 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js @@ -44,7 +44,7 @@ moduleFor( starObserver(target, key) { this.starProp = key; - } + }, }).create({ starProp: null, @@ -52,13 +52,11 @@ moduleFor( prop: 'propValue', newFoo: 'newFooValue', - newProp: 'newPropValue' + newProp: 'newPropValue', }); } - ['@test should observe the changes within the nested begin / end property changes']( - assert - ) { + ['@test should observe the changes within the nested begin / end property changes'](assert) { //start the outer nest ObjectA.beginPropertyChanges(); @@ -80,9 +78,7 @@ moduleFor( assert.equal(ObjectA.newFoo, 'changedNewFooValue'); } - ['@test should observe the changes within the begin and end property changes']( - assert - ) { + ['@test should observe the changes within the begin and end property changes'](assert) { ObjectA.beginPropertyChanges(); ObjectA.set('foo', 'changeFooValue'); @@ -92,9 +88,7 @@ moduleFor( assert.equal(ObjectA.prop, 'changedPropValue'); } - ['@test should indicate that the property of an object has just changed']( - assert - ) { + ['@test should indicate that the property of an object has just changed'](assert) { //change the value of foo. ObjectA.set('foo', 'changeFooValue'); @@ -126,18 +120,14 @@ moduleFor( set(key, value) { this._b = value; return this; - } - }).volatile() + }, + }).volatile(), }).create({ - _b: null + _b: null, }); a.set('b', 'foo'); - assert.equal( - a.get('b'), - 'foo', - 'should have set the correct value for property b' - ); + assert.equal(a.get('b'), 'foo', 'should have set the correct value for property b'); a._b = 'bar'; a.notifyPropertyChange('b'); diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js index d97f684d357..ee0d337de21 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js @@ -42,7 +42,7 @@ moduleFor( }, aMethodThatReturnsFalse() { return false; - } + }, }); } @@ -50,16 +50,12 @@ moduleFor( obj = undefined; } - ['@test Should return its properties when requested using EmberObject#get']( - assert - ) { + ['@test Should return its properties when requested using EmberObject#get'](assert) { assert.equal(get(obj, 'foo'), 'bar'); assert.equal(get(obj, 'total'), 12345); } - ['@test Should allow changing of those properties by calling EmberObject#set']( - assert - ) { + ['@test Should allow changing of those properties by calling EmberObject#set'](assert) { assert.equal(get(obj, 'foo'), 'bar'); assert.equal(get(obj, 'total'), 12345); @@ -79,7 +75,7 @@ moduleFor( obj = EmberObject.extend({ method1() { return 'hello'; - } + }, }); obj1 = obj.extend(); } @@ -89,16 +85,12 @@ moduleFor( obj1 = undefined; } - ['@test Checking the detect() function on an object and its subclass']( - assert - ) { + ['@test Checking the detect() function on an object and its subclass'](assert) { assert.equal(obj.detect(obj1), true); assert.equal(obj1.detect(obj), false); } - ['@test Checking the detectInstance() function on an object and its subclass']( - assert - ) { + ['@test Checking the detectInstance() function on an object and its subclass'](assert) { assert.ok(EmberObject.detectInstance(obj.create())); assert.ok(obj.detectInstance(obj.create())); } diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js index c6673870076..5418203784d 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js @@ -27,13 +27,13 @@ moduleFor( klass = EmberObject.extend({ concatenatedProperties: ['values', 'functions'], values: ['a', 'b', 'c'], - functions: [K] + functions: [K], }); } ['@test concatenates instances'](assert) { let obj = klass.create({ - values: ['d', 'e', 'f'] + values: ['d', 'e', 'f'], }); let values = get(obj, 'values'); @@ -48,7 +48,7 @@ moduleFor( ['@test concatenates subclasses'](assert) { let subKlass = klass.extend({ - values: ['d', 'e', 'f'] + values: ['d', 'e', 'f'], }); let obj = subKlass.create(); @@ -64,7 +64,7 @@ moduleFor( ['@test concatenates reopen'](assert) { klass.reopen({ - values: ['d', 'e', 'f'] + values: ['d', 'e', 'f'], }); let obj = klass.create(); @@ -80,10 +80,10 @@ moduleFor( ['@test concatenates mixin'](assert) { let mixin = { - values: ['d', 'e'] + values: ['d', 'e'], }; let subKlass = klass.extend(mixin, { - values: ['f'] + values: ['f'], }); let obj = subKlass.create(); @@ -114,7 +114,7 @@ moduleFor( ['@test concatenates subclasses when the values are functions'](assert) { let subKlass = klass.extend({ - functions: K + functions: K, }); let obj = subKlass.create(); diff --git a/packages/ember-runtime/tests/main_test.js b/packages/ember-runtime/tests/main_test.js index 73390730c67..0656e0e42c4 100644 --- a/packages/ember-runtime/tests/main_test.js +++ b/packages/ember-runtime/tests/main_test.js @@ -6,13 +6,13 @@ moduleFor( class extends AbstractTestCase { ['@test Ember.computed.collect'](assert) { let MyObj = EmberObject.extend({ - props: collect('foo', 'bar', 'baz') + props: collect('foo', 'bar', 'baz'), }); let myObj = MyObj.create({ foo: 3, bar: 5, - baz: 'asdf' + baz: 'asdf', }); let propsValue = myObj.get('props'); diff --git a/packages/ember-runtime/tests/mixins/array_test.js b/packages/ember-runtime/tests/mixins/array_test.js index 5159eb45464..705d1daf7c4 100644 --- a/packages/ember-runtime/tests/mixins/array_test.js +++ b/packages/ember-runtime/tests/mixins/array_test.js @@ -8,7 +8,7 @@ import { addArrayObserver, removeArrayObserver, arrayContentDidChange, - arrayContentWillChange + arrayContentWillChange, } from 'ember-metal'; import EmberObject from '../../system/object'; import EmberArray from '../../mixins/array'; @@ -48,7 +48,7 @@ const TestArray = EmberObject.extend(EmberArray, { length: computed(function() { return this._content.length; - }) + }), }); moduleFor( @@ -56,7 +56,7 @@ moduleFor( class extends AbstractTestCase { ['@test the return value of slice has Ember.Array applied'](assert) { let x = EmberObject.extend(EmberArray).create({ - length: 0 + length: 0, }); let y = x.slice(1); assert.equal(EmberArray.detect(y), true, 'mixin should be applied'); @@ -89,7 +89,7 @@ const DummyArray = EmberObject.extend(EmberArray, { length: 0, objectAt(idx) { return 'ITEM-' + idx; - } + }, }); let obj, observer; @@ -105,9 +105,9 @@ moduleFor( obj = DummyArray.extend({ enumerablePropertyDidChange: emberObserver('[]', function() { this._count++; - }) + }), }).create({ - _count: 0 + _count: 0, }); assert.equal(obj._count, 0, 'should not have invoked yet'); @@ -131,9 +131,9 @@ moduleFor( obj = DummyArray.extend({ lengthDidChange: emberObserver('length', function() { this._after++; - }) + }), }).create({ - _after: 0 + _after: 0, }); assert.equal(obj._after, 0, 'should not have fired yet'); @@ -189,10 +189,10 @@ moduleFor( arrayDidChange() { assert.equal(this._after, null); // should only call once this._after = Array.prototype.slice.call(arguments); - } + }, }).create({ _before: null, - _after: null + _after: null, }); addArrayObserver(obj, observer); @@ -253,8 +253,8 @@ moduleFor( { isDone: true, desc: 'Todo 1' }, { isDone: false, desc: 'Todo 2' }, { isDone: true, desc: 'Todo 3' }, - { isDone: false, desc: 'Todo 4' } - ] + { isDone: false, desc: 'Todo 4' }, + ], }); } @@ -268,7 +268,7 @@ moduleFor( let observerObject = EmberObject.create({ wasCalled() { called++; - } + }, }); addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); @@ -276,7 +276,7 @@ moduleFor( ary.addObject( EmberObject.create({ desc: 'foo', - isDone: false + isDone: false, }) ); @@ -299,21 +299,19 @@ moduleFor( }, /Cannot set read-only property "@each"/); } - ['@test using @each to observe arrays that does not return objects raise error']( - assert - ) { + ['@test using @each to observe arrays that does not return objects raise error'](assert) { let called = 0; let observerObject = EmberObject.create({ wasCalled() { called++; - } + }, }); ary = TestArray.create({ objectAt(idx) { return get(this._content[idx], 'desc'); - } + }, }); addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); @@ -322,7 +320,7 @@ moduleFor( ary.addObject( EmberObject.create({ desc: 'foo', - isDone: false + isDone: false, }) ); }, /When using @each to observe the array/); @@ -330,9 +328,7 @@ moduleFor( assert.equal(called, 0, 'not calls observer when object is pushed'); } - ['@test modifying the array should also indicate the isDone prop itself has changed']( - assert - ) { + ['@test modifying the array should also indicate the isDone prop itself has changed'](assert) { // NOTE: we never actually get the '@each.isDone' property here. This is // important because it tests the case where we don't have an isDone // EachArray materialized but just want to know when the property has @@ -368,7 +364,7 @@ moduleFor( common: computed('resources.@each.common', function() { return get(objectAt(get(this, 'resources'), 0), 'common'); - }) + }), }).create(); get(obj, 'resources').pushObject(EmberObject.create({ common: 'HI!' })); @@ -390,7 +386,7 @@ moduleFor( set(this, 'resources', emberA()); }, - commonDidChange: emberObserver('resources.@each.common', () => count++) + commonDidChange: emberObserver('resources.@each.common', () => count++), }).create(); // Observer fires second time when new object is added diff --git a/packages/ember-runtime/tests/mixins/comparable_test.js b/packages/ember-runtime/tests/mixins/comparable_test.js index df8fb596f61..7c6be34109c 100644 --- a/packages/ember-runtime/tests/mixins/comparable_test.js +++ b/packages/ember-runtime/tests/mixins/comparable_test.js @@ -14,7 +14,7 @@ const Rectangle = EmberObject.extend(Comparable, { compare(a, b) { return compare(a.area(), b.area()); - } + }, }); let r1, r2; diff --git a/packages/ember-runtime/tests/mixins/container_proxy_test.js b/packages/ember-runtime/tests/mixins/container_proxy_test.js index 15c08b3fdd9..dbaf1744283 100644 --- a/packages/ember-runtime/tests/mixins/container_proxy_test.js +++ b/packages/ember-runtime/tests/mixins/container_proxy_test.js @@ -14,18 +14,14 @@ moduleFor( let registry = new Registry(); this.instance.__container__ = new Container(registry, { - owner: this.instance + owner: this.instance, }); } ['@test provides ownerInjection helper method'](assert) { let result = this.instance.ownerInjection(); - assert.equal( - result[OWNER], - this.instance, - 'returns an object with the OWNER symbol' - ); + assert.equal(result[OWNER], this.instance, 'returns an object with the OWNER symbol'); } } ); diff --git a/packages/ember-runtime/tests/mixins/evented_test.js b/packages/ember-runtime/tests/mixins/evented_test.js index 6e4db483bdd..305864bdfd8 100644 --- a/packages/ember-runtime/tests/mixins/evented_test.js +++ b/packages/ember-runtime/tests/mixins/evented_test.js @@ -9,7 +9,7 @@ moduleFor( let eventedProxyObj = CoreObject.extend(EventedMixin, { unknownProperty() { return true; - } + }, }).create(); let noop = function() {}; diff --git a/packages/ember-runtime/tests/mixins/observable_test.js b/packages/ember-runtime/tests/mixins/observable_test.js index 354eddaf158..efd61f5980a 100644 --- a/packages/ember-runtime/tests/mixins/observable_test.js +++ b/packages/ember-runtime/tests/mixins/observable_test.js @@ -5,13 +5,11 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'mixins/observable', class extends AbstractTestCase { - ['@test should be able to use getProperties to get a POJO of provided keys']( - assert - ) { + ['@test should be able to use getProperties to get a POJO of provided keys'](assert) { let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', - companyName: 'Apple, Inc.' + companyName: 'Apple, Inc.', }); let pojo = obj.getProperties('firstName', 'lastName'); @@ -25,7 +23,7 @@ moduleFor( let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', - companyName: 'Apple, Inc.' + companyName: 'Apple, Inc.', }); let pojo = obj.getProperties(['firstName', 'lastName']); @@ -33,13 +31,11 @@ moduleFor( assert.equal('Jobs', pojo.lastName); } - ['@test should be able to use setProperties to set multiple properties at once']( - assert - ) { + ['@test should be able to use setProperties to set multiple properties at once'](assert) { let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', - companyName: 'Apple, Inc.' + companyName: 'Apple, Inc.', }); obj.setProperties({ firstName: 'Tim', lastName: 'Cook' }); @@ -47,9 +43,7 @@ moduleFor( assert.equal('Cook', obj.get('lastName')); } - ['@test calling setProperties completes safely despite exceptions']( - assert - ) { + ['@test calling setProperties completes safely despite exceptions'](assert) { let exc = new Error('Something unexpected happened!'); let obj = EmberObject.extend({ companyName: computed({ @@ -58,11 +52,11 @@ moduleFor( }, set() { throw exc; - } - }) + }, + }), }).create({ firstName: 'Steve', - lastName: 'Jobs' + lastName: 'Jobs', }); let firstNameChangedCount = 0; @@ -73,7 +67,7 @@ moduleFor( obj.setProperties({ firstName: 'Tim', lastName: 'Cook', - companyName: 'Fruit Co., Inc.' + companyName: 'Fruit Co., Inc.', }); } catch (err) { if (err !== exc) { @@ -81,11 +75,7 @@ moduleFor( } } - assert.equal( - firstNameChangedCount, - 1, - 'firstName should have fired once' - ); + assert.equal(firstNameChangedCount, 1, 'firstName should have fired once'); } ['@test should be able to retrieve cached values of computed properties without invoking the computed property']( @@ -94,9 +84,9 @@ moduleFor( let obj = EmberObject.extend({ foo: computed(function() { return 'foo'; - }) + }), }).create({ - bar: 'bar' + bar: 'bar', }); assert.equal( @@ -120,11 +110,9 @@ moduleFor( ); } - ['@test incrementProperty should work even if value is number in string']( - assert - ) { + ['@test incrementProperty should work even if value is number in string'](assert) { let obj = EmberObject.create({ - age: '24' + age: '24', }); obj.incrementProperty('age'); assert.equal(25, obj.get('age')); diff --git a/packages/ember-runtime/tests/mixins/promise_proxy_test.js b/packages/ember-runtime/tests/mixins/promise_proxy_test.js index 329a8d5f84f..33dbe770c40 100644 --- a/packages/ember-runtime/tests/mixins/promise_proxy_test.js +++ b/packages/ember-runtime/tests/mixins/promise_proxy_test.js @@ -41,13 +41,13 @@ moduleFor( ['@test fulfillment'](assert) { let value = { firstName: 'stef', - lastName: 'penner' + lastName: 'penner', }; let deferred = RSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); let didFulfillCount = 0; @@ -55,16 +55,8 @@ moduleFor( proxy.then(() => didFulfillCount++, () => didRejectCount++); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy to have no reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); assert.equal( get(proxy, 'isPending'), true, @@ -94,16 +86,8 @@ moduleFor( assert.equal(didFulfillCount, 1, 'should have been fulfilled'); assert.equal(didRejectCount, 0, 'should not have been rejected'); - assert.equal( - get(proxy, 'content'), - value, - 'expects the proxy to have content' - ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy to still have no reason' - ); + assert.equal(get(proxy, 'content'), value, 'expects the proxy to have content'); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy to still have no reason'); assert.equal( get(proxy, 'isPending'), false, @@ -127,20 +111,12 @@ moduleFor( run(deferred, 'resolve', value); - assert.equal( - didFulfillCount, - 1, - 'should still have been only fulfilled once' - ); + assert.equal(didFulfillCount, 1, 'should still have been only fulfilled once'); assert.equal(didRejectCount, 0, 'should still not have been rejected'); run(deferred, 'reject', value); - assert.equal( - didFulfillCount, - 1, - 'should still have been only fulfilled once' - ); + assert.equal(didFulfillCount, 1, 'should still have been only fulfilled once'); assert.equal(didRejectCount, 0, 'should still not have been rejected'); assert.equal( @@ -148,11 +124,7 @@ moduleFor( value, 'expects the proxy to have still have same content' ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy still to have no reason' - ); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy still to have no reason'); assert.equal( get(proxy, 'isPending'), false, @@ -181,7 +153,7 @@ moduleFor( let reason = new Error('failure'); let deferred = RSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); let didFulfillCount = 0; @@ -189,16 +161,8 @@ moduleFor( proxy.then(() => didFulfillCount++, () => didRejectCount++); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy to have no reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); assert.equal( get(proxy, 'isPending'), true, @@ -228,16 +192,8 @@ moduleFor( assert.equal(didFulfillCount, 0, 'should not yet have been fulfilled'); assert.equal(didRejectCount, 1, 'should have been rejected'); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - reason, - 'expects the proxy to have a reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); assert.equal( get(proxy, 'isPending'), false, @@ -261,32 +217,16 @@ moduleFor( run(deferred, 'reject', reason); - assert.equal( - didFulfillCount, - 0, - 'should stll not yet have been fulfilled' - ); + assert.equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); assert.equal(didRejectCount, 1, 'should still remain rejected'); run(deferred, 'resolve', 1); - assert.equal( - didFulfillCount, - 0, - 'should stll not yet have been fulfilled' - ); + assert.equal(didFulfillCount, 0, 'should stll not yet have been fulfilled'); assert.equal(didRejectCount, 1, 'should still remain rejected'); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - reason, - 'expects the proxy to have a reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), reason, 'expects the proxy to have a reason'); assert.equal( get(proxy, 'isPending'), false, @@ -313,7 +253,7 @@ moduleFor( ['@test rejection without specifying reason'](assert) { let deferred = RSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); let didFulfillCount = 0; @@ -321,16 +261,8 @@ moduleFor( proxy.then(() => didFulfillCount++, () => didRejectCount++); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy to have no reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); assert.equal( get(proxy, 'isPending'), true, @@ -360,16 +292,8 @@ moduleFor( assert.equal(didFulfillCount, 0, 'should not yet have been fulfilled'); assert.equal(didRejectCount, 1, 'should have been rejected'); - assert.equal( - get(proxy, 'content'), - undefined, - 'expects the proxy to have no content' - ); - assert.equal( - get(proxy, 'reason'), - undefined, - 'expects the proxy to have a reason' - ); + assert.equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); + assert.equal(get(proxy, 'reason'), undefined, 'expects the proxy to have a reason'); assert.equal( get(proxy, 'isPending'), false, @@ -392,9 +316,7 @@ moduleFor( ); } - ["@test unhandled rejects still propagate to RSVP.on('error', ...) "]( - assert - ) { + ["@test unhandled rejects still propagate to RSVP.on('error', ...) "](assert) { assert.expect(1); RSVP.on('error', onerror); @@ -404,7 +326,7 @@ moduleFor( let deferred = RSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); proxy.get('promise'); @@ -431,22 +353,17 @@ moduleFor( class PromiseSubclass extends RSVP.Promise {} let proxy = ObjectPromiseProxy.create({ - promise: new PromiseSubclass(() => {}) + promise: new PromiseSubclass(() => {}), }); - assert.ok( - proxy.then() instanceof PromiseSubclass, - 'promise proxy respected inheritance' - ); + assert.ok(proxy.then() instanceof PromiseSubclass, 'promise proxy respected inheritance'); } - ['@test should reset isFulfilled and isRejected when promise is reset']( - assert - ) { + ['@test should reset isFulfilled and isRejected when promise is reset'](assert) { let deferred = EmberRSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); assert.equal( @@ -545,12 +462,10 @@ moduleFor( let deferred = EmberRSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); - proxy.addObserver('isFulfilled', () => - assert.equal(get(proxy, 'content'), true) - ); + proxy.addObserver('isFulfilled', () => assert.equal(get(proxy, 'content'), true)); run(deferred, 'resolve', true); } @@ -560,12 +475,10 @@ moduleFor( let deferred = EmberRSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); - proxy.addObserver('isRejected', () => - assert.equal(get(proxy, 'reason'), error) - ); + proxy.addObserver('isRejected', () => assert.equal(get(proxy, 'reason'), error)); try { run(deferred, 'reject', error); @@ -574,13 +487,11 @@ moduleFor( } } - ['@test should not error if promise is resolved after proxy has been destroyed']( - assert - ) { + ['@test should not error if promise is resolved after proxy has been destroyed'](assert) { let deferred = EmberRSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); proxy.then(() => {}, () => {}); @@ -595,13 +506,11 @@ moduleFor( ); } - ['@test should not error if promise is rejected after proxy has been destroyed']( - assert - ) { + ['@test should not error if promise is rejected after proxy has been destroyed'](assert) { let deferred = EmberRSVP.defer(); let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); proxy.then(() => {}, () => {}); @@ -625,7 +534,7 @@ moduleFor( let didResolveCount = 0; let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); proxy.then( @@ -657,7 +566,7 @@ moduleFor( let didRejectCount = 0; let proxy = ObjectPromiseProxy.create({ - promise: deferred.promise + promise: deferred.promise, }); proxy.then( diff --git a/packages/ember-runtime/tests/mixins/target_action_support_test.js b/packages/ember-runtime/tests/mixins/target_action_support_test.js index d38da81e3da..3c93b97f0c4 100644 --- a/packages/ember-runtime/tests/mixins/target_action_support_test.js +++ b/packages/ember-runtime/tests/mixins/target_action_support_test.js @@ -17,17 +17,12 @@ moduleFor( context.lookup = originalLookup; } - ['@test it should return false if no target or action are specified']( - assert - ) { + ['@test it should return false if no target or action are specified'](assert) { assert.expect(1); let obj = EmberObject.extend(TargetActionSupport).create(); - assert.ok( - false === obj.triggerAction(), - 'no target or action was specified' - ); + assert.ok(false === obj.triggerAction(), 'no target or action was specified'); } ['@test it should support actions specified as strings'](assert) { @@ -37,46 +32,30 @@ moduleFor( target: EmberObject.create({ anEvent() { assert.ok(true, 'anEvent method was called'); - } + }, }), - action: 'anEvent' + action: 'anEvent', }); - assert.ok( - true === obj.triggerAction(), - 'a valid target and action were specified' - ); + assert.ok(true === obj.triggerAction(), 'a valid target and action were specified'); } - ['@test it should invoke the send() method on objects that implement it']( - assert - ) { + ['@test it should invoke the send() method on objects that implement it'](assert) { assert.expect(3); let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ send(evt, context) { - assert.equal( - evt, - 'anEvent', - 'send() method was invoked with correct event name' - ); - assert.equal( - context, - obj, - 'send() method was invoked with correct context' - ); - } + assert.equal(evt, 'anEvent', 'send() method was invoked with correct event name'); + assert.equal(context, obj, 'send() method was invoked with correct context'); + }, }), - action: 'anEvent' + action: 'anEvent', }); - assert.ok( - true === obj.triggerAction(), - 'a valid target and action were specified' - ); + assert.ok(true === obj.triggerAction(), 'a valid target and action were specified'); } ['@test it should find targets specified using a property path'](assert) { @@ -88,23 +67,18 @@ moduleFor( Test.targetObj = EmberObject.create({ anEvent() { assert.ok(true, 'anEvent method was called on global object'); - } + }, }); let myObj = EmberObject.extend(TargetActionSupport).create({ target: 'Test.targetObj', - action: 'anEvent' + action: 'anEvent', }); - assert.ok( - true === myObj.triggerAction(), - 'a valid target and action were specified' - ); + assert.ok(true === myObj.triggerAction(), 'a valid target and action were specified'); } - ['@test it should use an actionContext object specified as a property on the object']( - assert - ) { + ['@test it should use an actionContext object specified as a property on the object'](assert) { assert.expect(2); let obj = EmberObject.extend(TargetActionSupport).create({ action: 'anEvent', @@ -115,13 +89,10 @@ moduleFor( obj.actionContext === ctx, 'anEvent method was called with the expected context' ); - } - }) + }, + }), }); - assert.ok( - true === obj.triggerAction(), - 'a valid target and action were specified' - ); + assert.ok(true === obj.triggerAction(), 'a valid target and action were specified'); } ['@test it should raise a deprecation warning when targetObject is specified and used']( @@ -139,23 +110,18 @@ moduleFor( obj.actionContext === ctx, 'anEvent method was called with the expected context' ); - } - }) + }, + }), }); }, /Usage of `targetObject` is deprecated. Please use `target` instead./); - assert.ok( - true === obj.triggerAction(), - 'a valid targetObject and action were specified' - ); + assert.ok(true === obj.triggerAction(), 'a valid targetObject and action were specified'); expectDeprecation( () => obj.get('targetObject'), /Usage of `targetObject` is deprecated. Please use `target` instead./ ); } - ['@test it should find an actionContext specified as a property path']( - assert - ) { + ['@test it should find an actionContext specified as a property path'](assert) { assert.expect(2); let Test = {}; @@ -167,18 +133,12 @@ moduleFor( actionContext: 'Test.aContext', target: EmberObject.create({ anEvent(ctx) { - assert.ok( - Test.aContext === ctx, - 'anEvent method was called with the expected context' - ); - } - }) + assert.ok(Test.aContext === ctx, 'anEvent method was called with the expected context'); + }, + }), }); - assert.ok( - true === obj.triggerAction(), - 'a valid target and action were specified' - ); + assert.ok(true === obj.triggerAction(), 'a valid target and action were specified'); } ['@test it should use the target specified in the argument'](assert) { @@ -186,10 +146,10 @@ moduleFor( let targetObj = EmberObject.create({ anEvent() { assert.ok(true, 'anEvent method was called'); - } + }, }); let obj = EmberObject.extend(TargetActionSupport).create({ - action: 'anEvent' + action: 'anEvent', }); assert.ok( @@ -205,8 +165,8 @@ moduleFor( target: EmberObject.create({ anEvent() { assert.ok(true, 'anEvent method was called'); - } - }) + }, + }), }); assert.ok( true === obj.triggerAction({ action: 'anEvent' }), @@ -214,21 +174,16 @@ moduleFor( ); } - ['@test it should use the actionContext specified in the argument']( - assert - ) { + ['@test it should use the actionContext specified in the argument'](assert) { assert.expect(2); let context = {}; let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent(ctx) { - assert.ok( - context === ctx, - 'anEvent method was called with the expected context' - ); - } + assert.ok(context === ctx, 'anEvent method was called with the expected context'); + }, }), - action: 'anEvent' + action: 'anEvent', }); assert.ok( @@ -252,9 +207,9 @@ moduleFor( second === param2, 'anEvent method was called with the expected second argument' ); - } + }, }), - action: 'anEvent' + action: 'anEvent', }); assert.ok( @@ -263,20 +218,15 @@ moduleFor( ); } - ['@test it should use a null value specified in the actionContext argument']( - assert - ) { + ['@test it should use a null value specified in the actionContext argument'](assert) { assert.expect(2); let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent(ctx) { - assert.ok( - null === ctx, - 'anEvent method was called with the expected context (null)' - ); - } + assert.ok(null === ctx, 'anEvent method was called with the expected context (null)'); + }, }), - action: 'anEvent' + action: 'anEvent', }); assert.ok( true === obj.triggerAction({ actionContext: null }), diff --git a/packages/ember-runtime/tests/mutable-array/addObject-test.js b/packages/ember-runtime/tests/mutable-array/addObject-test.js index e402e3f3d7e..66b562261f4 100644 --- a/packages/ember-runtime/tests/mutable-array/addObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/addObject-test.js @@ -14,14 +14,7 @@ class AddObjectTest extends AbstractTestCase { let item = newFixture(1)[0]; let after = [before[0], before[1], item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -31,21 +24,9 @@ class AddObjectTest extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -65,14 +46,7 @@ class AddObjectTest extends AbstractTestCase { let after = before; let item = before[0]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -82,21 +56,9 @@ class AddObjectTest extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.validate('[]'), - false, - 'should NOT have notified []' - ); - this.assert.equal( - observer.validate('@each'), - false, - 'should NOT have notified @each' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length' - ); + this.assert.equal(observer.validate('[]'), false, 'should NOT have notified []'); + this.assert.equal(observer.validate('@each'), false, 'should NOT have notified @each'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length'); this.assert.equal( observer.validate('firstObject'), false, @@ -111,10 +73,4 @@ class AddObjectTest extends AbstractTestCase { } } -runArrayTests( - 'addObject', - AddObjectTest, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('addObject', AddObjectTest, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/clear-test.js b/packages/ember-runtime/tests/mutable-array/clear-test.js index c6314dcfb21..a2fc6c8d582 100644 --- a/packages/ember-runtime/tests/mutable-array/clear-test.js +++ b/packages/ember-runtime/tests/mutable-array/clear-test.js @@ -7,14 +7,7 @@ class ClearTests extends AbstractTestCase { let before = []; let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -23,21 +16,9 @@ class ClearTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.validate('[]'), - false, - 'should NOT have notified [] once' - ); - this.assert.equal( - observer.validate('@each'), - false, - 'should NOT have notified @each once' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length once' - ); + this.assert.equal(observer.validate('[]'), false, 'should NOT have notified [] once'); + this.assert.equal(observer.validate('@each'), false, 'should NOT have notified @each once'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length once'); this.assert.equal( observer.validate('firstObject'), false, @@ -56,14 +37,7 @@ class ClearTests extends AbstractTestCase { before = newFixture(1); after = []; obj = this.newObject(before); - observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ this.assert.equal(obj.clear(), obj, 'return self'); @@ -71,21 +45,9 @@ class ClearTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, diff --git a/packages/ember-runtime/tests/mutable-array/insertAt-test.js b/packages/ember-runtime/tests/mutable-array/insertAt-test.js index 56afa48445b..33583c4e305 100644 --- a/packages/ember-runtime/tests/mutable-array/insertAt-test.js +++ b/packages/ember-runtime/tests/mutable-array/insertAt-test.js @@ -6,14 +6,7 @@ class InsertAtTests extends AbstractTestCase { '@test [].insertAt(0, X) => [X] + notify'() { let after = newFixture(1); let obj = this.newObject([]); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -22,11 +15,7 @@ class InsertAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] did change once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] did change once'); this.assert.equal( observer.timesCalled('@each'), 0, @@ -61,14 +50,7 @@ class InsertAtTests extends AbstractTestCase { let before = newFixture(1); let after = [item, before[0]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -77,21 +59,9 @@ class InsertAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -110,14 +80,7 @@ class InsertAtTests extends AbstractTestCase { let before = newFixture(1); let after = [before[0], item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -126,21 +89,9 @@ class InsertAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -166,14 +117,7 @@ class InsertAtTests extends AbstractTestCase { let before = newFixture(3); let after = [item, before[0], before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -182,21 +126,9 @@ class InsertAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -215,14 +147,7 @@ class InsertAtTests extends AbstractTestCase { let before = newFixture(3); let after = [before[0], item, before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); let objectAtCalls = []; let objectAt = obj.objectAt; @@ -236,30 +161,14 @@ class InsertAtTests extends AbstractTestCase { objectAtCalls.splice(0, objectAtCalls.length); obj.insertAt(1, item); - this.assert.deepEqual( - objectAtCalls, - [], - 'objectAt is not called when only inserting items' - ); + this.assert.deepEqual(objectAtCalls, [], 'objectAt is not called when only inserting items'); this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -278,14 +187,7 @@ class InsertAtTests extends AbstractTestCase { let before = newFixture(3); let after = [before[0], before[1], before[2], item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -294,21 +196,9 @@ class InsertAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -323,10 +213,4 @@ class InsertAtTests extends AbstractTestCase { } } -runArrayTests( - 'instertAt', - InsertAtTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('instertAt', InsertAtTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/popObject-test.js b/packages/ember-runtime/tests/mutable-array/popObject-test.js index a17931a4e1e..05e57088f91 100644 --- a/packages/ember-runtime/tests/mutable-array/popObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/popObject-test.js @@ -5,14 +5,7 @@ import { runArrayTests, newFixture } from '../helpers/array'; class PopObjectTests extends AbstractTestCase { '@test [].popObject() => [] + returns undefined + NO notify'() { let obj = this.newObject([]); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -20,21 +13,9 @@ class PopObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), [], 'post item results'); - this.assert.equal( - observer.validate('[]'), - false, - 'should NOT have notified []' - ); - this.assert.equal( - observer.validate('@each'), - false, - 'should NOT have notified @each' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length' - ); + this.assert.equal(observer.validate('[]'), false, 'should NOT have notified []'); + this.assert.equal(observer.validate('@each'), false, 'should NOT have notified @each'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length'); this.assert.equal( observer.validate('firstObject'), false, @@ -51,14 +32,7 @@ class PopObjectTests extends AbstractTestCase { let before = newFixture(1); let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -68,21 +42,9 @@ class PopObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -99,14 +61,7 @@ class PopObjectTests extends AbstractTestCase { let before = newFixture(3); let after = [before[0], before[1]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -116,21 +71,9 @@ class PopObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -145,10 +88,4 @@ class PopObjectTests extends AbstractTestCase { } } -runArrayTests( - 'popObject', - PopObjectTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('popObject', PopObjectTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/pushObject-test.js b/packages/ember-runtime/tests/mutable-array/pushObject-test.js index c0b7de28530..4a62ece3a62 100644 --- a/packages/ember-runtime/tests/mutable-array/pushObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/pushObject-test.js @@ -14,14 +14,7 @@ class PushObjectTests extends AbstractTestCase { let before = []; let after = newFixture(1); let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -30,21 +23,9 @@ class PushObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -62,14 +43,7 @@ class PushObjectTests extends AbstractTestCase { let item = newFixture(1)[0]; let after = [before[0], before[1], before[2], item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -78,21 +52,9 @@ class PushObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -111,14 +73,7 @@ class PushObjectTests extends AbstractTestCase { let item = before[2]; // note same object as current tail. should end up twice let after = [before[0], before[1], before[2], item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -127,39 +82,17 @@ class PushObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), false, 'should NOT have notified firstObject' ); - this.assert.equal( - observer.validate('lastObject'), - true, - 'should have notified lastObject' - ); + this.assert.equal(observer.validate('lastObject'), true, 'should have notified lastObject'); } } -runArrayTests( - 'pushObject', - PushObjectTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('pushObject', PushObjectTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/pushObjects-test.js b/packages/ember-runtime/tests/mutable-array/pushObjects-test.js index c9d41757292..a89d3f97571 100644 --- a/packages/ember-runtime/tests/mutable-array/pushObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/pushObjects-test.js @@ -9,10 +9,4 @@ class PushObjectsTests extends AbstractTestCase { } } -runArrayTests( - 'pushObjects', - PushObjectsTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('pushObjects', PushObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/removeAt-test.js b/packages/ember-runtime/tests/mutable-array/removeAt-test.js index 552687c1119..8e7e126102e 100644 --- a/packages/ember-runtime/tests/mutable-array/removeAt-test.js +++ b/packages/ember-runtime/tests/mutable-array/removeAt-test.js @@ -8,14 +8,7 @@ class RemoveAtTests extends AbstractTestCase { let before = newFixture(1); let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -24,21 +17,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -60,14 +41,7 @@ class RemoveAtTests extends AbstractTestCase { let before = newFixture(2); let after = [before[1]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -76,21 +50,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -108,14 +70,7 @@ class RemoveAtTests extends AbstractTestCase { let before = newFixture(2); let after = [before[0]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -124,21 +79,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -156,14 +99,7 @@ class RemoveAtTests extends AbstractTestCase { let before = newFixture(3); let after = [before[0], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -172,21 +108,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -204,14 +128,7 @@ class RemoveAtTests extends AbstractTestCase { let before = newFixture(4); let after = [before[0], before[3]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -220,21 +137,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -254,14 +159,7 @@ class RemoveAtTests extends AbstractTestCase { before = newFixture(4); after = [before[0], before[3]]; obj = this.newObject(before); - observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ this.assert.equal(obj.removeAt(1, 2), obj, 'return self'); @@ -269,21 +167,9 @@ class RemoveAtTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -298,10 +184,4 @@ class RemoveAtTests extends AbstractTestCase { } } -runArrayTests( - 'removeAt', - RemoveAtTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('removeAt', RemoveAtTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/removeObject-test.js b/packages/ember-runtime/tests/mutable-array/removeObject-test.js index f65c33fe3f2..857b4c4bfa3 100644 --- a/packages/ember-runtime/tests/mutable-array/removeObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/removeObject-test.js @@ -7,25 +7,14 @@ class RemoveObjectTests extends AbstractTestCase { let before = newFixture(3); let obj = this.newObject(before); - this.assert.equal( - obj.removeObject(before[1]), - obj, - 'should return receiver' - ); + this.assert.equal(obj.removeObject(before[1]), obj, 'should return receiver'); } '@test [A,B,C].removeObject(B) => [A,C] + notify'() { let before = newFixture(3); let after = [before[0], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -35,21 +24,9 @@ class RemoveObjectTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -69,14 +46,7 @@ class RemoveObjectTests extends AbstractTestCase { let after = before; let item = newFixture(1)[0]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -86,21 +56,9 @@ class RemoveObjectTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.validate('[]'), - false, - 'should NOT have notified []' - ); - this.assert.equal( - observer.validate('@each'), - false, - 'should NOT have notified @each' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length' - ); + this.assert.equal(observer.validate('[]'), false, 'should NOT have notified []'); + this.assert.equal(observer.validate('@each'), false, 'should NOT have notified @each'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length'); this.assert.equal( observer.validate('firstObject'), @@ -116,10 +74,4 @@ class RemoveObjectTests extends AbstractTestCase { } } -runArrayTests( - 'removeObject', - RemoveObjectTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('removeObject', RemoveObjectTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/removeObjects-test.js b/packages/ember-runtime/tests/mutable-array/removeObjects-test.js index ee682ecc205..d62762b2f0b 100644 --- a/packages/ember-runtime/tests/mutable-array/removeObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/removeObjects-test.js @@ -8,24 +8,14 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newFixture(3)); let obj = before; - this.assert.equal( - obj.removeObjects(before[1]), - obj, - 'should return receiver' - ); + this.assert.equal(obj.removeObjects(before[1]), obj, 'should return receiver'); } '@test [A,B,C].removeObjects([B]) => [A,C] + notify'() { let before = emberA(newFixture(3)); let after = [before[0], before[2]]; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -35,16 +25,8 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -63,13 +45,7 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newObjectsFixture(3)); let after = [before[0], before[2]]; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -79,16 +55,8 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -107,13 +75,7 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newFixture(3)); let after = [before[2]]; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -123,22 +85,10 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); - this.assert.equal( - observer.timesCalled('firstObject'), - 1, - 'should have notified firstObject' - ); + this.assert.equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); this.assert.equal( observer.validate('lastObject'), false, @@ -151,13 +101,7 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newObjectsFixture(3)); let after = [before[2]]; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -167,22 +111,10 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); - this.assert.equal( - observer.timesCalled('firstObject'), - 1, - 'should have notified firstObject' - ); + this.assert.equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); this.assert.equal( observer.validate('lastObject'), false, @@ -195,13 +127,7 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newFixture(3)); let after = []; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -211,27 +137,11 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); - this.assert.equal( - observer.timesCalled('firstObject'), - 1, - 'should have notified firstObject' - ); - this.assert.equal( - observer.timesCalled('lastObject'), - 1, - 'should have notified lastObject' - ); + this.assert.equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + this.assert.equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject'); } } @@ -239,13 +149,7 @@ class RemoveObjectsTests extends AbstractTestCase { let before = emberA(newObjectsFixture(3)); let after = []; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -255,27 +159,11 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); - this.assert.equal( - observer.timesCalled('firstObject'), - 1, - 'should have notified firstObject' - ); - this.assert.equal( - observer.validate('lastObject'), - 1, - 'should have notified lastObject' - ); + this.assert.equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject'); + this.assert.equal(observer.validate('lastObject'), 1, 'should have notified lastObject'); } } @@ -284,13 +172,7 @@ class RemoveObjectsTests extends AbstractTestCase { let after = before; let item = newFixture(1)[0]; let obj = before; - let observer = this.newObserver( - obj, - '[]', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache @@ -300,16 +182,8 @@ class RemoveObjectsTests extends AbstractTestCase { this.assert.equal(get(obj, 'length'), after.length, 'length'); if (observer.isEnabled) { - this.assert.equal( - observer.validate('[]'), - false, - 'should NOT have notified []' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length' - ); + this.assert.equal(observer.validate('[]'), false, 'should NOT have notified []'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length'); this.assert.equal( observer.validate('firstObject'), @@ -325,10 +199,4 @@ class RemoveObjectsTests extends AbstractTestCase { } } -runArrayTests( - 'removeObjects', - RemoveObjectsTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('removeObjects', RemoveObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/replace-test.js b/packages/ember-runtime/tests/mutable-array/replace-test.js index 9da62f448d1..eff2298f72c 100644 --- a/packages/ember-runtime/tests/mutable-array/replace-test.js +++ b/packages/ember-runtime/tests/mutable-array/replace-test.js @@ -5,14 +5,7 @@ class ReplaceTests extends AbstractTestCase { "@test [].replace(0,0,'X') => ['X'] + notify"() { let exp = newFixture(1); let obj = this.newObject([]); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -20,21 +13,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), exp, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -82,14 +63,7 @@ class ReplaceTests extends AbstractTestCase { let after = [before[0], replace[0], before[3]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -97,21 +71,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -131,14 +93,7 @@ class ReplaceTests extends AbstractTestCase { let after = [before[0], replace[0], replace[1], before[3]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -146,21 +101,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.validate('length'), - false, - 'should NOT have notified length' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.validate('length'), false, 'should NOT have notified length'); this.assert.equal( observer.validate('firstObject'), @@ -180,14 +123,7 @@ class ReplaceTests extends AbstractTestCase { let after = [before[0], replace[0], replace[1], before[1]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -195,21 +131,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -228,14 +152,7 @@ class ReplaceTests extends AbstractTestCase { let after = [before[0], before[1]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -243,21 +160,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -276,14 +181,7 @@ class ReplaceTests extends AbstractTestCase { let after = [before[0], before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -291,21 +189,9 @@ class ReplaceTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('lastObject'), 1, @@ -332,10 +218,4 @@ class ReplaceTests extends AbstractTestCase { } } -runArrayTests( - 'replace', - ReplaceTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('replace', ReplaceTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/reverseObjects-test.js b/packages/ember-runtime/tests/mutable-array/reverseObjects-test.js index b6e878a2f8e..fe67cbe63cd 100644 --- a/packages/ember-runtime/tests/mutable-array/reverseObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/reverseObjects-test.js @@ -7,14 +7,7 @@ class ReverseObjectsTests extends AbstractTestCase { let before = newFixture(3); let after = [before[2], before[1], before[0]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -23,21 +16,9 @@ class ReverseObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 0, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 0, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -51,10 +32,4 @@ class ReverseObjectsTests extends AbstractTestCase { } } -runArrayTests( - 'reverseObjects', - ReverseObjectsTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('reverseObjects', ReverseObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/setObjects-test.js b/packages/ember-runtime/tests/mutable-array/setObjects-test.js index 7f6d2adcaa1..dd98e38166c 100644 --- a/packages/ember-runtime/tests/mutable-array/setObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/setObjects-test.js @@ -7,14 +7,7 @@ class SetObjectsTests extends AbstractTestCase { let before = newFixture(3); let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -23,21 +16,9 @@ class SetObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -54,14 +35,7 @@ class SetObjectsTests extends AbstractTestCase { let before = newFixture(3); let after = newFixture(4); let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -70,21 +44,9 @@ class SetObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -98,10 +60,4 @@ class SetObjectsTests extends AbstractTestCase { } } -runArrayTests( - 'setObjects', - SetObjectsTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('setObjects', SetObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/shiftObject-test.js b/packages/ember-runtime/tests/mutable-array/shiftObject-test.js index ccd4d9268c8..3f899c61f62 100644 --- a/packages/ember-runtime/tests/mutable-array/shiftObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/shiftObject-test.js @@ -7,14 +7,7 @@ class ShiftObjectTests extends AbstractTestCase { let before = []; let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -55,14 +48,7 @@ class ShiftObjectTests extends AbstractTestCase { let before = newFixture(1); let after = []; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -71,21 +57,9 @@ class ShiftObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -102,14 +76,7 @@ class ShiftObjectTests extends AbstractTestCase { let before = newFixture(3); let after = [before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -118,21 +85,9 @@ class ShiftObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -147,10 +102,4 @@ class ShiftObjectTests extends AbstractTestCase { } } -runArrayTests( - 'shiftObject', - ShiftObjectTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('shiftObject', ShiftObjectTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/unshiftObject-test.js b/packages/ember-runtime/tests/mutable-array/unshiftObject-test.js index d811daa9118..a69930f473c 100644 --- a/packages/ember-runtime/tests/mutable-array/unshiftObject-test.js +++ b/packages/ember-runtime/tests/mutable-array/unshiftObject-test.js @@ -7,11 +7,7 @@ class UnshiftObjectTests extends AbstractTestCase { let obj = this.newObject([]); let item = newFixture(1)[0]; - this.assert.equal( - obj.unshiftObject(item), - item, - 'should return unshifted object' - ); + this.assert.equal(obj.unshiftObject(item), item, 'should return unshifted object'); } '@test [].unshiftObject(X) => [X] + notify'() { @@ -19,14 +15,7 @@ class UnshiftObjectTests extends AbstractTestCase { let item = newFixture(1)[0]; let after = [item]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -35,21 +24,9 @@ class UnshiftObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -67,14 +44,7 @@ class UnshiftObjectTests extends AbstractTestCase { let item = newFixture(1)[0]; let after = [item, before[0], before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -83,21 +53,9 @@ class UnshiftObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -116,14 +74,7 @@ class UnshiftObjectTests extends AbstractTestCase { let item = before[0]; // note same object as current head. should end up twice let after = [item, before[0], before[1], before[2]]; let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -132,27 +83,11 @@ class UnshiftObjectTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); - this.assert.equal( - observer.validate('firstObject'), - true, - 'should have notified firstObject' - ); + this.assert.equal(observer.validate('firstObject'), true, 'should have notified firstObject'); this.assert.equal( observer.validate('lastObject'), false, @@ -161,10 +96,4 @@ class UnshiftObjectTests extends AbstractTestCase { } } -runArrayTests( - 'unshiftObject', - UnshiftObjectTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('unshiftObject', UnshiftObjectTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/mutable-array/unshiftObjects-test.js b/packages/ember-runtime/tests/mutable-array/unshiftObjects-test.js index 1ddbaa540a8..b37e8a28364 100644 --- a/packages/ember-runtime/tests/mutable-array/unshiftObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/unshiftObjects-test.js @@ -14,14 +14,7 @@ class UnshiftObjectsTests extends AbstractTestCase { let before = []; let items = newFixture(3); let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -30,21 +23,9 @@ class UnshiftObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), items, 'post item results'); this.assert.equal(get(obj, 'length'), items.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -62,14 +43,7 @@ class UnshiftObjectsTests extends AbstractTestCase { let items = newFixture(2); let after = items.concat(before); let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -78,21 +52,9 @@ class UnshiftObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.timesCalled('firstObject'), 1, @@ -111,14 +73,7 @@ class UnshiftObjectsTests extends AbstractTestCase { let items = [before[0], before[1]]; // note same object as current head. should end up twice let after = items.concat(before); let obj = this.newObject(before); - let observer = this.newObserver( - obj, - '[]', - '@each', - 'length', - 'firstObject', - 'lastObject' - ); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -127,21 +82,9 @@ class UnshiftObjectsTests extends AbstractTestCase { this.assert.deepEqual(this.toArray(obj), after, 'post item results'); this.assert.equal(get(obj, 'length'), after.length, 'length'); - this.assert.equal( - observer.timesCalled('[]'), - 1, - 'should have notified [] once' - ); - this.assert.equal( - observer.timesCalled('@each'), - 0, - 'should not have notified @each once' - ); - this.assert.equal( - observer.timesCalled('length'), - 1, - 'should have notified length once' - ); + this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); + this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); + this.assert.equal(observer.timesCalled('length'), 1, 'should have notified length once'); this.assert.equal( observer.validate('firstObject'), @@ -156,10 +99,4 @@ class UnshiftObjectsTests extends AbstractTestCase { } } -runArrayTests( - 'unshiftObjects', - UnshiftObjectsTests, - 'MutableArray', - 'NativeArray', - 'ArrayProxy' -); +runArrayTests('unshiftObjects', UnshiftObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy'); diff --git a/packages/ember-runtime/tests/system/application/base_test.js b/packages/ember-runtime/tests/system/application/base_test.js index b4ae3bfd503..658c7fd5483 100644 --- a/packages/ember-runtime/tests/system/application/base_test.js +++ b/packages/ember-runtime/tests/system/application/base_test.js @@ -5,13 +5,8 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'Ember.Application', class extends AbstractTestCase { - ['@test Ember.Application should be a subclass of Ember.Namespace']( - assert - ) { - assert.ok( - Namespace.detect(Application), - 'Ember.Application subclass of Ember.Namespace' - ); + ['@test Ember.Application should be a subclass of Ember.Namespace'](assert) { + assert.ok(Namespace.detect(Application), 'Ember.Application subclass of Ember.Namespace'); } } ); diff --git a/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js b/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js index fc4ef0aab26..0843856a8c8 100644 --- a/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js @@ -27,9 +27,9 @@ moduleFor( }) ) ); - }) + }), }).create({ - content: emberA([1, 2, 4, 5]) + content: emberA([1, 2, 4, 5]), }); }); } @@ -38,9 +38,7 @@ moduleFor( run(() => array.destroy()); } - ['@test compact - returns arrangedContent without nulls and undefined']( - assert - ) { + ['@test compact - returns arrangedContent without nulls and undefined'](assert) { run(() => array.set('content', emberA([1, 3, null, 2, undefined]))); assert.deepEqual(array.compact(), [3, 2, 1]); @@ -50,9 +48,7 @@ moduleFor( assert.equal(array.indexOf(4), 1, 'returns arranged index'); } - ['@test lastIndexOf - returns last index of object in arrangedContent']( - assert - ) { + ['@test lastIndexOf - returns last index of object in arrangedContent'](assert) { array.get('content').pushObject(4); assert.equal(array.lastIndexOf(4), 2, 'returns last arranged index'); } @@ -62,20 +58,12 @@ moduleFor( } // Not sure if we need a specific test for it, since it's internal - ['@test objectAtContent - returns object at index in arrangedContent']( - assert - ) { + ['@test objectAtContent - returns object at index in arrangedContent'](assert) { assert.equal(array.objectAtContent(1), 4, 'returns object at index'); } - ['@test objectsAt - returns objects at indices in arrangedContent']( - assert - ) { - assert.deepEqual( - array.objectsAt([0, 2, 4]), - [5, 2, undefined], - 'returns objects at indices' - ); + ['@test objectsAt - returns objects at indices in arrangedContent'](assert) { + assert.deepEqual(array.objectsAt([0, 2, 4]), [5, 2, undefined], 'returns objects at indices'); } ['@test replace - mutating an arranged ArrayProxy is not allowed']() { @@ -84,19 +72,13 @@ moduleFor( }, /Mutating an arranged ArrayProxy is not allowed/); } - ['@test replaceContent - does a standard array replace on content']( - assert - ) { + ['@test replaceContent - does a standard array replace on content'](assert) { run(() => array.replaceContent(1, 2, [3])); assert.deepEqual(array.get('content'), [1, 3, 5]); } ['@test slice - returns a slice of the arrangedContent'](assert) { - assert.deepEqual( - array.slice(1, 3), - [4, 2], - 'returns sliced arrangedContent' - ); + assert.deepEqual(array.slice(1, 3), [4, 2], 'returns sliced arrangedContent'); } ['@test toArray - returns copy of arrangedContent'](assert) { @@ -104,11 +86,7 @@ moduleFor( } ['@test without - returns arrangedContent without object'](assert) { - assert.deepEqual( - array.without(2), - [5, 4, 1], - 'returns arranged without object' - ); + assert.deepEqual(array.without(2), [5, 4, 1], 'returns arranged without object'); } ['@test lastObject - returns last arranged object'](assert) { @@ -116,11 +94,7 @@ moduleFor( } ['@test firstObject - returns first arranged object'](assert) { - assert.equal( - array.get('firstObject'), - 5, - 'returns first arranged object' - ); + assert.equal(array.get('firstObject'), 5, 'returns first arranged object'); } } ); @@ -131,7 +105,7 @@ moduleFor( beforeEach() { run(function() { array = ArrayProxy.create({ - content: emberA([1, 2, 4, 5]) + content: emberA([1, 2, 4, 5]), }); }); } @@ -192,9 +166,9 @@ moduleFor( objectAtContent(idx) { let obj = objectAt(this.get('arrangedContent'), idx); return obj && obj.toString(); - } + }, }).create({ - content: emberA([1, 2, 4, 5]) + content: emberA([1, 2, 4, 5]), }); }); } @@ -209,9 +183,7 @@ moduleFor( assert.equal(array.indexOf('4'), 1, 'returns arranged index'); } - ['@test lastIndexOf - returns last index of object in arrangedContent']( - assert - ) { + ['@test lastIndexOf - returns last index of object in arrangedContent'](assert) { array.get('content').pushObject(4); assert.equal(array.lastIndexOf('4'), 2, 'returns last arranged index'); } @@ -221,15 +193,11 @@ moduleFor( } // Not sure if we need a specific test for it, since it's internal - ['@test objectAtContent - returns object at index in arrangedContent']( - assert - ) { + ['@test objectAtContent - returns object at index in arrangedContent'](assert) { assert.equal(array.objectAtContent(1), '4', 'returns object at index'); } - ['@test objectsAt - returns objects at indices in arrangedContent']( - assert - ) { + ['@test objectsAt - returns objects at indices in arrangedContent'](assert) { assert.deepEqual( array.objectsAt([0, 2, 4]), ['5', '2', undefined], @@ -238,11 +206,7 @@ moduleFor( } ['@test slice - returns a slice of the arrangedContent'](assert) { - assert.deepEqual( - array.slice(1, 3), - ['4', '2'], - 'returns sliced arrangedContent' - ); + assert.deepEqual(array.slice(1, 3), ['4', '2'], 'returns sliced arrangedContent'); } ['@test toArray - returns copy of arrangedContent'](assert) { @@ -250,27 +214,15 @@ moduleFor( } ['@test without - returns arrangedContent without object'](assert) { - assert.deepEqual( - array.without('2'), - ['5', '4', '1'], - 'returns arranged without object' - ); + assert.deepEqual(array.without('2'), ['5', '4', '1'], 'returns arranged without object'); } ['@test lastObject - returns last arranged object'](assert) { - assert.equal( - array.get('lastObject'), - '1', - 'returns last arranged object' - ); + assert.equal(array.get('lastObject'), '1', 'returns last arranged object'); } ['@test firstObject - returns first arranged object'](assert) { - assert.equal( - array.get('firstObject'), - '5', - 'returns first arranged object' - ); + assert.equal(array.get('firstObject'), '5', 'returns first arranged object'); } } ); @@ -284,9 +236,9 @@ moduleFor( objectAtContent(idx) { let obj = objectAt(this.get('arrangedContent'), idx); return obj && obj.toString(); - } + }, }).create({ - content: emberA([1, 2, 4, 5]) + content: emberA([1, 2, 4, 5]), }); }); } @@ -300,11 +252,7 @@ moduleFor( ['@test popObject - removes last object in arrangedContent'](assert) { let popped = array.popObject(); assert.equal(popped, '5', 'returns last object'); - assert.deepEqual( - array.toArray(), - ['1', '2', '4'], - 'removes from content' - ); + assert.deepEqual(array.toArray(), ['1', '2', '4'], 'removes from content'); } ['@test removeObject - removes object from content'](assert) { @@ -320,11 +268,7 @@ moduleFor( ['@test shiftObject - removes from start of arrangedContent'](assert) { let shifted = array.shiftObject(); assert.equal(shifted, '1', 'returns first object'); - assert.deepEqual( - array.toArray(), - ['2', '4', '5'], - 'removes object from content' - ); + assert.deepEqual(array.toArray(), ['2', '4', '5'], 'removes object from content'); } } ); diff --git a/packages/ember-runtime/tests/system/array_proxy/array_observer_test.js b/packages/ember-runtime/tests/system/array_proxy/array_observer_test.js index a6055cb29ae..945bc615f0b 100644 --- a/packages/ember-runtime/tests/system/array_proxy/array_observer_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/array_observer_test.js @@ -20,7 +20,7 @@ moduleFor( arrayDidChange(proxy, startIndex, removeCount, addCount) { assert.deepEqual([startIndex, removeCount, addCount], [1, 1, 3]); assert.deepEqual(proxy.toArray(), ['x', 'a', 'b', 'c', 'z']); - } + }, }); proxy.toArray(); @@ -41,7 +41,7 @@ moduleFor( arrayDidChange(proxy, startIndex, removeCount, addCount) { assert.deepEqual([startIndex, removeCount, addCount], [0, 3, 5]); assert.deepEqual(proxy.toArray(), ['a', 'b', 'c', 'd', 'e']); - } + }, }); proxy.toArray(); diff --git a/packages/ember-runtime/tests/system/array_proxy/content_change_test.js b/packages/ember-runtime/tests/system/array_proxy/content_change_test.js index 8a3092fec70..e3d6b6f7452 100644 --- a/packages/ember-runtime/tests/system/array_proxy/content_change_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/content_change_test.js @@ -9,7 +9,7 @@ moduleFor( class extends AbstractTestCase { ['@test should update length for null content'](assert) { let proxy = ArrayProxy.create({ - content: emberA([1, 2, 3]) + content: emberA([1, 2, 3]), }); assert.equal(proxy.get('length'), 3, 'precond - length is 3'); @@ -23,9 +23,9 @@ moduleFor( assert ) { let proxy = ArrayProxy.extend({ - isEmpty: not('length') + isEmpty: not('length'), }).create({ - content: emberA([1, 2, 3]) + content: emberA([1, 2, 3]), }); assert.equal(proxy.get('length'), 3, 'precond - length is 3'); @@ -39,9 +39,7 @@ moduleFor( assert.equal(proxy.get('length'), 0, 'length updates'); } - ["@test The ArrayProxy doesn't explode when assigned a destroyed object"]( - assert - ) { + ["@test The ArrayProxy doesn't explode when assigned a destroyed object"](assert) { let proxy1 = ArrayProxy.create(); let proxy2 = ArrayProxy.create(); @@ -52,9 +50,7 @@ moduleFor( assert.ok(true, 'No exception was raised'); } - ['@test should update if content changes while change events are deferred']( - assert - ) { + ['@test should update if content changes while change events are deferred'](assert) { let proxy = ArrayProxy.create(); assert.deepEqual(proxy.toArray(), []); @@ -72,9 +68,9 @@ moduleFor( objectAtContent(index) { indexes.push(index); return this.content[index]; - } + }, }).create({ - content: emberA([1, 2, 3, 4, 5]) + content: emberA([1, 2, 3, 4, 5]), }); assert.deepEqual(indexes, []); @@ -102,9 +98,9 @@ moduleFor( objectAtContent(index) { indexes.push(index); return this.content[index]; - } + }, }).create({ - content: emberA([1, 2, 3, 4, 5]) + content: emberA([1, 2, 3, 4, 5]), }); assert.equal(get(proxy, 'length'), 5); @@ -128,9 +124,9 @@ moduleFor( objectAtContent(index) { indexes.push(index); return this.content[index]; - } + }, }).create({ - content: emberA([1, 2, 3, 4, 5]) + content: emberA([1, 2, 3, 4, 5]), }); assert.deepEqual(proxy.toArray(), [1, 2, 3, 4, 5]); diff --git a/packages/ember-runtime/tests/system/array_proxy/length_test.js b/packages/ember-runtime/tests/system/array_proxy/length_test.js index e0cc1906e70..f37d9f49878 100644 --- a/packages/ember-runtime/tests/system/array_proxy/length_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/length_test.js @@ -21,13 +21,13 @@ moduleFor( b: observer('colors.length', () => bCalled++), c: observer('colors.content.length', () => cCalled++), d: observer('colors.[]', () => dCalled++), - e: observer('colors.content.[]', () => eCalled++) + e: observer('colors.content.[]', () => eCalled++), }).create(); obj.set( 'model', ArrayProxy.create({ - content: a(['red', 'yellow', 'blue']) + content: a(['red', 'yellow', 'blue']), }) ); @@ -36,26 +36,10 @@ moduleFor( assert.equal(obj.get('length'), 3); assert.equal(aCalled, 1, 'expected observer `length` to be called ONCE'); - assert.equal( - bCalled, - 1, - 'expected observer `colors.length` to be called ONCE' - ); - assert.equal( - cCalled, - 1, - 'expected observer `colors.content.length` to be called ONCE' - ); - assert.equal( - dCalled, - 1, - 'expected observer `colors.[]` to be called ONCE' - ); - assert.equal( - eCalled, - 1, - 'expected observer `colors.content.[]` to be called ONCE' - ); + assert.equal(bCalled, 1, 'expected observer `colors.length` to be called ONCE'); + assert.equal(cCalled, 1, 'expected observer `colors.content.length` to be called ONCE'); + assert.equal(dCalled, 1, 'expected observer `colors.[]` to be called ONCE'); + assert.equal(eCalled, 1, 'expected observer `colors.content.[]` to be called ONCE'); obj.get('colors').pushObjects(['green', 'red']); @@ -64,26 +48,10 @@ moduleFor( assert.equal(obj.get('length'), 5); assert.equal(aCalled, 2, 'expected observer `length` to be called TWICE'); - assert.equal( - bCalled, - 2, - 'expected observer `colors.length` to be called TWICE' - ); - assert.equal( - cCalled, - 2, - 'expected observer `colors.content.length` to be called TWICE' - ); - assert.equal( - dCalled, - 2, - 'expected observer `colors.[]` to be called TWICE' - ); - assert.equal( - eCalled, - 2, - 'expected observer `colors.content.[]` to be called TWICE' - ); + assert.equal(bCalled, 2, 'expected observer `colors.length` to be called TWICE'); + assert.equal(cCalled, 2, 'expected observer `colors.content.length` to be called TWICE'); + assert.equal(dCalled, 2, 'expected observer `colors.[]` to be called TWICE'); + assert.equal(eCalled, 2, 'expected observer `colors.content.[]` to be called TWICE'); } } ); diff --git a/packages/ember-runtime/tests/system/array_proxy/watching_and_listening_test.js b/packages/ember-runtime/tests/system/array_proxy/watching_and_listening_test.js index 6e434cdcb95..a6c5679bb0a 100644 --- a/packages/ember-runtime/tests/system/array_proxy/watching_and_listening_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/watching_and_listening_test.js @@ -1,11 +1,4 @@ -import { - get, - addObserver, - defineProperty, - watcherCount, - computed, - peekMeta -} from 'ember-metal'; +import { get, addObserver, defineProperty, watcherCount, computed, peekMeta } from 'ember-metal'; import ArrayProxy from '../../../system/array_proxy'; import { A } from '../../../mixins/array'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -33,10 +26,10 @@ moduleFor( proxy.set('content', content); assert.deepEqual(sortedListenersFor(content, '@array:before'), [ - '_arrangedContentArrayWillChange' + '_arrangedContentArrayWillChange', ]); assert.deepEqual(sortedListenersFor(content, '@array:change'), [ - '_arrangedContentArrayDidChange' + '_arrangedContentArrayDidChange', ]); } @@ -46,10 +39,10 @@ moduleFor( let proxy = ArrayProxy.create({ content: content1 }); assert.deepEqual(sortedListenersFor(content1, '@array:before'), [ - '_arrangedContentArrayWillChange' + '_arrangedContentArrayWillChange', ]); assert.deepEqual(sortedListenersFor(content1, '@array:change'), [ - '_arrangedContentArrayDidChange' + '_arrangedContentArrayDidChange', ]); proxy.set('content', content2); @@ -57,16 +50,14 @@ moduleFor( assert.deepEqual(sortedListenersFor(content1, '@array:before'), []); assert.deepEqual(sortedListenersFor(content1, '@array:change'), []); assert.deepEqual(sortedListenersFor(content2, '@array:before'), [ - '_arrangedContentArrayWillChange' + '_arrangedContentArrayWillChange', ]); assert.deepEqual(sortedListenersFor(content2, '@array:change'), [ - '_arrangedContentArrayDidChange' + '_arrangedContentArrayDidChange', ]); } - [`@test regression test for https://github.com/emberjs/ember.js/issues/12475`]( - assert - ) { + [`@test regression test for https://github.com/emberjs/ember.js/issues/12475`](assert) { let item1a = { id: 1 }; let item1b = { id: 2 }; let item1c = { id: 3 }; diff --git a/packages/ember-runtime/tests/system/core_object_test.js b/packages/ember-runtime/tests/system/core_object_test.js index b7267d1f320..319f98f3b6c 100644 --- a/packages/ember-runtime/tests/system/core_object_test.js +++ b/packages/ember-runtime/tests/system/core_object_test.js @@ -9,7 +9,7 @@ moduleFor( ['@test works with new (one arg)'](assert) { let obj = new CoreObject({ firstName: 'Stef', - lastName: 'Penner' + lastName: 'Penner', }); assert.equal(obj.firstName, 'Stef'); @@ -20,10 +20,10 @@ moduleFor( let obj = new CoreObject( { firstName: 'Stef', - lastName: 'Penner' + lastName: 'Penner', }, { - other: 'name' + other: 'name', } ); @@ -33,12 +33,10 @@ moduleFor( assert.equal(obj.other, undefined); // doesn't support multiple pojo' to the constructor } - ['@test toString should be not be added as a property when calling toString()']( - assert - ) { + ['@test toString should be not be added as a property when calling toString()'](assert) { let obj = new CoreObject({ firstName: 'Foo', - lastName: 'Bar' + lastName: 'Bar', }); obj.toString(); @@ -49,41 +47,29 @@ moduleFor( ); } - ['@test should not trigger proxy assertion when retrieving a proxy with (GH#16263)']( - assert - ) { + ['@test should not trigger proxy assertion when retrieving a proxy with (GH#16263)'](assert) { let someProxyishThing = CoreObject.extend({ unknownProperty() { return true; - } + }, }).create(); let obj = new CoreObject({ - someProxyishThing + someProxyishThing, }); let proxy = get(obj, 'someProxyishThing'); - assert.equal( - get(proxy, 'lolol'), - true, - 'should be able to get data from a proxy' - ); + assert.equal(get(proxy, 'lolol'), true, 'should be able to get data from a proxy'); } - ['@test should not trigger proxy assertion when probing for a "symbol"']( - assert - ) { + ['@test should not trigger proxy assertion when probing for a "symbol"'](assert) { let proxy = CoreObject.extend({ unknownProperty() { return true; - } + }, }).create(); - assert.equal( - get(proxy, 'lolol'), - true, - 'should be able to get data from a proxy' - ); + assert.equal(get(proxy, 'lolol'), true, 'should be able to get data from a proxy'); // should not trigger an assertion getOwner(proxy); diff --git a/packages/ember-runtime/tests/system/lazy_load_test.js b/packages/ember-runtime/tests/system/lazy_load_test.js index adf04015465..039bdaf4756 100644 --- a/packages/ember-runtime/tests/system/lazy_load_test.js +++ b/packages/ember-runtime/tests/system/lazy_load_test.js @@ -12,9 +12,7 @@ moduleFor( } } - ['@test if a load hook is registered, it is executed when runLoadHooks are exected']( - assert - ) { + ['@test if a load hook is registered, it is executed when runLoadHooks are exected'](assert) { let count = 0; run(function() { @@ -30,9 +28,7 @@ moduleFor( assert.equal(count, 1, 'the object was passed into the load hook'); } - ['@test if runLoadHooks was already run, it executes newly added hooks immediately']( - assert - ) { + ['@test if runLoadHooks was already run, it executes newly added hooks immediately'](assert) { let count = 0; run(() => { onLoad('__test_hook__', object => (count += object)); @@ -45,11 +41,7 @@ moduleFor( onLoad('__test_hook__', object => (count += object)); }); - assert.equal( - count, - 1, - 'the original object was passed into the load hook' - ); + assert.equal(count, 1, 'the original object was passed into the load hook'); } ["@test hooks in ENV.EMBER_LOAD_HOOKS['hookName'] get executed"](assert) { @@ -60,11 +52,7 @@ moduleFor( runLoadHooks('__before_ember_test_hook__', 1); }); - assert.equal( - window.ENV.__test_hook_count__, - 1, - 'the object was passed into the load hook' - ); + assert.equal(window.ENV.__test_hook_count__, 1, 'the object was passed into the load hook'); } ['@test load hooks trigger a custom event'](assert) { @@ -77,11 +65,7 @@ moduleFor( window.addEventListener('__test_hook_for_events__', function(e) { assert.ok(true, 'custom event was fired'); - assert.equal( - e.detail, - eventObject, - 'event details are provided properly' - ); + assert.equal(e.detail, eventObject, 'event details are provided properly'); }); run(() => { diff --git a/packages/ember-runtime/tests/system/namespace/base_test.js b/packages/ember-runtime/tests/system/namespace/base_test.js index 0b7ccdcde7a..7ea8d259bea 100644 --- a/packages/ember-runtime/tests/system/namespace/base_test.js +++ b/packages/ember-runtime/tests/system/namespace/base_test.js @@ -33,10 +33,7 @@ moduleFor( } ['@test Namespace should be duck typed'](assert) { - assert.ok( - get(Namespace.create(), 'isNamespace'), - 'isNamespace property is true' - ); + assert.ok(get(Namespace.create(), 'isNamespace'), 'isNamespace property is true'); } ['@test Namespace is found and named'](assert) { @@ -58,11 +55,7 @@ moduleFor( ['@test Classes under an Namespace are properly named'](assert) { let nsA = (lookup.NamespaceA = Namespace.create()); nsA.Foo = EmberObject.extend(); - assert.equal( - nsA.Foo.toString(), - 'NamespaceA.Foo', - 'Classes pick up their parent namespace' - ); + assert.equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'Classes pick up their parent namespace'); nsA.Bar = EmberObject.extend(); assert.equal( @@ -93,11 +86,11 @@ moduleFor( ['@test A namespace can be assigned a custom name'](assert) { let nsA = Namespace.create({ - name: 'NamespaceA' + name: 'NamespaceA', }); let nsB = (lookup.NamespaceB = Namespace.create({ - name: 'CustomNamespaceB' + name: 'CustomNamespaceB', })); nsA.Foo = EmberObject.extend(); @@ -115,9 +108,7 @@ moduleFor( ); } - ['@test Calling namespace.nameClasses() eagerly names all classes']( - assert - ) { + ['@test Calling namespace.nameClasses() eagerly names all classes'](assert) { setNamespaceSearchDisabled(true); let namespace = (lookup.NS = Namespace.create()); @@ -154,11 +145,7 @@ moduleFor( let CF = (lookup.CF = Namespace.create()); run(CF, 'destroy'); - assert.equal( - Namespace.byName('CF'), - undefined, - 'namespace can not be found after destroyed' - ); + assert.equal(Namespace.byName('CF'), undefined, 'namespace can not be found after destroyed'); } ['@test Destroying a namespace after looking up removes it from the list of namespaces']( @@ -166,18 +153,10 @@ moduleFor( ) { let CF = (lookup.CF = Namespace.create()); - assert.equal( - Namespace.byName('CF'), - CF, - 'precondition - namespace can be looked up by name' - ); + assert.equal(Namespace.byName('CF'), CF, 'precondition - namespace can be looked up by name'); run(CF, 'destroy'); - assert.equal( - Namespace.byName('CF'), - undefined, - 'namespace can not be found after destroyed' - ); + assert.equal(Namespace.byName('CF'), undefined, 'namespace can not be found after destroyed'); } } ); diff --git a/packages/ember-runtime/tests/system/native_array/replace_test.js b/packages/ember-runtime/tests/system/native_array/replace_test.js index 7fbe8c439ed..e738994145a 100644 --- a/packages/ember-runtime/tests/system/native_array/replace_test.js +++ b/packages/ember-runtime/tests/system/native_array/replace_test.js @@ -10,14 +10,8 @@ moduleFor( }, 'The third argument to replace needs to be an array.'); } - ['@test it does not raise an assertion if third parameter is not passed']( - assert - ) { - assert.deepEqual( - A([1, 2, 3]).replace(1, 2), - A([1]), - 'no assertion raised' - ); + ['@test it does not raise an assertion if third parameter is not passed'](assert) { + assert.deepEqual(A([1, 2, 3]).replace(1, 2), A([1]), 'no assertion raised'); } } ); diff --git a/packages/ember-runtime/tests/system/object/computed_test.js b/packages/ember-runtime/tests/system/object/computed_test.js index 047a7c8f041..b61e2e3a940 100644 --- a/packages/ember-runtime/tests/system/object/computed_test.js +++ b/packages/ember-runtime/tests/system/object/computed_test.js @@ -1,12 +1,4 @@ -import { - alias, - computed, - set, - get, - getWithDefault, - observer, - defineProperty -} from 'ember-metal'; +import { alias, computed, set, get, getWithDefault, observer, defineProperty } from 'ember-metal'; import { oneWay as reads } from 'ember-runtime'; import EmberObject from '../../../system/object'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -28,7 +20,7 @@ moduleFor( let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); testWithDefault(assert, 'FOO', new MyClass(), 'foo'); @@ -38,13 +30,13 @@ moduleFor( let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); let Subclass = MyClass.extend({ foo: computed(function() { return 'BAR'; - }) + }), }); testWithDefault(assert, 'BAR', new Subclass(), 'foo'); @@ -54,11 +46,11 @@ moduleFor( let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); let Subclass = MyClass.extend({ - foo: 'BAR' + foo: 'BAR', }); testWithDefault(assert, 'BAR', new Subclass(), 'foo'); @@ -76,11 +68,11 @@ moduleFor( foo: computed(function() { set(this, 'count', get(this, 'count') + 1); return get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); - }).property('bar.baz') + }).property('bar.baz'), }); let Subclass = MyClass.extend({ - count: 20 + count: 20, }); let obj1 = new MyClass(); @@ -112,7 +104,7 @@ moduleFor( foo: computed(function() { set(this, 'count', get(this, 'count') + 1); return get(get(this, 'bar'), 'baz') + ' ' + get(this, 'count'); - }).property('bar.baz') + }).property('bar.baz'), }); let Subclass = MyClass.extend({ @@ -126,7 +118,7 @@ moduleFor( foo: computed(function() { set(this, 'count', get(this, 'count') + 1); return get(get(this, 'bar2'), 'baz') + ' ' + get(this, 'count'); - }).property('bar2.baz') + }).property('bar2.baz'), }); let obj2 = new Subclass(); @@ -142,7 +134,7 @@ moduleFor( ['@test can retrieve metadata for a computed property'](assert) { let MyClass = EmberObject.extend({ - computedProperty: computed(function() {}).meta({ key: 'keyValue' }) + computedProperty: computed(function() {}).meta({ key: 'keyValue' }), }); assert.equal( @@ -154,7 +146,7 @@ moduleFor( let ClassWithNoMetadata = EmberObject.extend({ computedProperty: computed(function() {}).volatile(), - staticProperty: 12 + staticProperty: 12, }); assert.equal( @@ -180,11 +172,11 @@ moduleFor( fooDidChange: observer('foo', function() {}), - bar: computed(function() {}) + bar: computed(function() {}), }); let SubClass = MyClass.extend({ - foo: null + foo: null, }); let list = []; @@ -198,9 +190,7 @@ moduleFor( ); } - ['@test can iterate over a list of computed properties for a class']( - assert - ) { + ['@test can iterate over a list of computed properties for a class'](assert) { let MyClass = EmberObject.extend({ foo: computed(function() {}), @@ -208,15 +198,15 @@ moduleFor( bar: computed(function() {}), - qux: alias('foo') + qux: alias('foo'), }); let SubClass = MyClass.extend({ - baz: computed(function() {}) + baz: computed(function() {}), }); SubClass.reopen({ - bat: computed(function() {}).meta({ iAmBat: true }) + bat: computed(function() {}).meta({ iAmBat: true }), }); let list = []; @@ -258,7 +248,7 @@ moduleFor( fooDidChange: observer('foo', function() {}), - bar: computed(K) + bar: computed(K), }); let list = []; @@ -267,14 +257,10 @@ moduleFor( list.push(name); }); - assert.deepEqual( - list.sort(), - ['bar', 'foo'].sort(), - 'expected two computed properties' - ); + assert.deepEqual(list.sort(), ['bar', 'foo'].sort(), 'expected two computed properties'); MyClass.reopen({ - baz: computed(K) + baz: computed(K), }); MyClass.create(); // force apply mixins @@ -306,9 +292,7 @@ moduleFor( ); } - ['@test Calling _super in call outside the immediate function of a CP getter works']( - assert - ) { + ['@test Calling _super in call outside the immediate function of a CP getter works'](assert) { function macro(callback) { return computed(function() { return callback.call(this); @@ -318,21 +302,19 @@ moduleFor( let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); let SubClass = MyClass.extend({ foo: macro(function() { return this._super(); - }) + }), }); assert.ok(get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); } - ['@test Calling _super in apply outside the immediate function of a CP getter works']( - assert - ) { + ['@test Calling _super in apply outside the immediate function of a CP getter works'](assert) { function macro(callback) { return computed(function() { return callback.apply(this); @@ -342,24 +324,22 @@ moduleFor( let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); let SubClass = MyClass.extend({ foo: macro(function() { return this._super(); - }) + }), }); assert.ok(get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); } - ['@test observing computed.reads prop and overriding it in create() works']( - assert - ) { + ['@test observing computed.reads prop and overriding it in create() works'](assert) { let Obj = EmberObject.extend({ name: reads('model.name'), - nameDidChange: observer('name', function() {}) + nameDidChange: observer('name', function() {}), }); let obj1 = Obj.create({ name: '1' }); diff --git a/packages/ember-runtime/tests/system/object/create_test.js b/packages/ember-runtime/tests/system/object/create_test.js index 696b7aa87dc..5f8b84323b8 100644 --- a/packages/ember-runtime/tests/system/object/create_test.js +++ b/packages/ember-runtime/tests/system/object/create_test.js @@ -19,8 +19,8 @@ moduleFor( }, set(key, value) { return value; - } - }) + }, + }), }); let o = MyClass.create({ foo: 'bar' }); @@ -32,7 +32,7 @@ moduleFor( let MyClass = EmberObject.extend({ foo: null, bar: null, - fooDidChange: observer('foo', function() {}) + fooDidChange: observer('foo', function() {}), }); let o = MyClass.create({ foo: 'bar', bar: 'baz' }); @@ -54,7 +54,7 @@ moduleFor( let MyClass = EmberObject.extend({ setUnknownProperty(/* key, value */) { setUnknownPropertyCalled = true; - } + }, }); MyClass.create({ foo: 'bar' }); @@ -64,7 +64,7 @@ moduleFor( ['@test throws if you try to define a computed property']() { expectAssertion(function() { EmberObject.create({ - foo: computed(function() {}) + foo: computed(function() {}), }); }, 'EmberObject.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().'); } @@ -74,7 +74,7 @@ moduleFor( EmberObject.create({ foo() { this._super(...arguments); - } + }, }); }, 'EmberObject.create no longer supports defining methods that call _super.'); } @@ -83,7 +83,7 @@ moduleFor( let myMixin = Mixin.create({ adder(arg1, arg2) { return arg1 + arg2; - } + }, }); expectAssertion(function() { diff --git a/packages/ember-runtime/tests/system/object/destroy_test.js b/packages/ember-runtime/tests/system/object/destroy_test.js index d7f1144ae63..5c843e3b953 100644 --- a/packages/ember-runtime/tests/system/object/destroy_test.js +++ b/packages/ember-runtime/tests/system/object/destroy_test.js @@ -5,7 +5,7 @@ import { set, beginPropertyChanges, endPropertyChanges, - peekMeta + peekMeta, } from 'ember-metal'; import EmberObject from '../../../system/object'; import { MANDATORY_SETTER } from 'ember/features'; @@ -14,9 +14,7 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'ember-runtime/system/object/destroy_test', class extends AbstractTestCase { - ['@test should schedule objects to be destroyed at the end of the run loop']( - assert - ) { + ['@test should schedule objects to be destroyed at the end of the run loop'](assert) { let obj = EmberObject.create(); let meta; @@ -24,21 +22,12 @@ moduleFor( obj.destroy(); meta = peekMeta(obj); assert.ok(meta, 'meta is not destroyed immediately'); - assert.ok( - get(obj, 'isDestroying'), - 'object is marked as destroying immediately' - ); - assert.ok( - !get(obj, 'isDestroyed'), - 'object is not destroyed immediately' - ); + assert.ok(get(obj, 'isDestroying'), 'object is marked as destroying immediately'); + assert.ok(!get(obj, 'isDestroyed'), 'object is not destroyed immediately'); }); meta = peekMeta(obj); - assert.ok( - get(obj, 'isDestroyed'), - 'object is destroyed after run loop finishes' - ); + assert.ok(get(obj, 'isDestroyed'), 'object is destroyed after run loop finishes'); } // MANDATORY_SETTER moves value to meta.values @@ -49,31 +38,25 @@ moduleFor( ) { if (MANDATORY_SETTER) { let obj = EmberObject.extend({ - fooDidChange: observer('foo', function() {}) + fooDidChange: observer('foo', function() {}), }).create({ - foo: 'bar' + foo: 'bar', }); run(() => obj.destroy()); - assert.throws( - () => set(obj, 'foo', 'baz'), - Error, - 'raises an exception' - ); + assert.throws(() => set(obj, 'foo', 'baz'), Error, 'raises an exception'); } else { assert.expect(0); } } - ['@test observers should not fire after an object has been destroyed']( - assert - ) { + ['@test observers should not fire after an object has been destroyed'](assert) { let count = 0; let obj = EmberObject.extend({ fooDidChange: observer('foo', function() { count++; - }) + }), }).create(); obj.set('foo', 'bar'); @@ -87,11 +70,7 @@ moduleFor( endPropertyChanges(); }); - assert.equal( - count, - 1, - 'observer was not called after object was destroyed' - ); + assert.equal(count, 1, 'observer was not called after object was destroyed'); } ['@test destroyed objects should not see each others changes during teardown but a long lived object should']( @@ -113,7 +92,7 @@ moduleFor( }), cDidChange: observer('objs.c.isAlive', function() { shouldNotChange++; - }) + }), }); let B = EmberObject.extend({ @@ -127,7 +106,7 @@ moduleFor( }), cDidChange: observer('objs.c.isAlive', function() { shouldNotChange++; - }) + }), }); let C = EmberObject.extend({ @@ -141,14 +120,14 @@ moduleFor( }), bDidChange: observer('objs.b.isAlive', function() { shouldNotChange++; - }) + }), }); let LongLivedObject = EmberObject.extend({ objs: objs, isAliveDidChange: observer('objs.a.isAlive', function() { shouldChange++; - }) + }), }); objs.a = new A(); @@ -166,16 +145,8 @@ moduleFor( } }); - assert.equal( - shouldNotChange, - 0, - 'destroyed graph objs should not see change in willDestroy' - ); - assert.equal( - shouldChange, - 1, - 'long lived should see change in willDestroy' - ); + assert.equal(shouldNotChange, 0, 'destroyed graph objs should not see change in willDestroy'); + assert.equal(shouldChange, 1, 'long lived should see change in willDestroy'); } } ); diff --git a/packages/ember-runtime/tests/system/object/detectInstance_test.js b/packages/ember-runtime/tests/system/object/detectInstance_test.js index 15a9c9e5a37..e773f307f26 100644 --- a/packages/ember-runtime/tests/system/object/detectInstance_test.js +++ b/packages/ember-runtime/tests/system/object/detectInstance_test.js @@ -14,22 +14,10 @@ moduleFor( let b = B.create(); let c = C.create(); - assert.ok( - EmberObject.detectInstance(o), - 'o is an instance of EmberObject' - ); - assert.ok( - EmberObject.detectInstance(a), - 'a is an instance of EmberObject' - ); - assert.ok( - EmberObject.detectInstance(b), - 'b is an instance of EmberObject' - ); - assert.ok( - EmberObject.detectInstance(c), - 'c is an instance of EmberObject' - ); + assert.ok(EmberObject.detectInstance(o), 'o is an instance of EmberObject'); + assert.ok(EmberObject.detectInstance(a), 'a is an instance of EmberObject'); + assert.ok(EmberObject.detectInstance(b), 'b is an instance of EmberObject'); + assert.ok(EmberObject.detectInstance(c), 'c is an instance of EmberObject'); assert.ok(!A.detectInstance(o), 'o is not an instance of A'); assert.ok(A.detectInstance(a), 'a is an instance of A'); diff --git a/packages/ember-runtime/tests/system/object/detect_test.js b/packages/ember-runtime/tests/system/object/detect_test.js index 1dc19ae99f3..a56c1d97c2b 100644 --- a/packages/ember-runtime/tests/system/object/detect_test.js +++ b/packages/ember-runtime/tests/system/object/detect_test.js @@ -9,10 +9,7 @@ moduleFor( let B = A.extend(); let C = A.extend(); - assert.ok( - EmberObject.detect(EmberObject), - 'EmberObject is an EmberObject class' - ); + assert.ok(EmberObject.detect(EmberObject), 'EmberObject is an EmberObject class'); assert.ok(EmberObject.detect(A), 'A is an EmberObject class'); assert.ok(EmberObject.detect(B), 'B is an EmberObject class'); assert.ok(EmberObject.detect(C), 'C is an EmberObject class'); diff --git a/packages/ember-runtime/tests/system/object/es-compatibility-test.js b/packages/ember-runtime/tests/system/object/es-compatibility-test.js index 60e48c2ae39..6945ce9c002 100644 --- a/packages/ember-runtime/tests/system/object/es-compatibility-test.js +++ b/packages/ember-runtime/tests/system/object/es-compatibility-test.js @@ -24,11 +24,7 @@ moduleFor( let myObject = MyObject.create({ passedProperty: 'passed-property' }); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (create)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); assert.equal( myObject.postInitProperty, 'post-init-property', @@ -48,11 +44,7 @@ moduleFor( calls = []; myObject = new MyObject({ passedProperty: 'passed-property' }); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (new)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); assert.equal( myObject.postInitProperty, 'post-init-property', @@ -76,14 +68,14 @@ moduleFor( let SuperSuperObject = EmberObject.extend({ method() { calls.push('super-super-method'); - } + }, }); let SuperObject = SuperSuperObject.extend({ method() { this._super(); calls.push('super-method'); - } + }, }); class MyObject extends SuperObject { @@ -105,11 +97,11 @@ moduleFor( ['@test using mixins'](assert) { let Mixin1 = Mixin.create({ - property1: 'data-1' + property1: 'data-1', }); let Mixin2 = Mixin.create({ - property2: 'data-2' + property2: 'data-2', }); class MyObject extends EmberObject.extend(Mixin1, Mixin2) {} @@ -150,19 +142,11 @@ moduleFor( class MyObject extends SubEmberObject {} MyObject.create(); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (create)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); calls = []; new MyObject(); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (new)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); } // TODO: Needs to be fixed. Currently only `init` is called. @@ -184,19 +168,11 @@ moduleFor( let MyObject = SubEmberObject.extend({}); MyObject.create(); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (create)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (create)'); calls = []; new MyObject(); - assert.deepEqual( - calls, - ['constructor', 'init'], - 'constructor then init called (new)' - ); + assert.deepEqual(calls, ['constructor', 'init'], 'constructor then init called (new)'); } } ); diff --git a/packages/ember-runtime/tests/system/object/events_test.js b/packages/ember-runtime/tests/system/object/events_test.js index 2bdd32ec631..9ed444130f3 100644 --- a/packages/ember-runtime/tests/system/object/events_test.js +++ b/packages/ember-runtime/tests/system/object/events_test.js @@ -59,9 +59,7 @@ moduleFor( assert.equal(self, obj); } - ['@test a listener can be added and removed automatically and have arguments']( - assert - ) { + ['@test a listener can be added and removed automatically and have arguments'](assert) { let self, args; let count = 0; @@ -126,7 +124,7 @@ moduleFor( ['@test a listener registered with one can be removed with off'](assert) { let obj = EmberObject.extend(Evented, { - F() {} + F() {}, }).create(); let F = function() {}; diff --git a/packages/ember-runtime/tests/system/object/extend_test.js b/packages/ember-runtime/tests/system/object/extend_test.js index 078ed0bf4f4..0ff5808af0c 100644 --- a/packages/ember-runtime/tests/system/object/extend_test.js +++ b/packages/ember-runtime/tests/system/object/extend_test.js @@ -30,7 +30,7 @@ moduleFor( barCnt: 0, bar() { this.barCnt++; - } + }, }); let AnotherClass = SomeClass.extend({ @@ -38,7 +38,7 @@ moduleFor( bar() { this.barCnt++; this._super(...arguments); - } + }, }); let FinalClass = AnotherClass.extend({ @@ -46,7 +46,7 @@ moduleFor( foo() { this.fooCnt++; this._super(...arguments); - } + }, }); let obj = new FinalClass(); @@ -60,7 +60,7 @@ moduleFor( foo() { this.fooCnt++; this._super(...arguments); - } + }, }).create(); obj.foo(); @@ -72,18 +72,14 @@ moduleFor( ['@test With concatenatedProperties'](assert) { let SomeClass = EmberObject.extend({ things: 'foo', - concatenatedProperties: ['things'] + concatenatedProperties: ['things'], }); let AnotherClass = SomeClass.extend({ things: 'bar' }); let YetAnotherClass = SomeClass.extend({ things: 'baz' }); let some = new SomeClass(); let another = new AnotherClass(); let yetAnother = new YetAnotherClass(); - assert.deepEqual( - some.get('things'), - ['foo'], - 'base class should have just its value' - ); + assert.deepEqual(some.get('things'), ['foo'], 'base class should have just its value'); assert.deepEqual( another.get('things'), ['foo', 'bar'], @@ -100,7 +96,7 @@ moduleFor( let SomeClass = EmberObject.extend(); SomeClass.reopenClass({ concatenatedProperties: ['things'], - things: 'foo' + things: 'foo', }); let AnotherClass = SomeClass.extend(); AnotherClass.reopenClass({ things: 'bar' }); @@ -130,7 +126,7 @@ moduleFor( let Parent = EmberObject.extend({ foo: computed(function() { return 'FOO'; - }) + }), }); let seen = []; @@ -138,7 +134,7 @@ moduleFor( let Child = Parent.extend({ foo: observer('bar', function() { seen.push(this.get('bar')); - }) + }), }); let child = Child.create({ bar: 0 }); diff --git a/packages/ember-runtime/tests/system/object/observer_test.js b/packages/ember-runtime/tests/system/object/observer_test.js index 689f26b98a2..a9b34f7efc0 100644 --- a/packages/ember-runtime/tests/system/object/observer_test.js +++ b/packages/ember-runtime/tests/system/object/observer_test.js @@ -11,15 +11,11 @@ moduleFor( foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = new MyClass(); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -31,28 +27,20 @@ moduleFor( foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let Subclass = MyClass.extend({ foo: observer('baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = new Subclass(); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer after change' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer after change'); set(obj, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -62,16 +50,12 @@ moduleFor( let obj = EmberObject.extend({ foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }).create({ - count: 0 + count: 0, }); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -83,28 +67,20 @@ moduleFor( foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj = MyClass.extend({ foo: observer('baz', function() { // <-- change property we observe set(this, 'count', get(this, 'count') + 1); - }) + }), }).create(); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer after change' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer after change'); set(obj, 'baz', 'BAZ'); assert.equal(get(obj, 'count'), 1, 'should invoke observer after change'); @@ -115,14 +91,10 @@ moduleFor( count: 0, foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }).create(); - assert.equal( - get(obj, 'count'), - 0, - 'precond - should not invoke observer immediately' - ); + assert.equal(get(obj, 'count'), 0, 'precond - should not invoke observer immediately'); run(() => obj.destroy()); @@ -130,11 +102,7 @@ moduleFor( set(obj, 'bar', 'BAZ'); }, `calling set on destroyed object: ${obj}.bar = BAZ`); - assert.equal( - get(obj, 'count'), - 0, - 'should not invoke observer after change' - ); + assert.equal(get(obj, 'count'), 0, 'should not invoke observer after change'); } // .......................................................... @@ -147,15 +115,15 @@ moduleFor( foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj1 = MyClass.create({ - bar: { baz: 'biff' } + bar: { baz: 'biff' }, }); let obj2 = MyClass.create({ - bar: { baz: 'biff2' } + bar: { baz: 'biff2' }, }); assert.equal(get(obj1, 'count'), 0, 'should not invoke yet'); @@ -176,20 +144,20 @@ moduleFor( foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }); let obj1 = MyClass.extend().create({ - bar: { baz: 'biff' } + bar: { baz: 'biff' }, }); let obj2 = MyClass.extend({ foo: observer('bar2.baz', function() { set(this, 'count', get(this, 'count') + 1); - }) + }), }).create({ bar: { baz: 'biff2' }, - bar2: { baz: 'biff3' } + bar2: { baz: 'biff3' }, }); assert.equal(get(obj1, 'count'), 0, 'should not invoke yet'); @@ -217,18 +185,18 @@ moduleFor( parent: null, parentOneTwoDidChange: observer('parent.one.two', function() { changed = true; - }) + }), }); let ParentClass = EmberObject.extend({ one: { - two: 'old' + two: 'old', }, init() { this.child = ChildClass.create({ - parent: this + parent: this, }); - } + }, }); let parent = new ParentClass(); @@ -237,19 +205,11 @@ moduleFor( set(parent, 'one.two', 'new'); - assert.equal( - changed, - true, - 'child should have been notified of change to path' - ); + assert.equal(changed, true, 'child should have been notified of change to path'); set(parent, 'one', { two: 'newer' }); - assert.equal( - changed, - true, - 'child should have been notified of change to path' - ); + assert.equal(changed, true, 'child should have been notified of change to path'); } } ); diff --git a/packages/ember-runtime/tests/system/object/reopenClass_test.js b/packages/ember-runtime/tests/system/object/reopenClass_test.js index 871a502c792..cf2b909fc32 100644 --- a/packages/ember-runtime/tests/system/object/reopenClass_test.js +++ b/packages/ember-runtime/tests/system/object/reopenClass_test.js @@ -11,7 +11,7 @@ moduleFor( foo() { return 'FOO'; }, - bar: 'BAR' + bar: 'BAR', }); assert.equal(Subclass.foo(), 'FOO', 'Adds method'); @@ -24,7 +24,7 @@ moduleFor( foo() { return 'FOO'; }, - bar: 'BAR' + bar: 'BAR', }); let SubSub = Subclass.extend(); diff --git a/packages/ember-runtime/tests/system/object/reopen_test.js b/packages/ember-runtime/tests/system/object/reopen_test.js index e1474e96f3a..cbc12bdfca1 100644 --- a/packages/ember-runtime/tests/system/object/reopen_test.js +++ b/packages/ember-runtime/tests/system/object/reopen_test.js @@ -11,7 +11,7 @@ moduleFor( foo() { return 'FOO'; }, - bar: 'BAR' + bar: 'BAR', }); assert.equal(new Subclass().foo(), 'FOO', 'Adds method'); @@ -26,7 +26,7 @@ moduleFor( foo() { return 'FOO'; }, - bar: 'BAR' + bar: 'BAR', }); assert.equal(new SubSub().foo(), 'FOO', 'Adds method'); @@ -39,7 +39,7 @@ moduleFor( Subclass.create(); Subclass.reopen({ - trololol: true + trololol: true, }); assert.equal(Subclass.create().get('trololol'), true, 'reopen works'); diff --git a/packages/ember-runtime/tests/system/object/strict-mode-test.js b/packages/ember-runtime/tests/system/object/strict-mode-test.js index 63ecb69ca20..e4fdf2ba02c 100644 --- a/packages/ember-runtime/tests/system/object/strict-mode-test.js +++ b/packages/ember-runtime/tests/system/object/strict-mode-test.js @@ -8,7 +8,7 @@ moduleFor( let Foo = EmberObject.extend({ blah() { return 'foo'; - } + }, }); let Bar = Foo.extend({ @@ -20,16 +20,12 @@ moduleFor( let blah = this.blah; return blah(); - } + }, }); let bar = Bar.create(); - assert.equal( - bar.callBlah(), - 'bar', - 'can call local function without call/apply' - ); + assert.equal(bar.callBlah(), 'bar', 'can call local function without call/apply'); } } ); diff --git a/packages/ember-runtime/tests/system/object/toString_test.js b/packages/ember-runtime/tests/system/object/toString_test.js index c2daac1c3d7..485a8be45a1 100644 --- a/packages/ember-runtime/tests/system/object/toString_test.js +++ b/packages/ember-runtime/tests/system/object/toString_test.js @@ -37,9 +37,7 @@ moduleFor( assert.equal(Foo.Bar.toString(), 'Foo.Bar'); } - ['@test toString on a class returns a useful value when nested in a namespace']( - assert - ) { + ['@test toString on a class returns a useful value when nested in a namespace'](assert) { let obj; let Foo = Namespace.create(); @@ -81,9 +79,7 @@ moduleFor( assert.equal(obj.toString(), ''); } - ['@test toString on a namespace falls back to modulePrefix, if defined']( - assert - ) { + ['@test toString on a namespace falls back to modulePrefix, if defined'](assert) { let Foo = Namespace.create({ modulePrefix: 'foo' }); assert.equal(Foo.toString(), 'foo'); @@ -93,7 +89,7 @@ moduleFor( let Foo = EmberObject.extend({ toStringExtension() { return 'fooey'; - } + }, }); let foo = Foo.create(); let Bar = EmberObject.extend({}); diff --git a/packages/ember-runtime/tests/system/object_proxy_test.js b/packages/ember-runtime/tests/system/object_proxy_test.js index 3cd27a63e64..b89fb797991 100644 --- a/packages/ember-runtime/tests/system/object_proxy_test.js +++ b/packages/ember-runtime/tests/system/object_proxy_test.js @@ -1,11 +1,4 @@ -import { - addObserver, - computed, - get, - set, - isWatching, - removeObserver -} from 'ember-metal'; +import { addObserver, computed, get, set, isWatching, removeObserver } from 'ember-metal'; import { HAS_NATIVE_PROXY } from 'ember-utils'; import { MANDATORY_GETTER, EMBER_METAL_ES5_GETTERS } from 'ember/features'; import ObjectProxy from '../../system/object_proxy'; @@ -23,19 +16,15 @@ moduleFor( set(key, value) { this._cp = value; return this._cp; - } - }) + }, + }), }); let proxy = Proxy.create({ prop: 'Foo', - cp: 'Bar' + cp: 'Bar', }); - assert.equal( - get(proxy, 'prop'), - 'Foo', - 'should not have tried to proxy set' - ); + assert.equal(get(proxy, 'prop'), 'Foo', 'should not have tried to proxy set'); assert.equal(proxy._cp, 'Bar', 'should use CP setter'); } @@ -45,7 +34,7 @@ moduleFor( lastName: 'Dale', unknownProperty(key) { return key + ' unknown'; - } + }, }; let proxy = ObjectProxy.create(); @@ -83,31 +72,19 @@ moduleFor( 'Huda', 'content should have new value from set on proxy' ); - assert.equal( - get(proxy, 'lastName'), - 'Huda', - 'proxy should have new value from set on proxy' - ); + assert.equal(get(proxy, 'lastName'), 'Huda', 'proxy should have new value from set on proxy'); set(proxy, 'content', { firstName: 'Yehuda', lastName: 'Katz' }); - assert.equal( - get(proxy, 'firstName'), - 'Yehuda', - 'proxy should reflect updated content' - ); - assert.equal( - get(proxy, 'lastName'), - 'Katz', - 'proxy should reflect updated content' - ); + assert.equal(get(proxy, 'firstName'), 'Yehuda', 'proxy should reflect updated content'); + assert.equal(get(proxy, 'lastName'), 'Katz', 'proxy should reflect updated content'); } ['@test getting proxied properties with Ember.get should work'](assert) { let proxy = ObjectProxy.create({ content: { - foo: 'FOO' - } + foo: 'FOO', + }, }); assert.equal(get(proxy, 'foo'), 'FOO'); @@ -116,14 +93,11 @@ moduleFor( [`@test JSON.stringify doens't assert`](assert) { let proxy = ObjectProxy.create({ content: { - foo: 'FOO' - } + foo: 'FOO', + }, }); - assert.equal( - JSON.stringify(proxy), - JSON.stringify({ content: { foo: 'FOO' } }) - ); + assert.equal(JSON.stringify(proxy), JSON.stringify({ content: { foo: 'FOO' } })); } [`@test setting a property on the proxy avoids the assertion`](assert) { @@ -132,24 +106,22 @@ moduleFor( content: { toJSON() { return 'hello'; - } - } + }, + }, }); assert.equal(JSON.stringify(proxy), JSON.stringify({ content: 'hello' })); } - [`@test setting a property on the proxy's prototype avoids the assertion`]( - assert - ) { + [`@test setting a property on the proxy's prototype avoids the assertion`](assert) { let proxy = ObjectProxy.extend({ - toJSON: null + toJSON: null, }).create({ content: { toJSON() { return 'hello'; - } - } + }, + }, }); assert.equal(JSON.stringify(proxy), JSON.stringify({ content: 'hello' })); @@ -159,8 +131,8 @@ moduleFor( if (MANDATORY_GETTER && EMBER_METAL_ES5_GETTERS && HAS_NATIVE_PROXY) { let proxy = ObjectProxy.create({ content: { - foo: 'FOO' - } + foo: 'FOO', + }, }); expectAssertion(() => proxy.foo, /\.get\('foo'\)/); @@ -184,7 +156,7 @@ moduleFor( return firstName + ' ' + lastName; } return firstName || lastName; - }).property('firstName', 'lastName') + }).property('firstName', 'lastName'), }); let proxy = Proxy.create(); @@ -250,9 +222,7 @@ moduleFor( assert.equal(proxy.get('content.foo.bar'), 'bye'); } - ['@test should transition between watched and unwatched strategies']( - assert - ) { + ['@test should transition between watched and unwatched strategies'](assert) { let content = { foo: 'foo' }; let proxy = ObjectProxy.create({ content: content }); let count = 0; @@ -305,8 +275,8 @@ moduleFor( ) { let proxyObject = ObjectProxy.create({ content: { - prop: 'emberjs' - } + prop: 'emberjs', + }, }); set(proxyObject, 'prop', undefined); assert.equal( diff --git a/packages/ember-runtime/tests/system/string/camelize_test.js b/packages/ember-runtime/tests/system/string/camelize_test.js index e81d2185e71..a3b3cf245fc 100644 --- a/packages/ember-runtime/tests/system/string/camelize_test.js +++ b/packages/ember-runtime/tests/system/string/camelize_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.camelize', class extends AbstractTestCase { - ['@test String.prototype.camelize is not modified without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.camelize is not modified without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.camelize, @@ -26,27 +24,12 @@ moduleFor( } ['@test String camelize tests'](assert) { - test( - assert, - 'my favorite items', - 'myFavoriteItems', - 'camelize normal string' - ); + test(assert, 'my favorite items', 'myFavoriteItems', 'camelize normal string'); test(assert, 'I Love Ramen', 'iLoveRamen', 'camelize capitalized string'); - test( - assert, - 'css-class-name', - 'cssClassName', - 'camelize dasherized string' - ); + test(assert, 'css-class-name', 'cssClassName', 'camelize dasherized string'); test(assert, 'action_name', 'actionName', 'camelize underscored string'); test(assert, 'action.name', 'actionName', 'camelize dot notation string'); - test( - assert, - 'innerHTML', - 'innerHTML', - 'does nothing with camelcased string' - ); + test(assert, 'innerHTML', 'innerHTML', 'does nothing with camelcased string'); test( assert, 'PrivateDocs/OwnerInvoice', diff --git a/packages/ember-runtime/tests/system/string/capitalize_test.js b/packages/ember-runtime/tests/system/string/capitalize_test.js index 81fd7d56c7d..a3feaa2ea08 100644 --- a/packages/ember-runtime/tests/system/string/capitalize_test.js +++ b/packages/ember-runtime/tests/system/string/capitalize_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.capitalize', class extends AbstractTestCase { - ['@test String.prototype.capitalize is not modified without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.capitalize is not modified without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.capitalize, @@ -26,24 +24,9 @@ moduleFor( } ['@test String capitalize tests'](assert) { - test( - assert, - 'my favorite items', - 'My favorite items', - 'capitalize normal string' - ); - test( - assert, - 'css-class-name', - 'Css-class-name', - 'capitalize dasherized string' - ); - test( - assert, - 'action_name', - 'Action_name', - 'capitalize underscored string' - ); + test(assert, 'my favorite items', 'My favorite items', 'capitalize normal string'); + test(assert, 'css-class-name', 'Css-class-name', 'capitalize dasherized string'); + test(assert, 'action_name', 'Action_name', 'capitalize underscored string'); test(assert, 'innerHTML', 'InnerHTML', 'capitalize camelcased string'); test( assert, diff --git a/packages/ember-runtime/tests/system/string/classify_test.js b/packages/ember-runtime/tests/system/string/classify_test.js index 02668479466..a12ff0a9d7b 100644 --- a/packages/ember-runtime/tests/system/string/classify_test.js +++ b/packages/ember-runtime/tests/system/string/classify_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.classify', class extends AbstractTestCase { - ['@test String.prototype.classify is not modified without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.classify is not modified without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.classify, @@ -26,18 +24,8 @@ moduleFor( } ['@test String classify tests'](assert) { - test( - assert, - 'my favorite items', - 'MyFavoriteItems', - 'classify normal string' - ); - test( - assert, - 'css-class-name', - 'CssClassName', - 'classify dasherized string' - ); + test(assert, 'my favorite items', 'MyFavoriteItems', 'classify normal string'); + test(assert, 'css-class-name', 'CssClassName', 'classify dasherized string'); test(assert, 'action_name', 'ActionName', 'classify underscored string'); test( assert, @@ -57,30 +45,15 @@ moduleFor( 'PrivateDocs/OwnerInvoice', 'classify namespaced dasherized string' ); - test( - assert, - '-view-registry', - '_ViewRegistry', - 'classify prefixed dasherized string' - ); + test(assert, '-view-registry', '_ViewRegistry', 'classify prefixed dasherized string'); test( assert, 'components/-text-field', 'Components/_TextField', 'classify namespaced prefixed dasherized string' ); - test( - assert, - '_Foo_Bar', - '_FooBar', - 'classify underscore-prefixed underscored string' - ); - test( - assert, - '_Foo-Bar', - '_FooBar', - 'classify underscore-prefixed dasherized string' - ); + test(assert, '_Foo_Bar', '_FooBar', 'classify underscore-prefixed underscored string'); + test(assert, '_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string'); test( assert, '_foo/_bar', @@ -99,18 +72,8 @@ moduleFor( '_Foo/_Bar', 'classify dash-prefixed-namespaced dash-prefixed string' ); - test( - assert, - 'InnerHTML', - 'InnerHTML', - 'does nothing with classified string' - ); - test( - assert, - '_FooBar', - '_FooBar', - 'does nothing with classified prefixed string' - ); + test(assert, 'InnerHTML', 'InnerHTML', 'does nothing with classified string'); + test(assert, '_FooBar', '_FooBar', 'does nothing with classified prefixed string'); } } ); diff --git a/packages/ember-runtime/tests/system/string/dasherize_test.js b/packages/ember-runtime/tests/system/string/dasherize_test.js index 4b452ce070e..326e76a8bba 100644 --- a/packages/ember-runtime/tests/system/string/dasherize_test.js +++ b/packages/ember-runtime/tests/system/string/dasherize_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.dasherize', class extends AbstractTestCase { - ['@test String.prototype.dasherize is not modified without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.dasherize is not modified without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.dasherize, @@ -26,24 +24,9 @@ moduleFor( } ['@test String dasherize tests'](assert) { - test( - assert, - 'my favorite items', - 'my-favorite-items', - 'dasherize normal string' - ); - test( - assert, - 'css-class-name', - 'css-class-name', - 'does nothing with dasherized string' - ); - test( - assert, - 'action_name', - 'action-name', - 'dasherize underscored string' - ); + test(assert, 'my favorite items', 'my-favorite-items', 'dasherize normal string'); + test(assert, 'css-class-name', 'css-class-name', 'does nothing with dasherized string'); + test(assert, 'action_name', 'action-name', 'dasherize underscored string'); test(assert, 'innerHTML', 'inner-html', 'dasherize camelcased string'); test( assert, diff --git a/packages/ember-runtime/tests/system/string/decamelize_test.js b/packages/ember-runtime/tests/system/string/decamelize_test.js index c33edde8fed..874fb8688bf 100644 --- a/packages/ember-runtime/tests/system/string/decamelize_test.js +++ b/packages/ember-runtime/tests/system/string/decamelize_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.decamelize', class extends AbstractTestCase { - ['@test String.prototype.decamelize is not modified without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.decamelize is not modified without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.decamelize, @@ -26,36 +24,16 @@ moduleFor( } ['@test String decamelize tests'](assert) { - test( - assert, - 'my favorite items', - 'my favorite items', - 'does nothing with normal string' - ); - test( - assert, - 'css-class-name', - 'css-class-name', - 'does nothing with dasherized string' - ); - test( - assert, - 'action_name', - 'action_name', - 'does nothing with underscored string' - ); + test(assert, 'my favorite items', 'my favorite items', 'does nothing with normal string'); + test(assert, 'css-class-name', 'css-class-name', 'does nothing with dasherized string'); + test(assert, 'action_name', 'action_name', 'does nothing with underscored string'); test( assert, 'innerHTML', 'inner_html', 'converts a camelized string into all lower case separated by underscores.' ); - test( - assert, - 'size160Url', - 'size160_url', - 'decamelizes strings with numbers' - ); + test(assert, 'size160Url', 'size160_url', 'decamelizes strings with numbers'); test( assert, 'PrivateDocs/OwnerInvoice', diff --git a/packages/ember-runtime/tests/system/string/loc_test.js b/packages/ember-runtime/tests/system/string/loc_test.js index a675f87cad6..da90663a151 100644 --- a/packages/ember-runtime/tests/system/string/loc_test.js +++ b/packages/ember-runtime/tests/system/string/loc_test.js @@ -21,7 +21,7 @@ moduleFor( '_Hello World': 'Bonjour le monde', '_Hello %@': 'Bonjour %@', '_Hello %@ %@': 'Bonjour %@ %@', - '_Hello %@# %@#': 'Bonjour %@2 %@1' + '_Hello %@# %@#': 'Bonjour %@2 %@1', }); } @@ -29,14 +29,9 @@ moduleFor( setStrings(oldString); } - ['@test String.prototype.loc is not available without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.loc is not available without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { - assert.ok( - 'undefined' === typeof String.prototype.loc, - 'String.prototype helper disabled' - ); + assert.ok('undefined' === typeof String.prototype.loc, 'String.prototype helper disabled'); } else { assert.expect(0); } diff --git a/packages/ember-runtime/tests/system/string/underscore_test.js b/packages/ember-runtime/tests/system/string/underscore_test.js index 9ee2693252e..4589c39e1d4 100644 --- a/packages/ember-runtime/tests/system/string/underscore_test.js +++ b/packages/ember-runtime/tests/system/string/underscore_test.js @@ -12,9 +12,7 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.underscore', class extends AbstractTestCase { - ['@test String.prototype.underscore is not available without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.underscore is not available without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { assert.ok( 'undefined' === typeof String.prototype.underscore, @@ -26,24 +24,9 @@ moduleFor( } ['@test String underscore tests'](assert) { - test( - assert, - 'my favorite items', - 'my_favorite_items', - 'with normal string' - ); - test( - assert, - 'css-class-name', - 'css_class_name', - 'with dasherized string' - ); - test( - assert, - 'action_name', - 'action_name', - 'does nothing with underscored string' - ); + test(assert, 'my favorite items', 'my_favorite_items', 'with normal string'); + test(assert, 'css-class-name', 'css_class_name', 'with dasherized string'); + test(assert, 'action_name', 'action_name', 'does nothing with underscored string'); test(assert, 'innerHTML', 'inner_html', 'with camelcased string'); test( assert, diff --git a/packages/ember-runtime/tests/system/string/w_test.js b/packages/ember-runtime/tests/system/string/w_test.js index 7dae380e67e..06c4109dbbb 100644 --- a/packages/ember-runtime/tests/system/string/w_test.js +++ b/packages/ember-runtime/tests/system/string/w_test.js @@ -12,14 +12,9 @@ function test(assert, given, expected, description) { moduleFor( 'EmberStringUtils.w', class extends AbstractTestCase { - ['@test String.prototype.w is not available without EXTEND_PROTOTYPES']( - assert - ) { + ['@test String.prototype.w is not available without EXTEND_PROTOTYPES'](assert) { if (!ENV.EXTEND_PROTOTYPES.String) { - assert.ok( - 'undefined' === typeof String.prototype.w, - 'String.prototype helper disabled' - ); + assert.ok('undefined' === typeof String.prototype.w, 'String.prototype helper disabled'); } else { assert.expect(0); } @@ -38,12 +33,7 @@ moduleFor( ['one', 'two', 'three'], `w('one two three') with extra spaces between words => ['one','two','three']` ); - test( - assert, - 'one\ttwo three', - ['one', 'two', 'three'], - `w('one two three') with tabs` - ); + test(assert, 'one\ttwo three', ['one', 'two', 'three'], `w('one two three') with tabs`); } } ); diff --git a/packages/ember-template-compiler/lib/index.js b/packages/ember-template-compiler/lib/index.js index 9c85cc074db..79054db7298 100644 --- a/packages/ember-template-compiler/lib/index.js +++ b/packages/ember-template-compiler/lib/index.js @@ -21,7 +21,7 @@ export { default as compile } from './system/compile'; export { default as compileOptions, registerPlugin, - unregisterPlugin + unregisterPlugin, } from './system/compile-options'; export { default as defaultPlugins } from './plugins/index'; diff --git a/packages/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.js b/packages/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.js index 0046365a267..5fde9337c43 100644 --- a/packages/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.js +++ b/packages/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.js @@ -11,9 +11,10 @@ export default function assertIfHelperWithoutArguments(env) { BlockStatement(node) { if (isInvalidBlockIf(node)) { assert( - `${blockAssertMessage( - node.path.original - )} ${calculateLocationDisplay(moduleName, node.loc)}` + `${blockAssertMessage(node.path.original)} ${calculateLocationDisplay( + moduleName, + node.loc + )}` ); } }, @@ -21,9 +22,10 @@ export default function assertIfHelperWithoutArguments(env) { MustacheStatement(node) { if (isInvalidInlineIf(node)) { assert( - `${inlineAssertMessage( - node.path.original - )} ${calculateLocationDisplay(moduleName, node.loc)}` + `${inlineAssertMessage(node.path.original)} ${calculateLocationDisplay( + moduleName, + node.loc + )}` ); } }, @@ -31,13 +33,14 @@ export default function assertIfHelperWithoutArguments(env) { SubExpression(node) { if (isInvalidInlineIf(node)) { assert( - `${inlineAssertMessage( - node.path.original - )} ${calculateLocationDisplay(moduleName, node.loc)}` + `${inlineAssertMessage(node.path.original)} ${calculateLocationDisplay( + moduleName, + node.loc + )}` ); } - } - } + }, + }, }; } @@ -57,7 +60,5 @@ function isInvalidInlineIf(node) { } function isInvalidBlockIf(node) { - return ( - node.path.original === 'if' && (!node.params || node.params.length !== 1) - ); + return node.path.original === 'if' && (!node.params || node.params.length !== 1); } diff --git a/packages/ember-template-compiler/lib/plugins/assert-input-helper-without-block.js b/packages/ember-template-compiler/lib/plugins/assert-input-helper-without-block.js index 0213752bbe6..0f5d28d9aa0 100644 --- a/packages/ember-template-compiler/lib/plugins/assert-input-helper-without-block.js +++ b/packages/ember-template-compiler/lib/plugins/assert-input-helper-without-block.js @@ -14,8 +14,8 @@ export default function errorOnInputWithContent(env) { } assert(assertMessage(moduleName, node)); - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js b/packages/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js index 00c6ad683cd..dd45f48b01a 100644 --- a/packages/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js +++ b/packages/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js @@ -15,15 +15,10 @@ export default function assertReservedNamedArguments(env) { visitor: { PathExpression({ original, loc }) { if (isReserved(original)) { - assert( - `${assertMessage(original)} ${calculateLocationDisplay( - moduleName, - loc - )}` - ); + assert(`${assertMessage(original)} ${calculateLocationDisplay(moduleName, loc)}`); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/deprecate-render-model.js b/packages/ember-template-compiler/lib/plugins/deprecate-render-model.js index f686781921b..cf3761f8b64 100644 --- a/packages/ember-template-compiler/lib/plugins/deprecate-render-model.js +++ b/packages/ember-template-compiler/lib/plugins/deprecate-render-model.js @@ -20,12 +20,12 @@ export default function deprecateRenderModel(env) { id: 'ember-template-compiler.deprecate-render-model', until: '3.0.0', url: - 'https://emberjs.com/deprecations/v2.x#toc_model-param-in-code-render-code-helper' + 'https://emberjs.com/deprecations/v2.x#toc_model-param-in-code-render-code-helper', }); }); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/deprecate-render.js b/packages/ember-template-compiler/lib/plugins/deprecate-render.js index 5e0f9c52332..babd3869594 100644 --- a/packages/ember-template-compiler/lib/plugins/deprecate-render.js +++ b/packages/ember-template-compiler/lib/plugins/deprecate-render.js @@ -25,12 +25,11 @@ export default function deprecateRender(env) { deprecate(deprecationMessage(moduleName, node), false, { id: 'ember-template-compiler.deprecate-render', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x#toc_code-render-code-helper' + url: 'https://emberjs.com/deprecations/v2.x#toc_code-render-code-helper', }); }); - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/index.js b/packages/ember-template-compiler/lib/plugins/index.js index bd38a53cbf2..049f22cbdd0 100644 --- a/packages/ember-template-compiler/lib/plugins/index.js +++ b/packages/ember-template-compiler/lib/plugins/index.js @@ -35,7 +35,7 @@ const transforms = [ TransformHasBlockSyntax, AssertInputHelperWithoutBlock, TransformInElement, - AssertIfHelperWithoutArguments + AssertIfHelperWithoutArguments, ]; export default Object.freeze(transforms); diff --git a/packages/ember-template-compiler/lib/plugins/transform-action-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-action-syntax.js index 3b12392d087..e0769dc4bd2 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-action-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-action-syntax.js @@ -46,8 +46,8 @@ export default function transformActionSyntax({ syntax }) { if (isAction(node)) { insertThisAsFirstParam(node, b); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js b/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js index 0175acd1c24..5c1d4c1a459 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js +++ b/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js @@ -5,7 +5,7 @@ export default function transformAngleBracketComponents(/* env */) { visitor: { ComponentNode(node) { node.tag = `<${node.tag}>`; - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-attrs-into-args.js b/packages/ember-template-compiler/lib/plugins/transform-attrs-into-args.js index 638a7b41d43..5b1a9da8184 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-attrs-into-args.js +++ b/packages/ember-template-compiler/lib/plugins/transform-attrs-into-args.js @@ -38,7 +38,7 @@ export default function transformAttrsIntoArgs(env) { }, exit() { stack.pop(); - } + }, }, PathExpression(node) { @@ -48,8 +48,8 @@ export default function transformAttrsIntoArgs(env) { path.data = true; return path; } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-dot-component-invocation.js b/packages/ember-template-compiler/lib/plugins/transform-dot-component-invocation.js index c0ec62e8a55..feeccffec88 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-dot-component-invocation.js +++ b/packages/ember-template-compiler/lib/plugins/transform-dot-component-invocation.js @@ -67,8 +67,8 @@ export default function transformDotComponentInvocation(env) { if (isMultipartPath(node.path)) { wrapInComponent(node, b); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-each-in-into-each.js b/packages/ember-template-compiler/lib/plugins/transform-each-in-into-each.js index 09cab12329d..68f892b316e 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-each-in-into-each.js +++ b/packages/ember-template-compiler/lib/plugins/transform-each-in-into-each.js @@ -54,7 +54,7 @@ export default function transformEachInIntoEach(env) { node.loc ); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-has-block-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-has-block-syntax.js index e44eea6212e..9f80f6b5e73 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-has-block-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-has-block-syntax.js @@ -21,7 +21,7 @@ const TRANSFORMATIONS = { hasBlock: 'has-block', - hasBlockParams: 'has-block-params' + hasBlockParams: 'has-block-params', }; export default function transformHasBlockSyntax(env) { @@ -49,13 +49,9 @@ export default function transformHasBlockSyntax(env) { }, SubExpression(node) { if (TRANSFORMATIONS[node.path.original]) { - return b.sexpr( - b.path(TRANSFORMATIONS[node.path.original]), - node.params, - node.hash - ); + return b.sexpr(b.path(TRANSFORMATIONS[node.path.original]), node.params, node.hash); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-in-element.js b/packages/ember-template-compiler/lib/plugins/transform-in-element.js index 9623f2c16f1..4183bc6f253 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-in-element.js +++ b/packages/ember-template-compiler/lib/plugins/transform-in-element.js @@ -80,8 +80,8 @@ export default function transformInElement(env) { hash.pairs.push(nextSibling); } } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-inline-link-to.js b/packages/ember-template-compiler/lib/plugins/transform-inline-link-to.js index 7db039ede64..ea987f88b1e 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-inline-link-to.js +++ b/packages/ember-template-compiler/lib/plugins/transform-inline-link-to.js @@ -29,9 +29,7 @@ export default function transformInlineLinkTo(env) { visitor: { MustacheStatement(node) { if (node.path.original === 'link-to') { - let content = node.escaped - ? node.params[0] - : unsafeHtml(b, node.params[0]); + let content = node.escaped ? node.params[0] : unsafeHtml(b, node.params[0]); return b.block( 'link-to', node.params.slice(1), @@ -41,7 +39,7 @@ export default function transformInlineLinkTo(env) { node.loc ); } - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-input-type-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-input-type-syntax.js index d0440b049a7..90d2bfbb458 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-input-type-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-input-type-syntax.js @@ -34,8 +34,8 @@ export default function transformInputTypeSyntax(env) { if (isInput(node)) { insertTypeHelperParameter(node, b); } - } - } + }, + }, }; } @@ -53,8 +53,6 @@ function insertTypeHelperParameter(node, builders) { } } if (pair && pair.value.type !== 'StringLiteral') { - node.params.unshift( - builders.sexpr('-input-type', [pair.value], null, pair.loc) - ); + node.params.unshift(builders.sexpr('-input-type', [pair.value], null, pair.loc)); } } diff --git a/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js index d3e47f036b4..afa03331659 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js @@ -15,8 +15,8 @@ export default function transformOldBindingSyntax(env) { MustacheStatement(node) { processHash(b, node, moduleName); - } - } + }, + }, }; } @@ -42,13 +42,11 @@ function processHash(b, node, moduleName) { deprecate( `You're using legacy binding syntax: ${key}=${exprToString( value - )} ${sourceInformation}. Please replace with ${newKey}=${ - value.original - }`, + )} ${sourceInformation}. Please replace with ${newKey}=${value.original}`, false, { id: 'ember-template-compiler.transform-old-binding-syntax', - until: '3.0.0' + until: '3.0.0', } ); diff --git a/packages/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.js index 4cacc96ab48..16d2fee89fa 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.js @@ -11,8 +11,8 @@ export default function transformOldClassBindingSyntax(env) { BlockStatement(node) { process(b, node); - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js b/packages/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js index e9d7f43f333..2b09880ee7f 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js +++ b/packages/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js @@ -11,8 +11,8 @@ export default function transformQuotedBindingsIntoJustBindings(/* env */) { } styleAttr.value = styleAttr.value.parts[0]; - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js b/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js index c161f72e63f..f00b44cf30c 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js +++ b/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js @@ -8,8 +8,8 @@ export default function transformTopLevelComponent(/* env */) { component.tag = `@${component.tag}`; component.isStatic = true; }); - } - } + }, + }, }; } diff --git a/packages/ember-template-compiler/lib/system/bootstrap.js b/packages/ember-template-compiler/lib/system/bootstrap.js index 44124ebba32..581ba0482cb 100644 --- a/packages/ember-template-compiler/lib/system/bootstrap.js +++ b/packages/ember-template-compiler/lib/system/bootstrap.js @@ -34,13 +34,11 @@ function bootstrap({ context, hasTemplate, setTemplate }) { // First look for data-template-name attribute, then fall back to its // id if no name is found. let templateName = - script.getAttribute('data-template-name') || - script.getAttribute('id') || - 'application'; + script.getAttribute('data-template-name') || script.getAttribute('id') || 'application'; let template; template = compile(script.innerHTML, { - moduleName: templateName + moduleName: templateName, }); // Check if template of same name already exists. diff --git a/packages/ember-template-compiler/lib/system/compile-options.js b/packages/ember-template-compiler/lib/system/compile-options.js index cd39f34fdea..cf43710e0d6 100644 --- a/packages/ember-template-compiler/lib/system/compile-options.js +++ b/packages/ember-template-compiler/lib/system/compile-options.js @@ -16,9 +16,7 @@ export default function compileOptions(_options) { options.plugins = { ast: [...USER_PLUGINS, ...PLUGINS] }; } else { let potententialPugins = [...USER_PLUGINS, ...PLUGINS]; - let providedPlugins = options.plugins.ast.map(plugin => - wrapLegacyPluginIfNeeded(plugin) - ); + let providedPlugins = options.plugins.ast.map(plugin => wrapLegacyPluginIfNeeded(plugin)); let pluginsToAdd = potententialPugins.filter(plugin => { return options.plugins.ast.indexOf(plugin) === -1; }); @@ -47,8 +45,8 @@ function wrapLegacyPluginIfNeeded(_plugin) { return plugin.transform(node); } - } - } + }, + }, }; }; diff --git a/packages/ember-template-compiler/lib/system/initializer.js b/packages/ember-template-compiler/lib/system/initializer.js index 71f603096f6..0279844ed1f 100644 --- a/packages/ember-template-compiler/lib/system/initializer.js +++ b/packages/ember-template-compiler/lib/system/initializer.js @@ -1,11 +1,7 @@ import require, { has } from 'require'; // Globals mode template compiler -if ( - has('ember-application') && - has('ember-environment') && - has('ember-glimmer') -) { +if (has('ember-application') && has('ember-environment') && has('ember-glimmer')) { let emberEnv = require('ember-environment'); let emberGlimmer = require('ember-glimmer'); let emberApp = require('ember-application'); @@ -26,6 +22,6 @@ if ( } bootstrap({ context, hasTemplate, setTemplate }); - } + }, }); } diff --git a/packages/ember-template-compiler/tests/plugins/assert-if-helper-without-arguments-test.js b/packages/ember-template-compiler/tests/plugins/assert-if-helper-without-arguments-test.js index 9076a14c9a6..5f726a7b32d 100644 --- a/packages/ember-template-compiler/tests/plugins/assert-if-helper-without-arguments-test.js +++ b/packages/ember-template-compiler/tests/plugins/assert-if-helper-without-arguments-test.js @@ -7,19 +7,19 @@ moduleFor( [`@test block if helper expects one argument`]() { expectAssertion(() => { compile(`{{#if}}aVal{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `#if requires a single argument. ('baz/foo-bar' @ L1:C0) `); expectAssertion(() => { compile(`{{#if val1 val2}}aVal{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `#if requires a single argument. ('baz/foo-bar' @ L1:C0) `); expectAssertion(() => { compile(`{{#if}}aVal{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `#if requires a single argument. ('baz/foo-bar' @ L1:C0) `); } @@ -27,24 +27,24 @@ moduleFor( [`@test inline if helper expects between one and three arguments`]() { expectAssertion(() => { compile(`{{if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `The inline form of the 'if' helper expects two or three arguments. ('baz/foo-bar' @ L1:C0) `); compile(`{{if foo bar baz}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); } ['@test subexpression if helper expects between one and three arguments']() { expectAssertion(() => { compile(`{{input foo=(if)}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `The inline form of the 'if' helper expects two or three arguments. ('baz/foo-bar' @ L1:C12) `); compile(`{{some-thing foo=(if foo bar baz)}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); } } diff --git a/packages/ember-template-compiler/tests/plugins/assert-input-helper-without-block-test.js b/packages/ember-template-compiler/tests/plugins/assert-input-helper-without-block-test.js index 92b90cc12f8..66c51c8af9c 100644 --- a/packages/ember-template-compiler/tests/plugins/assert-input-helper-without-block-test.js +++ b/packages/ember-template-compiler/tests/plugins/assert-input-helper-without-block-test.js @@ -9,7 +9,7 @@ moduleFor( expectAssertion(() => { compile('{{#input value="123"}}Completely invalid{{/input}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, expectedMessage); } diff --git a/packages/ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js b/packages/ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js index c72009e6b78..3654132284c 100644 --- a/packages/ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js +++ b/packages/ember-template-compiler/tests/plugins/assert-reserved-named-arguments-test.js @@ -9,19 +9,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@arguments' is reserved`]() { expectAssertion(() => { compile(`{{@arguments}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@arguments' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @arguments}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@arguments' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @arguments "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@arguments' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -29,19 +29,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@args' is reserved`]() { expectAssertion(() => { compile(`{{@args}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@args' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @args}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@args' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @args "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@args' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -49,19 +49,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@block' is reserved`]() { expectAssertion(() => { compile(`{{@block}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@block' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @block}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@block' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @block "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@block' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -69,19 +69,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@else' is reserved`]() { expectAssertion(() => { compile(`{{@else}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@else' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @else}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@else' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @else "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@else' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -90,19 +90,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@Arguments' is reserved`]() { expectAssertion(() => { compile(`{{@Arguments}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Arguments' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @Arguments}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Arguments' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @Arguments "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Arguments' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -110,19 +110,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@Args' is reserved`]() { expectAssertion(() => { compile(`{{@Args}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Args' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @Args}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Args' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @Args "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Args' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -130,19 +130,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@FOO' is reserved`]() { expectAssertion(() => { compile(`{{@FOO}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@FOO' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @FOO}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@FOO' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @FOO "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@FOO' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -150,19 +150,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@Foo' is reserved`]() { expectAssertion(() => { compile(`{{@Foo}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Foo' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @Foo}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Foo' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @Foo "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@Foo' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -170,19 +170,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@.' is reserved`]() { expectAssertion(() => { compile(`{{@.}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@.' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @.}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@.' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @. "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@.' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -190,19 +190,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@_' is reserved`]() { expectAssertion(() => { compile(`{{@_}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@_' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @_}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@_' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @_ "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@_' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -210,19 +210,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@-' is reserved`]() { expectAssertion(() => { compile(`{{@-}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@-' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @-}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@-' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @- "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@-' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -230,19 +230,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@$' is reserved`]() { expectAssertion(() => { compile(`{{@$}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@$' is reserved. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile(`{{#if @$}}Yup{{/if}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@$' is reserved. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile(`{{input type=(if @$ "bar" "baz")}}`, { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@$' is reserved. ('baz/foo-bar' @ L1:C17) `); } @@ -250,19 +250,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @ "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -270,19 +270,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@0' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@0}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @0}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @0 "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -290,19 +290,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@1' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@1}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @1}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @1 "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -310,19 +310,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@2' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@2}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @2}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @2 "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -330,19 +330,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@@' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@@}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @@}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @@ "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -350,19 +350,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@=' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@=}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @=}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @= "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -370,19 +370,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { [`@test '@!' is de facto reserved (parse error)`](assert) { assert.throws(() => { compile('{{@!}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{#if @!}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); assert.throws(() => { compile('{{input type=(if @! "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, /Expecting 'ID'/); } @@ -395,19 +395,19 @@ if (EMBER_GLIMMER_NAMED_ARGUMENTS) { ['@test Paths beginning with @ are not valid']() { expectAssertion(() => { compile('{{@foo}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@foo' is not a valid path. ('baz/foo-bar' @ L1:C2) `); expectAssertion(() => { compile('{{#if @foo}}Yup{{/if}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@foo' is not a valid path. ('baz/foo-bar' @ L1:C6) `); expectAssertion(() => { compile('{{input type=(if @foo "bar" "baz")}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, `'@foo' is not a valid path. ('baz/foo-bar' @ L1:C17) `); } diff --git a/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js b/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js index dc19ab55b6b..6d393dc674a 100644 --- a/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js +++ b/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js @@ -11,7 +11,7 @@ moduleFor( expectDeprecation(() => { compile('{{render "foo-bar" coolModel}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, expectedMessage); } diff --git a/packages/ember-template-compiler/tests/plugins/deprecate-render-test.js b/packages/ember-template-compiler/tests/plugins/deprecate-render-test.js index 2985a1334f5..4ebe4fd9a43 100644 --- a/packages/ember-template-compiler/tests/plugins/deprecate-render-test.js +++ b/packages/ember-template-compiler/tests/plugins/deprecate-render-test.js @@ -11,7 +11,7 @@ moduleFor( expectDeprecation(() => { compile('{{render "foo-bar"}}', { - moduleName: 'baz/foo-bar' + moduleName: 'baz/foo-bar', }); }, expectedMessage); } diff --git a/packages/ember-template-compiler/tests/plugins/transform-dot-component-invocation-test.js b/packages/ember-template-compiler/tests/plugins/transform-dot-component-invocation-test.js index f633e9be316..e017c88ec7e 100644 --- a/packages/ember-template-compiler/tests/plugins/transform-dot-component-invocation-test.js +++ b/packages/ember-template-compiler/tests/plugins/transform-dot-component-invocation-test.js @@ -18,7 +18,7 @@ moduleFor( '{{#my-component as |c|}}{{c.a "Chad"}}{{/my-component}}', '{{#my-component as |c|}}{{#c.a}}{{/c.a}}{{/my-component}}', '', // GH#15740 - '' // GH#15217 + '', // GH#15217 ].forEach((layout, i) => { compile(layout, { moduleName: `example-${i}` }); }); diff --git a/packages/ember-template-compiler/tests/plugins/transform-inline-link-to-test.js b/packages/ember-template-compiler/tests/plugins/transform-inline-link-to-test.js index d043f5805a1..7e3e196babf 100644 --- a/packages/ember-template-compiler/tests/plugins/transform-inline-link-to-test.js +++ b/packages/ember-template-compiler/tests/plugins/transform-inline-link-to-test.js @@ -8,7 +8,7 @@ moduleFor( assert.expect(0); compile(`{{link-to 'foo' 'index'}}`, { - moduleName: 'foo/bar/baz' + moduleName: 'foo/bar/baz', }); } } diff --git a/packages/ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js b/packages/ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js index f627a85b60f..0cc0deb1dd4 100644 --- a/packages/ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js +++ b/packages/ember-template-compiler/tests/plugins/transform-input-type-syntax-test.js @@ -4,25 +4,19 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'ember-template-compiler: input type syntax', class extends AbstractTestCase { - ['@test Can compile an {{input}} helper that has a sub-expression value as its type']( - assert - ) { + ['@test Can compile an {{input}} helper that has a sub-expression value as its type'](assert) { assert.expect(0); compile(`{{input type=(if true 'password' 'text')}}`); } - ['@test Can compile an {{input}} helper with a string literal type']( - assert - ) { + ['@test Can compile an {{input}} helper with a string literal type'](assert) { assert.expect(0); compile(`{{input type='text'}}`); } - ['@test Can compile an {{input}} helper with a type stored in a var']( - assert - ) { + ['@test Can compile an {{input}} helper with a type stored in a var'](assert) { assert.expect(0); compile(`{{input type=_type}}`); diff --git a/packages/ember-template-compiler/tests/system/bootstrap-test.js b/packages/ember-template-compiler/tests/system/bootstrap-test.js index 89e52c854f4..ff2c79a84c8 100644 --- a/packages/ember-template-compiler/tests/system/bootstrap-test.js +++ b/packages/ember-template-compiler/tests/system/bootstrap-test.js @@ -1,18 +1,12 @@ import { run } from 'ember-metal'; -import { - Component, - getTemplate, - setTemplates, - hasTemplate, - setTemplate -} from 'ember-glimmer'; +import { Component, getTemplate, setTemplates, hasTemplate, setTemplate } from 'ember-glimmer'; import bootstrap from '../../system/bootstrap'; import { runAppend, runDestroy, buildOwner, moduleFor, - AbstractTestCase + AbstractTestCase, } from 'internal-test-helpers'; let component, fixture; @@ -33,18 +27,14 @@ function checkTemplate(templateName, assert) { Component.extend({ layoutName: '-top-level', firstName: 'Tobias', - drug: 'teamocil' + drug: 'teamocil', }) ); component = owner.lookup('component:-top-level'); runAppend(component); - assert.equal( - qunitFixture.textContent.trim(), - 'Tobias takes teamocil', - 'template works' - ); + assert.equal(qunitFixture.textContent.trim(), 'Tobias takes teamocil', 'template works'); runDestroy(component); } @@ -80,11 +70,8 @@ moduleFor( checkTemplate('funkyTemplate', assert); } - ['@test template without data-template-name or id should default to application']( - assert - ) { - fixture.innerHTML = - ''; + ['@test template without data-template-name or id should default to application'](assert) { + fixture.innerHTML = ''; checkTemplate('application', assert); } @@ -106,9 +93,7 @@ moduleFor( assert.equal(template({ name: 'Tobias' }).trim(), 'Tobias'); } - ['@test duplicated default application templates should throw exception']( - assert - ) { + ['@test duplicated default application templates should throw exception'](assert) { fixture.innerHTML = ''; @@ -156,9 +141,7 @@ moduleFor( ); } - ['@test duplicated template data-template-name should throw exception']( - assert - ) { + ['@test duplicated template data-template-name should throw exception'](assert) { fixture.innerHTML = ''; diff --git a/packages/ember-template-compiler/tests/system/compile_options_test.js b/packages/ember-template-compiler/tests/system/compile_options_test.js index 1c0dcb8574d..7c178635d60 100644 --- a/packages/ember-template-compiler/tests/system/compile_options_test.js +++ b/packages/ember-template-compiler/tests/system/compile_options_test.js @@ -3,13 +3,9 @@ import { compileOptions, defaultPlugins, registerPlugin, - unregisterPlugin + unregisterPlugin, } from '../../index'; -import { - moduleFor, - AbstractTestCase, - RenderingTestCase -} from 'internal-test-helpers'; +import { moduleFor, AbstractTestCase, RenderingTestCase } from 'internal-test-helpers'; moduleFor( 'ember-template-compiler: default compile options', @@ -71,17 +67,13 @@ class CustomPluginsTests extends RenderingTestCase { this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: 'hahaha', 'data-blah': 'derp' }, - content: '' + content: '', }); } ['@test wrapped plugins are only invoked once per template'](assert) { this.render('
{{#if falsey}}nope{{/if}}
'); - assert.equal( - customTransformCounter, - 1, - 'transform should only be instantiated once' - ); + assert.equal(customTransformCounter, 1, 'transform should only be instantiated once'); } } @@ -103,11 +95,7 @@ moduleFor( 'application', '
' ); - assert.equal( - customTransformCounter, - 1, - 'transform should only be instantiated once' - ); + assert.equal(customTransformCounter, 1, 'transform should only be instantiated once'); } } ); @@ -119,8 +107,8 @@ moduleFor( compile(templateString) { return compile(templateString, { plugins: { - ast: [CustomTransform] - } + ast: [CustomTransform], + }, }); } } diff --git a/packages/ember-testing/lib/adapters/adapter.js b/packages/ember-testing/lib/adapters/adapter.js index 88371e81ead..f15bd979f6f 100644 --- a/packages/ember-testing/lib/adapters/adapter.js +++ b/packages/ember-testing/lib/adapters/adapter.js @@ -54,5 +54,5 @@ export default EmberObject.extend({ */ exception(error) { throw error; - } + }, }); diff --git a/packages/ember-testing/lib/adapters/qunit.js b/packages/ember-testing/lib/adapters/qunit.js index 59eda9c5d61..b6e398eaefd 100644 --- a/packages/ember-testing/lib/adapters/qunit.js +++ b/packages/ember-testing/lib/adapters/qunit.js @@ -24,9 +24,7 @@ export default Adapter.extend({ // very old QUnit version QUnit.stop(); } else { - this.doneCallbacks.push( - QUnit.config.current ? QUnit.config.current.assert.async() : null - ); + this.doneCallbacks.push(QUnit.config.current ? QUnit.config.current.assert.async() : null); } }, asyncEnd() { @@ -45,5 +43,5 @@ export default Adapter.extend({ }, exception(error) { QUnit.config.current.assert.ok(false, inspect(error)); - } + }, }); diff --git a/packages/ember-testing/lib/events.js b/packages/ember-testing/lib/events.js index 94e480cb24e..1b8a4086482 100644 --- a/packages/ember-testing/lib/events.js +++ b/packages/ember-testing/lib/events.js @@ -13,7 +13,7 @@ const MOUSE_EVENT_TYPES = [ 'mouseleave', 'mousemove', 'mouseout', - 'mouseover' + 'mouseover', ]; export function focus(el) { @@ -35,7 +35,7 @@ export function focus(el) { if (browserIsNotFocused) { // if the browser is not focused the previous `el.focus()` didn't fire an event, so we simulate it fireEvent(el, 'focus', { - bubbles: false + bubbles: false, }); fireEvent(el, 'focusin'); @@ -60,7 +60,7 @@ export function fireEvent(element, type, options = {}) { screenX: x + 5, screenY: y + 95, clientX: x, - clientY: y + clientY: y, }; event = buildMouseEvent(type, assign(simulatedCoordinates, options)); } else { diff --git a/packages/ember-testing/lib/ext/application.js b/packages/ember-testing/lib/ext/application.js index 313a24f7eb9..6ced31b2e36 100644 --- a/packages/ember-testing/lib/ext/application.js +++ b/packages/ember-testing/lib/ext/application.js @@ -71,7 +71,7 @@ EmberApplication.reopen({ this.testing = true; this.resolveRegistration('router:main').reopen({ - location: 'none' + location: 'none', }); }, @@ -116,19 +116,14 @@ EmberApplication.reopen({ willDestroy() { this._super(...arguments); this.removeTestHelpers(); - } + }, }); this.testHelpers = {}; for (let name in helpers) { this.originalMethods[name] = this.helperContainer[name]; this.testHelpers[name] = this.helperContainer[name] = helper(this, name); - protoWrap( - TestPromise.prototype, - name, - helper(this, name), - helpers[name].meta.wait - ); + protoWrap(TestPromise.prototype, name, helper(this, name), helpers[name].meta.wait); } invokeInjectHelpersCallbacks(this); @@ -158,7 +153,7 @@ EmberApplication.reopen({ delete this.testHelpers[name]; delete this.originalMethods[name]; } - } + }, }); // This method is no longer needed @@ -191,8 +186,6 @@ function helper(app, name) { // asynchronous here, because fn may not be invoked before we // return. asyncStart(); - return lastPromise - .then(() => fn.apply(app, [app, ...args])) - .finally(asyncEnd); + return lastPromise.then(() => fn.apply(app, [app, ...args])).finally(asyncEnd); }; } diff --git a/packages/ember-testing/lib/helpers.js b/packages/ember-testing/lib/helpers.js index f5978b7a246..24522ac9f48 100644 --- a/packages/ember-testing/lib/helpers.js +++ b/packages/ember-testing/lib/helpers.js @@ -1,7 +1,4 @@ -import { - registerHelper as helper, - registerAsyncHelper as asyncHelper -} from './test/helpers'; +import { registerHelper as helper, registerAsyncHelper as asyncHelper } from './test/helpers'; import andThen from './helpers/and_then'; import click from './helpers/click'; import currentPath from './helpers/current_path'; diff --git a/packages/ember-testing/lib/helpers/key_event.js b/packages/ember-testing/lib/helpers/key_event.js index 857bff8daea..bed4161a048 100644 --- a/packages/ember-testing/lib/helpers/key_event.js +++ b/packages/ember-testing/lib/helpers/key_event.js @@ -17,13 +17,7 @@ @since 1.5.0 @public */ -export default function keyEvent( - app, - selector, - contextOrType, - typeOrKeyCode, - keyCode -) { +export default function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { let context, type; if (keyCode === undefined) { @@ -37,6 +31,6 @@ export default function keyEvent( return app.testHelpers.triggerEvent(selector, context, type, { keyCode, - which: keyCode + which: keyCode, }); } diff --git a/packages/ember-testing/lib/helpers/trigger_event.js b/packages/ember-testing/lib/helpers/trigger_event.js index ad2acaec3e9..4b6e0a04f0d 100644 --- a/packages/ember-testing/lib/helpers/trigger_event.js +++ b/packages/ember-testing/lib/helpers/trigger_event.js @@ -22,13 +22,7 @@ import { fireEvent } from '../events'; @since 1.5.0 @public */ -export default function triggerEvent( - app, - selector, - contextOrType, - typeOrOptions, - possibleOptions -) { +export default function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { let arity = arguments.length; let context, type, options; diff --git a/packages/ember-testing/lib/helpers/wait.js b/packages/ember-testing/lib/helpers/wait.js index 5c237682cd7..d7a7ba90b2e 100644 --- a/packages/ember-testing/lib/helpers/wait.js +++ b/packages/ember-testing/lib/helpers/wait.js @@ -43,8 +43,7 @@ export default function wait(app, value) { // Every 10ms, poll for the async thing to have finished let watcher = setInterval(() => { // 1. If the router is loading, keep polling - let routerIsLoading = - router._routerMicrolib && !!router._routerMicrolib.activeTransition; + let routerIsLoading = router._routerMicrolib && !!router._routerMicrolib.activeTransition; if (routerIsLoading) { return; } diff --git a/packages/ember-testing/lib/initializers.js b/packages/ember-testing/lib/initializers.js index 6afa36167e9..f464fb4e61a 100644 --- a/packages/ember-testing/lib/initializers.js +++ b/packages/ember-testing/lib/initializers.js @@ -11,7 +11,7 @@ onLoad('Ember.Application', function(Application) { if (application.testing) { application.deferReadiness(); } - } + }, }); } }); diff --git a/packages/ember-testing/lib/setup_for_testing.js b/packages/ember-testing/lib/setup_for_testing.js index 1ac8d9afe54..597f89ae0b2 100644 --- a/packages/ember-testing/lib/setup_for_testing.js +++ b/packages/ember-testing/lib/setup_for_testing.js @@ -5,7 +5,7 @@ import { getAdapter, setAdapter } from './test/adapter'; import { incrementPendingRequests, decrementPendingRequests, - clearPendingRequests + clearPendingRequests, } from './test/pending_requests'; import Adapter from './adapters/adapter'; import QUnitAdapter from './adapters/qunit'; @@ -30,9 +30,7 @@ export default function setupForTesting() { let adapter = getAdapter(); // if adapter is not manually set default to QUnit if (!adapter) { - setAdapter( - typeof self.QUnit === 'undefined' ? new Adapter() : new QUnitAdapter() - ); + setAdapter(typeof self.QUnit === 'undefined' ? new Adapter() : new QUnitAdapter()); } document.removeEventListener('ajaxSend', incrementPendingRequests); diff --git a/packages/ember-testing/lib/support.js b/packages/ember-testing/lib/support.js index 6b62bdc031e..ace70de906a 100644 --- a/packages/ember-testing/lib/support.js +++ b/packages/ember-testing/lib/support.js @@ -43,26 +43,20 @@ if (environment.hasDOM && !jQueryDisabled) { $.event.special.click = { // For checkbox, fire native event so checked state will be right trigger() { - if ( - this.nodeName === 'INPUT' && - this.type === 'checkbox' && - this.click - ) { + if (this.nodeName === 'INPUT' && this.type === 'checkbox' && this.click) { this.click(); return false; } - } + }, }; } }); // Try again to verify that the patch took effect or blow up. testCheckboxClick(function() { - warn( - "clicked checkboxes should be checked! the jQuery patch didn't work", - this.checked, - { id: 'ember-testing.test-checkbox-click' } - ); + warn("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked, { + id: 'ember-testing.test-checkbox-click', + }); }); }); } diff --git a/packages/ember-testing/lib/test.js b/packages/ember-testing/lib/test.js index 1aff70ba7f7..c1eaa33a127 100644 --- a/packages/ember-testing/lib/test.js +++ b/packages/ember-testing/lib/test.js @@ -1,12 +1,7 @@ /** @module ember */ -import { - helpers, - registerHelper, - registerAsyncHelper, - unregisterHelper -} from './test/helpers'; +import { helpers, registerHelper, registerAsyncHelper, unregisterHelper } from './test/helpers'; import { onInjectHelpers } from './test/on_inject_helpers'; import TestPromise, { promise, resolve } from './test/promise'; import { checkWaiters, registerWaiter, unregisterWaiter } from './test/waiters'; @@ -44,7 +39,7 @@ const Test = { resolve, registerWaiter, unregisterWaiter, - checkWaiters + checkWaiters, }; /** @@ -69,7 +64,7 @@ const Test = { */ Object.defineProperty(Test, 'adapter', { get: getAdapter, - set: setAdapter + set: setAdapter, }); export default Test; diff --git a/packages/ember-testing/lib/test/helpers.js b/packages/ember-testing/lib/test/helpers.js index f50780b0744..63a3774a8c9 100644 --- a/packages/ember-testing/lib/test/helpers.js +++ b/packages/ember-testing/lib/test/helpers.js @@ -45,7 +45,7 @@ export const helpers = {}; export function registerHelper(name, helperMethod) { helpers[name] = { method: helperMethod, - meta: { wait: false } + meta: { wait: false }, }; } @@ -98,7 +98,7 @@ export function registerHelper(name, helperMethod) { export function registerAsyncHelper(name, helperMethod) { helpers[name] = { method: helperMethod, - meta: { wait: true } + meta: { wait: true }, }; } diff --git a/packages/ember-testing/lib/test/pending_requests.js b/packages/ember-testing/lib/test/pending_requests.js index eb73e32a21b..ef11388ac9a 100644 --- a/packages/ember-testing/lib/test/pending_requests.js +++ b/packages/ember-testing/lib/test/pending_requests.js @@ -8,16 +8,12 @@ export function clearPendingRequests() { requests.length = 0; } -export function incrementPendingRequests( - { detail } = { detail: { xhr: null } } -) { +export function incrementPendingRequests({ detail } = { detail: { xhr: null } }) { let xhr = detail.xhr; requests.push(xhr); } -export function decrementPendingRequests( - { detail } = { detail: { xhr: null } } -) { +export function decrementPendingRequests({ detail } = { detail: { xhr: null } }) { let xhr = detail.xhr; for (let i = 0; i < requests.length; i++) { if (xhr === requests[i]) { diff --git a/packages/ember-testing/lib/test/promise.js b/packages/ember-testing/lib/test/promise.js index d69bfea4c83..6a0d8e1c911 100644 --- a/packages/ember-testing/lib/test/promise.js +++ b/packages/ember-testing/lib/test/promise.js @@ -11,9 +11,7 @@ export default class TestPromise extends RSVP.Promise { then(_onFulfillment, ...args) { let onFulfillment = - typeof _onFulfillment === 'function' - ? result => isolate(_onFulfillment, result) - : undefined; + typeof _onFulfillment === 'function' ? result => isolate(_onFulfillment, result) : undefined; return super.then(onFulfillment, ...args); } } diff --git a/packages/ember-testing/tests/acceptance_test.js b/packages/ember-testing/tests/acceptance_test.js index ac85e60b67b..85a5f8a4012 100644 --- a/packages/ember-testing/tests/acceptance_test.js +++ b/packages/ember-testing/tests/acceptance_test.js @@ -42,7 +42,7 @@ if (!jQueryDisabled) { Route.extend({ model() { testContext.indexHitCount += 1; - } + }, }) ); @@ -52,7 +52,7 @@ if (!jQueryDisabled) { renderTemplate() { testContext.currentRoute = 'posts'; this._super(...arguments); - } + }, }) ); @@ -74,7 +74,7 @@ if (!jQueryDisabled) { renderTemplate() { testContext.currentRoute = 'comments'; this._super(...arguments); - } + }, }) ); @@ -85,7 +85,7 @@ if (!jQueryDisabled) { Route.extend({ beforeModel(transition) { transition.abort(); - } + }, }) ); @@ -94,7 +94,7 @@ if (!jQueryDisabled) { Route.extend({ beforeModel() { this.transitionTo('comments'); - } + }, }) ); @@ -124,20 +124,12 @@ if (!jQueryDisabled) { window .visit('/posts') .then(() => { - assert.equal( - this.currentRoute, - 'posts', - 'Successfully visited posts route' - ); + assert.equal(this.currentRoute, 'posts', 'Successfully visited posts route'); assert.equal(window.currentURL(), '/posts', 'posts URL is correct'); return window.click('a:contains("Comments")'); }) .then(() => { - assert.equal( - this.currentRoute, - 'comments', - 'visit chained with click' - ); + assert.equal(this.currentRoute, 'comments', 'visit chained with click'); return window.fillIn('.ember-text-field', 'yeah'); }) .then(() => { @@ -146,11 +138,7 @@ if (!jQueryDisabled) { 'yeah', 'chained with fillIn' ); - return window.fillIn( - '.ember-text-field', - '#qunit-fixture', - 'context working' - ); + return window.fillIn('.ember-text-field', '#qunit-fixture', 'context working'); }) .then(() => { assert.equal( @@ -177,43 +165,23 @@ if (!jQueryDisabled) { .click('a:first', '#comments-link') .fillIn('.ember-text-field', 'hello') .then(() => { - assert.equal( - this.currentRoute, - 'comments', - 'Successfully visited comments route' - ); - assert.equal( - window.currentURL(), - '/comments', - 'Comments URL is correct' - ); + assert.equal(this.currentRoute, 'comments', 'Successfully visited comments route'); + assert.equal(window.currentURL(), '/comments', 'Comments URL is correct'); assert.equal( document.querySelector('.ember-text-field').value, 'hello', 'Fillin successfully works' ); window.find('.ember-text-field').one('keypress', e => { - assert.equal( - e.keyCode, - 13, - 'keyevent chained with correct keyCode.' - ); + assert.equal(e.keyCode, 13, 'keyevent chained with correct keyCode.'); assert.equal(e.which, 13, 'keyevent chained with correct which.'); }); }) .keyEvent('.ember-text-field', 'keypress', 13) .visit('/posts') .then(() => { - assert.equal( - this.currentRoute, - 'posts', - 'Thens can also be chained to helpers' - ); - assert.equal( - window.currentURL(), - '/posts', - 'URL is set correct on chained helpers' - ); + assert.equal(this.currentRoute, 'posts', 'Thens can also be chained to helpers'); + assert.equal(window.currentURL(), '/posts', 'URL is set correct on chained helpers'); }); } @@ -227,16 +195,8 @@ if (!jQueryDisabled) { window.fillIn('.ember-text-field', 'hello'); window.andThen(() => { - assert.equal( - this.currentRoute, - 'comments', - 'Successfully visited comments route' - ); - assert.equal( - window.currentURL(), - '/comments', - 'Comments URL is correct' - ); + assert.equal(this.currentRoute, 'comments', 'Successfully visited comments route'); + assert.equal(window.currentURL(), '/comments', 'Comments URL is correct'); assert.equal( window.find('.ember-text-field').val(), 'hello', @@ -263,16 +223,8 @@ if (!jQueryDisabled) { }); window.andThen(() => { - assert.equal( - this.currentRoute, - 'comments', - 'Successfully visited comments route' - ); - assert.equal( - window.currentURL(), - '/comments', - 'Comments URL is correct' - ); + assert.equal(this.currentRoute, 'comments', 'Successfully visited comments route'); + assert.equal(window.currentURL(), '/comments', 'Comments URL is correct'); assert.equal( window.find('.ember-text-field').val(), 'hello', @@ -306,16 +258,8 @@ if (!jQueryDisabled) { 'goodbye', 'Fillin successfully works' ); - assert.equal( - this.currentRoute, - 'comments', - 'Successfully visited comments route' - ); - assert.equal( - window.currentURL(), - '/comments', - 'Comments URL is correct' - ); + assert.equal(this.currentRoute, 'comments', 'Successfully visited comments route'); + assert.equal(window.currentURL(), '/comments', 'Comments URL is correct'); }); } @@ -331,16 +275,8 @@ if (!jQueryDisabled) { }); window.andThen(() => { - assert.equal( - this.currentRoute, - 'comments', - 'Successfully visited comments route' - ); - assert.equal( - window.currentURL(), - '/comments', - 'Comments URL is correct' - ); + assert.equal(this.currentRoute, 'comments', 'Successfully visited comments route'); + assert.equal(window.currentURL(), '/comments', 'Comments URL is correct'); assert.equal( window.find('.ember-text-field').val(), 'hello', @@ -356,23 +292,19 @@ if (!jQueryDisabled) { }); } - [`@test Aborted transitions are not logged via Ember.Test.adapter#exception`]( - assert - ) { + [`@test Aborted transitions are not logged via Ember.Test.adapter#exception`](assert) { assert.expect(0); Test.adapter = QUnitAdapter.create({ exception() { assert.ok(false, 'aborted transitions are not logged'); - } + }, }); window.visit('/abort_transition'); } - [`@test Unhandled exceptions are logged via Ember.Test.adapter#exception`]( - assert - ) { + [`@test Unhandled exceptions are logged via Ember.Test.adapter#exception`](assert) { assert.expect(2); console.error = () => {}; // eslint-disable-line no-console @@ -386,7 +318,7 @@ if (!jQueryDisabled) { ); // handle the rejection so it doesn't leak later. asyncHandled.catch(() => {}); - } + }, }); window.visit('/posts'); @@ -415,7 +347,7 @@ if (!jQueryDisabled) { 'Catch me', 'Exception successfully caught and passed to Ember.Test.adapter.exception' ); - } + }, }); window.visit('/posts'); @@ -425,20 +357,14 @@ if (!jQueryDisabled) { }); } - [`@test should not start routing on the root URL when visiting another`]( - assert - ) { + [`@test should not start routing on the root URL when visiting another`](assert) { assert.expect(4); window.visit('/posts'); window.andThen(() => { assert.ok(window.find('#comments-link'), 'found comments-link'); - assert.equal( - this.currentRoute, - 'posts', - 'Successfully visited posts route' - ); + assert.equal(this.currentRoute, 'posts', 'Successfully visited posts route'); assert.equal(window.currentURL(), '/posts', 'Posts URL is correct'); assert.equal( this.indexHitCount, @@ -454,11 +380,7 @@ if (!jQueryDisabled) { window.visit('/'); window.andThen(() => { - assert.equal( - this.indexHitCount, - 1, - 'should hit index once when visiting /' - ); + assert.equal(this.indexHitCount, 1, 'should hit index once when visiting /'); }); } @@ -476,7 +398,7 @@ if (!jQueryDisabled) { asyncEnd() { async--; this._super(); - } + }, }).create(); this.application.testHelpers.slowHelper(); @@ -498,19 +420,13 @@ if (!jQueryDisabled) { } } - [`@test visiting a URL that causes another transition should yield the correct URL`]( - assert - ) { + [`@test visiting a URL that causes another transition should yield the correct URL`](assert) { assert.expect(1); window.visit('/redirect'); window.andThen(() => { - assert.equal( - window.currentURL(), - '/comments', - 'Redirected to Comments URL' - ); + assert.equal(window.currentURL(), '/comments', 'Redirected to Comments URL'); }); } @@ -522,21 +438,13 @@ if (!jQueryDisabled) { window.visit('/posts'); window.andThen(function() { - assert.equal( - window.currentURL(), - '/posts', - 'First visited URL is correct' - ); + assert.equal(window.currentURL(), '/posts', 'First visited URL is correct'); }); window.visit('/redirect'); window.andThen(() => { - assert.equal( - window.currentURL(), - '/comments', - 'Redirected to Comments URL' - ); + assert.equal(window.currentURL(), '/comments', 'Redirected to Comments URL'); }); } } diff --git a/packages/ember-testing/tests/adapters/qunit_test.js b/packages/ember-testing/tests/adapters/qunit_test.js index f464333a894..d63a802c441 100644 --- a/packages/ember-testing/tests/adapters/qunit_test.js +++ b/packages/ember-testing/tests/adapters/qunit_test.js @@ -34,9 +34,7 @@ moduleFor( }, 50); } - ['@test asyncStart waits for equal numbers of asyncEnd to finish a test']( - assert - ) { + ['@test asyncStart waits for equal numbers of asyncEnd to finish a test'](assert) { let adapter = QUnitAdapter.create(); adapter.asyncStart(); diff --git a/packages/ember-testing/tests/adapters_test.js b/packages/ember-testing/tests/adapters_test.js index 4b93b672687..f7db36a5746 100644 --- a/packages/ember-testing/tests/adapters_test.js +++ b/packages/ember-testing/tests/adapters_test.js @@ -64,7 +64,7 @@ moduleFor( CustomAdapter = Adapter.extend({ asyncStart() { assert.ok(true, 'Correct adapter was used'); - } + }, }); run(function() { @@ -105,16 +105,14 @@ moduleFor( assert.ok(!(Test.adapter instanceof QUnitAdapter)); } - ['@test With Ember.Test.adapter set, errors in synchronous Ember.run are bubbled out']( - assert - ) { + ['@test With Ember.Test.adapter set, errors in synchronous Ember.run are bubbled out'](assert) { let thrown = new Error('Boom!'); let caughtInAdapter, caughtInCatch; Test.adapter = QUnitAdapter.create({ exception(error) { caughtInAdapter = error; - } + }, }); try { @@ -130,11 +128,7 @@ moduleFor( undefined, 'test adapter should never receive synchronous errors' ); - assert.equal( - caughtInCatch, - thrown, - 'a "normal" try/catch should catch errors in sync run' - ); + assert.equal(caughtInCatch, thrown, 'a "normal" try/catch should catch errors in sync run'); } ['@test when both Ember.onerror (which rethrows) and TestAdapter are registered - sync run']( @@ -144,18 +138,12 @@ moduleFor( Test.adapter = { exception() { - assert.notOk( - true, - 'adapter is not called for errors thrown in sync run loops' - ); - } + assert.notOk(true, 'adapter is not called for errors thrown in sync run loops'); + }, }; setOnerror(function(error) { - assert.ok( - true, - 'onerror is called for sync errors even if TestAdapter is setup' - ); + assert.ok(true, 'onerror is called for sync errors even if TestAdapter is setup'); throw error; }); @@ -169,30 +157,19 @@ moduleFor( Test.adapter = { exception() { - assert.notOk( - true, - 'adapter is not called for errors thrown in sync run loops' - ); - } + assert.notOk(true, 'adapter is not called for errors thrown in sync run loops'); + }, }; setOnerror(function() { - assert.ok( - true, - 'onerror is called for sync errors even if TestAdapter is setup' - ); + assert.ok(true, 'onerror is called for sync errors even if TestAdapter is setup'); }); runThatThrowsSync(); - assert.ok( - true, - 'no error was thrown, Ember.onerror can intercept errors' - ); + assert.ok(true, 'no error was thrown, Ember.onerror can intercept errors'); } - ['@test when TestAdapter is registered and error is thrown - async run']( - assert - ) { + ['@test when TestAdapter is registered and error is thrown - async run'](assert) { assert.expect(3); let done = assert.async(); @@ -200,7 +177,7 @@ moduleFor( Test.adapter = { exception(error) { caughtInAdapter = error; - } + }, }; window.onerror = function(message) { @@ -228,32 +205,25 @@ moduleFor( ); assert.pushResult({ - result: /Error for testing error handling/.test( - caughtByWindowOnerror - ), + result: /Error for testing error handling/.test(caughtByWindowOnerror), actual: caughtByWindowOnerror, expected: 'to include `Error for testing error handling`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); done(); }, 20); } - ['@test when both Ember.onerror and TestAdapter are registered - async run']( - assert - ) { + ['@test when both Ember.onerror and TestAdapter are registered - async run'](assert) { assert.expect(1); let done = assert.async(); Test.adapter = { exception() { - assert.notOk( - true, - 'Adapter.exception is not called for errors thrown in next' - ); - } + assert.notOk(true, 'Adapter.exception is not called for errors thrown in next'); + }, }; setOnerror(function() { @@ -268,14 +238,12 @@ moduleFor( function testAdapter(message, generatePromise, timeout = 10) { return class PromiseFailureTests extends AdapterSetupAndTearDown { - [`@test ${message} when TestAdapter without \`exception\` method is present - rsvp`]( - assert - ) { + [`@test ${message} when TestAdapter without \`exception\` method is present - rsvp`](assert) { assert.expect(1); let thrown = new Error('the error'); Test.adapter = QUnitAdapter.create({ - exception: undefined + exception: undefined, }); window.onerror = function(message) { @@ -284,7 +252,7 @@ function testAdapter(message, generatePromise, timeout = 10) { actual: message, expected: 'to include `the error`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); // prevent "bubbling" and therefore failing the test @@ -305,7 +273,7 @@ function testAdapter(message, generatePromise, timeout = 10) { let thrown = new Error('the error'); Test.adapter = QUnitAdapter.create({ - exception: undefined + exception: undefined, }); setOnerror(function(error) { @@ -314,7 +282,7 @@ function testAdapter(message, generatePromise, timeout = 10) { actual: error.message, expected: 'to include `the error`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); }); @@ -337,7 +305,7 @@ function testAdapter(message, generatePromise, timeout = 10) { thrown, 'Adapter.exception is called for errors thrown in RSVP promises' ); - } + }, }); generatePromise(thrown); @@ -347,9 +315,7 @@ function testAdapter(message, generatePromise, timeout = 10) { return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); } - [`@test ${message} when both Ember.onerror and TestAdapter are present - rsvp`]( - assert - ) { + [`@test ${message} when both Ember.onerror and TestAdapter are present - rsvp`](assert) { assert.expect(1); let thrown = new Error('the error'); @@ -360,14 +326,11 @@ function testAdapter(message, generatePromise, timeout = 10) { thrown, 'Adapter.exception is called for errors thrown in RSVP promises' ); - } + }, }); setOnerror(function() { - assert.notOk( - true, - 'Ember.onerror is not called if Test.adapter does not rethrow' - ); + assert.notOk(true, 'Ember.onerror is not called if Test.adapter does not rethrow'); }); generatePromise(thrown); @@ -377,9 +340,7 @@ function testAdapter(message, generatePromise, timeout = 10) { return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); } - [`@test ${message} when both Ember.onerror and TestAdapter are present - rsvp`]( - assert - ) { + [`@test ${message} when both Ember.onerror and TestAdapter are present - rsvp`](assert) { assert.expect(2); let thrown = new Error('the error'); @@ -391,7 +352,7 @@ function testAdapter(message, generatePromise, timeout = 10) { 'Adapter.exception is called for errors thrown in RSVP promises' ); throw error; - } + }, }); setOnerror(function(error) { diff --git a/packages/ember-testing/tests/ext/rsvp_test.js b/packages/ember-testing/tests/ext/rsvp_test.js index b40572d2fd1..cbbcaab49cb 100644 --- a/packages/ember-testing/tests/ext/rsvp_test.js +++ b/packages/ember-testing/tests/ext/rsvp_test.js @@ -23,7 +23,7 @@ moduleFor( }, asyncEnd() { asyncEnded++; - } + }, }); } diff --git a/packages/ember-testing/tests/helpers_test.js b/packages/ember-testing/tests/helpers_test.js index 0f9c25d0c0b..5659e9cd4df 100644 --- a/packages/ember-testing/tests/helpers_test.js +++ b/packages/ember-testing/tests/helpers_test.js @@ -1,8 +1,4 @@ -import { - moduleFor, - AutobootApplicationTestCase, - isIE11 -} from 'internal-test-helpers'; +import { moduleFor, AutobootApplicationTestCase, isIE11 } from 'internal-test-helpers'; import { Route } from 'ember-routing'; import { Controller, RSVP } from 'ember-runtime'; @@ -17,7 +13,7 @@ import { pendingRequests, incrementPendingRequests, decrementPendingRequests, - clearPendingRequests + clearPendingRequests, } from '../test/pending_requests'; import { setAdapter, getAdapter } from '../test/adapter'; import { registerWaiter, unregisterWaiter } from '../test/waiters'; @@ -50,9 +46,7 @@ function assertHelpers(assert, application, helperContainer, expected) { assert.ok( presentInHelperContainer === expected, - "Expected '" + - helper + - "' to be present in the helper container (defaults to window)." + "Expected '" + helper + "' to be present in the helper container (defaults to window)." ); assert.ok( presentInTestHelpers === expected, @@ -118,10 +112,7 @@ if (!jQueryDisabled) { assertHelpers(assert, this.application); - assert.ok( - Test.Promise.prototype.LeakyMcLeakLeak, - 'helper in question SHOULD be present' - ); + assert.ok(Test.Promise.prototype.LeakyMcLeakLeak, 'helper in question SHOULD be present'); this.application.removeTestHelpers(); @@ -144,24 +135,16 @@ if (!jQueryDisabled) { assert.equal(routerInstance.location, 'none'); } - [`@test Ember.Application.setupForTesting sets the application to 'testing'`]( - assert - ) { + [`@test Ember.Application.setupForTesting sets the application to 'testing'`](assert) { this.runTask(() => { this.createApplication(); this.application.setupForTesting(); }); - assert.equal( - this.application.testing, - true, - 'Application instance is set to testing.' - ); + assert.equal(this.application.testing, true, 'Application instance is set to testing.'); } - [`@test Ember.Application.setupForTesting leaves the system in a deferred state.`]( - assert - ) { + [`@test Ember.Application.setupForTesting leaves the system in a deferred state.`](assert) { this.runTask(() => { this.createApplication(); this.application.setupForTesting(); @@ -211,24 +194,14 @@ if (!jQueryDisabled) { this.application.setupForTesting(); }); - assert.equal( - injected, - 0, - 'onInjectHelpers are not called before injectTestHelpers' - ); + assert.equal(injected, 0, 'onInjectHelpers are not called before injectTestHelpers'); this.application.injectTestHelpers(); - assert.equal( - injected, - 1, - 'onInjectHelpers are called after injectTestHelpers' - ); + assert.equal(injected, 1, 'onInjectHelpers are called after injectTestHelpers'); } - [`@test Ember.Application#injectTestHelpers adds helpers to provided object.`]( - assert - ) { + [`@test Ember.Application#injectTestHelpers adds helpers to provided object.`](assert) { let helpers = {}; this.runTask(() => { @@ -257,18 +230,10 @@ if (!jQueryDisabled) { this.application.injectTestHelpers(helpers); - assert.notEqual( - helpers.visit, - 'snazzleflabber', - 'helper added to container' - ); + assert.notEqual(helpers.visit, 'snazzleflabber', 'helper added to container'); this.application.removeTestHelpers(); - assert.equal( - helpers.visit, - 'snazzleflabber', - 'original value added back to container' - ); + assert.equal(helpers.visit, 'snazzleflabber', 'original value added back to container'); } } ); @@ -300,22 +265,14 @@ if (!jQueryDisabled) { return testHelpers .wait() .then(() => { - assert.equal( - waiter(), - true, - 'should not resolve until our waiter is ready' - ); + assert.equal(waiter(), true, 'should not resolve until our waiter is ready'); unregisterWaiter(waiter); counter = 0; return testHelpers.wait(); }) .then(() => { assert.equal(counter, 0, 'unregistered waiter was not checked'); - assert.equal( - otherWaiter(), - true, - 'other waiter is still registered' - ); + assert.equal(otherWaiter(), true, 'other waiter is still registered'); }) .finally(() => { unregisterWaiter(otherWaiter); @@ -365,11 +322,7 @@ if (!jQueryDisabled) { return testHelpers.wait(RSVP.resolve(promiseObjectValue)); }) .then(val => { - assert.equal( - val, - promiseObjectValue, - 'can resolve to a promise resolution value' - ); + assert.equal(val, promiseObjectValue, 'can resolve to a promise resolution value'); }); } @@ -400,7 +353,7 @@ if (!jQueryDisabled) { events.push(e.type); } }); - } + }, }) ); @@ -415,7 +368,7 @@ if (!jQueryDisabled) { }, change() { events.push('change:' + this.get('checked')); - } + }, }) ); @@ -444,11 +397,7 @@ if (!jQueryDisabled) { return testHelpers.click('.index-wrapper'); }) .then(() => { - assert.deepEqual( - events, - ['mousedown', 'mouseup', 'click'], - 'fires events in order' - ); + assert.deepEqual(events, ['mousedown', 'mouseup', 'click'], 'fires events in order'); }) .then(() => { events = []; @@ -491,17 +440,11 @@ if (!jQueryDisabled) { // i.e. mousedown, mouseup, change:true, click, click:true // Firefox differs so we can't assert the exact ordering here. // See https://bugzilla.mozilla.org/show_bug.cgi?id=843554. - assert.equal( - events.length, - 5, - 'fires click and change on checkboxes' - ); + assert.equal(events.length, 5, 'fires click and change on checkboxes'); }); } - [`@test 'click' triggers native events with simulated X/Y coordinates`]( - assert - ) { + [`@test 'click' triggers native events with simulated X/Y coordinates`](assert) { assert.expect(15); this.add( @@ -514,7 +457,7 @@ if (!jQueryDisabled) { this.element.addEventListener('mousedown', pushEvent); this.element.addEventListener('mouseup', pushEvent); this.element.addEventListener('click', pushEvent); - } + }, }) ); @@ -538,10 +481,7 @@ if (!jQueryDisabled) { }) .then(() => { events.forEach(e => { - assert.ok( - e instanceof window.Event, - 'The event is an instance of MouseEvent' - ); + assert.ok(e instanceof window.Event, 'The event is an instance of MouseEvent'); assert.ok(typeof e.screenX === 'number', 'screenX is correct'); assert.ok(typeof e.screenY === 'number', 'screenY is correct'); assert.ok(typeof e.clientX === 'number', 'clientX is correct'); @@ -562,14 +502,11 @@ if (!jQueryDisabled) { classNames: 'index-wrapper', didInsertElement() { this.element.addEventListener('mouseenter', e => (evt = e)); - } + }, }) ); - this.addTemplate( - 'index', - `{{#index-wrapper}}some text{{/index-wrapper}}` - ); + this.addTemplate('index', `{{#index-wrapper}}some text{{/index-wrapper}}`); this.runTask(() => { this.application.advanceReadiness(); @@ -581,10 +518,7 @@ if (!jQueryDisabled) { return triggerEvent('.index-wrapper', 'mouseenter'); }) .then(() => { - assert.ok( - evt instanceof window.Event, - 'The event is an instance of MouseEvent' - ); + assert.ok(evt instanceof window.Event, 'The event is an instance of MouseEvent'); assert.ok(typeof evt.screenX === 'number', 'screenX is correct'); assert.ok(typeof evt.screenY === 'number', 'screenY is correct'); assert.ok(typeof evt.clientX === 'number', 'clientX is correct'); @@ -605,11 +539,7 @@ if (!jQueryDisabled) { }, 20); return this.application.testHelpers.wait().then(() => { - assert.equal( - waitDone, - true, - 'should wait for the timer to be fired.' - ); + assert.equal(waitDone, true, 'should wait for the timer to be fired.'); }); } @@ -620,7 +550,7 @@ if (!jQueryDisabled) { counter: 0, ready() { return ++this.counter > 2; - } + }, }; let other = 0; @@ -638,26 +568,14 @@ if (!jQueryDisabled) { let { application: { testHelpers: { wait } } } = this; return wait() .then(() => { - assert.equal( - obj.ready(), - true, - 'should not resolve until our waiter is ready' - ); + assert.equal(obj.ready(), true, 'should not resolve until our waiter is ready'); unregisterWaiter(obj, obj.ready); obj.counter = 0; return wait(); }) .then(() => { - assert.equal( - obj.counter, - 0, - 'the unregistered waiter should still be at 0' - ); - assert.equal( - otherWaiter(), - true, - 'other waiter should still be registered' - ); + assert.equal(obj.counter, 0, 'the unregistered waiter should still be at 0'); + assert.equal(otherWaiter(), true, 'other waiter should still be registered'); }) .finally(() => { unregisterWaiter(otherWaiter); @@ -672,9 +590,7 @@ if (!jQueryDisabled) { }); } - [`@test 'triggerEvent' accepts an optional options hash without context`]( - assert - ) { + [`@test 'triggerEvent' accepts an optional options hash without context`](assert) { assert.expect(3); let event; @@ -685,7 +601,7 @@ if (!jQueryDisabled) { let domElem = document.querySelector('.input'); domElem.addEventListener('change', e => (event = e)); domElem.addEventListener('keydown', e => (event = e)); - } + }, }) ); @@ -717,9 +633,7 @@ if (!jQueryDisabled) { }); } - [`@test 'triggerEvent' can limit searching for a selector to a scope`]( - assert - ) { + [`@test 'triggerEvent' can limit searching for a selector to a scope`](assert) { assert.expect(2); let event; @@ -733,7 +647,7 @@ if (!jQueryDisabled) { let secondInput = document.querySelector('#limited .input'); secondInput.addEventListener('blur', e => (event = e)); secondInput.addEventListener('change', e => (event = e)); - } + }, }) ); @@ -778,7 +692,7 @@ if (!jQueryDisabled) { let foo = document.getElementById('foo'); foo.addEventListener('blur', e => (event = e)); foo.addEventListener('change', e => (event = e)); - } + }, }) ); @@ -826,9 +740,7 @@ if (!jQueryDisabled) { this.application.advanceReadiness(); }); - let { - application: { testHelpers: { visit, fillIn, andThen, find } } - } = this; + let { application: { testHelpers: { visit, fillIn, andThen, find } } } = this; visit('/'); fillIn('.current', '#parent', 'current value'); @@ -847,8 +759,8 @@ if (!jQueryDisabled) { actions: { wasFocused() { wasFocused = true; - } - } + }, + }, }) ); @@ -865,9 +777,7 @@ if (!jQueryDisabled) { this.application.advanceReadiness(); }); - let { - application: { testHelpers: { visit, fillIn, andThen, find, wait } } - } = this; + let { application: { testHelpers: { visit, fillIn, andThen, find, wait } } } = this; visit('/'); fillIn('#first', 'current value'); andThen(() => { @@ -879,9 +789,7 @@ if (!jQueryDisabled) { return wait(); } - [`@test 'fillIn' fires 'input' and 'change' events in the proper order`]( - assert - ) { + [`@test 'fillIn' fires 'input' and 'change' events in the proper order`](assert) { assert.expect(1); let events = []; @@ -894,8 +802,8 @@ if (!jQueryDisabled) { }, onchangeHandler(e) { events.push(e.type); - } - } + }, + }, }) ); @@ -912,9 +820,7 @@ if (!jQueryDisabled) { this.application.advanceReadiness(); }); - let { - application: { testHelpers: { visit, fillIn, andThen, wait } } - } = this; + let { application: { testHelpers: { visit, fillIn, andThen, wait } } } = this; visit('/'); fillIn('#first', 'current value'); @@ -929,9 +835,7 @@ if (!jQueryDisabled) { return wait(); } - [`@test 'fillIn' only sets the value in the first matched element`]( - assert - ) { + [`@test 'fillIn' only sets the value in the first matched element`](assert) { this.addTemplate( 'index', ` @@ -944,9 +848,7 @@ if (!jQueryDisabled) { this.application.advanceReadiness(); }); - let { - application: { testHelpers: { visit, fillIn, find, andThen, wait } } - } = this; + let { application: { testHelpers: { visit, fillIn, find, andThen, wait } } } = this; visit('/'); fillIn('input.in-test', 'new value'); @@ -958,9 +860,7 @@ if (!jQueryDisabled) { return wait(); } - [`@test 'triggerEvent' accepts an optional options hash and context`]( - assert - ) { + [`@test 'triggerEvent' accepts an optional options hash and context`](assert) { assert.expect(3); let event; @@ -974,7 +874,7 @@ if (!jQueryDisabled) { let secondInput = document.querySelector('#limited .input'); secondInput.addEventListener('keydown', e => (event = e), false); secondInput.addEventListener('change', e => (event = e), false); - } + }, }) ); @@ -997,7 +897,7 @@ if (!jQueryDisabled) { return wait() .then(() => { return triggerEvent('.input', '#limited', 'keydown', { - keyCode: 13 + keyCode: 13, }); }) .then(() => { @@ -1036,10 +936,7 @@ if (!jQueryDisabled) { andThen(() => { Test.adapter.asyncStart = () => { - assert.ok( - true, - 'Async start should be called after waiting for other helpers' - ); + assert.ok(true, 'Async start should be called after waiting for other helpers'); }; }); @@ -1095,16 +992,8 @@ if (!jQueryDisabled) { let { application: { testHelpers } } = this; return testHelpers.visit('/').then(() => { - assert.equal( - testHelpers.currentRouteName(), - 'index', - `should equal 'index'.` - ); - assert.equal( - testHelpers.currentPath(), - 'index', - `should equal 'index'.` - ); + assert.equal(testHelpers.currentRouteName(), 'index', `should equal 'index'.`); + assert.equal(testHelpers.currentPath(), 'index', `should equal 'index'.`); assert.equal(testHelpers.currentURL(), '/', `should equal '/'.`); }); } @@ -1119,16 +1008,8 @@ if (!jQueryDisabled) { 'posts.index', `should equal 'posts.index'.` ); - assert.equal( - testHelpers.currentPath(), - 'posts.index', - `should equal 'posts.index'.` - ); - assert.equal( - testHelpers.currentURL(), - '/posts', - `should equal '/posts'.` - ); + assert.equal(testHelpers.currentPath(), 'posts.index', `should equal 'posts.index'.`); + assert.equal(testHelpers.currentURL(), '/posts', `should equal '/posts'.`); }); } @@ -1137,21 +1018,9 @@ if (!jQueryDisabled) { let { application: { testHelpers } } = this; return testHelpers.visit('/posts/new').then(() => { - assert.equal( - testHelpers.currentRouteName(), - 'posts.new', - `should equal 'posts.new'.` - ); - assert.equal( - testHelpers.currentPath(), - 'posts.new', - `should equal 'posts.new'.` - ); - assert.equal( - testHelpers.currentURL(), - '/posts/new', - `should equal '/posts/new'.` - ); + assert.equal(testHelpers.currentRouteName(), 'posts.new', `should equal 'posts.new'.`); + assert.equal(testHelpers.currentPath(), 'posts.new', `should equal 'posts.new'.`); + assert.equal(testHelpers.currentURL(), '/posts/new', `should equal '/posts/new'.`); }); } @@ -1160,21 +1029,9 @@ if (!jQueryDisabled) { let { application: { testHelpers } } = this; return testHelpers.visit('/posts/edit').then(() => { - assert.equal( - testHelpers.currentRouteName(), - 'edit', - `should equal 'edit'.` - ); - assert.equal( - testHelpers.currentPath(), - 'posts.edit', - `should equal 'posts.edit'.` - ); - assert.equal( - testHelpers.currentURL(), - '/posts/edit', - `should equal '/posts/edit'.` - ); + assert.equal(testHelpers.currentRouteName(), 'edit', `should equal 'edit'.`); + assert.equal(testHelpers.currentPath(), 'posts.edit', `should equal 'posts.edit'.`); + assert.equal(testHelpers.currentURL(), '/posts/edit', `should equal '/posts/edit'.`); }); } } @@ -1183,26 +1040,16 @@ if (!jQueryDisabled) { moduleFor( 'ember-testing: pendingRequests', class extends HelpersApplicationTestCase { - [`@test pendingRequests is maintained for ajaxSend and ajaxComplete events`]( - assert - ) { + [`@test pendingRequests is maintained for ajaxSend and ajaxComplete events`](assert) { assert.equal(pendingRequests(), 0); let xhr = { some: 'xhr' }; customEvent('ajaxSend', xhr); - assert.equal( - pendingRequests(), - 1, - 'Ember.Test.pendingRequests was incremented' - ); + assert.equal(pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); customEvent('ajaxComplete', xhr); - assert.equal( - pendingRequests(), - 0, - 'Ember.Test.pendingRequests was decremented' - ); + assert.equal(pendingRequests(), 0, 'Ember.Test.pendingRequests was decremented'); } [`@test pendingRequests is ignores ajaxComplete events from past setupForTesting calls`]( @@ -1213,28 +1060,16 @@ if (!jQueryDisabled) { let xhr = { some: 'xhr' }; customEvent('ajaxSend', xhr); - assert.equal( - pendingRequests(), - 1, - 'Ember.Test.pendingRequests was incremented' - ); + assert.equal(pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); setupForTesting(); - assert.equal( - pendingRequests(), - 0, - 'Ember.Test.pendingRequests was reset' - ); + assert.equal(pendingRequests(), 0, 'Ember.Test.pendingRequests was reset'); let altXhr = { some: 'more xhr' }; customEvent('ajaxSend', altXhr); - assert.equal( - pendingRequests(), - 1, - 'Ember.Test.pendingRequests was incremented' - ); + assert.equal(pendingRequests(), 1, 'Ember.Test.pendingRequests was incremented'); customEvent('ajaxComplete', xhr); assert.equal( @@ -1286,7 +1121,7 @@ if (!jQueryDisabled) { Route.extend({ model() { return resolveLater(); - } + }, }) ); @@ -1294,10 +1129,8 @@ if (!jQueryDisabled) { 'route:user.profile', Route.extend({ beforeModel() { - return resolveLater().then(() => - this.transitionTo('user.edit') - ); - } + return resolveLater().then(() => this.transitionTo('user.edit')); + }, }) ); @@ -1315,27 +1148,11 @@ if (!jQueryDisabled) { let { application: { testHelpers } } = this; return testHelpers.visit('/user').then(() => { - assert.equal( - testHelpers.currentRouteName(), - 'user.index', - `should equal 'user.index'.` - ); - assert.equal( - testHelpers.currentPath(), - 'user.index', - `should equal 'user.index'.` - ); - assert.equal( - testHelpers.currentURL(), - '/user', - `should equal '/user'.` - ); + assert.equal(testHelpers.currentRouteName(), 'user.index', `should equal 'user.index'.`); + assert.equal(testHelpers.currentPath(), 'user.index', `should equal 'user.index'.`); + assert.equal(testHelpers.currentURL(), '/user', `should equal '/user'.`); let userRoute = this.applicationInstance.lookup('route:user'); - assert.equal( - userRoute.get('controller.model.firstName'), - 'Tom', - `should equal 'Tom'.` - ); + assert.equal(userRoute.get('controller.model.firstName'), 'Tom', `should equal 'Tom'.`); }); } @@ -1344,27 +1161,11 @@ if (!jQueryDisabled) { let { application: { testHelpers } } = this; return testHelpers.visit('/user/profile').then(() => { - assert.equal( - testHelpers.currentRouteName(), - 'user.edit', - `should equal 'user.edit'.` - ); - assert.equal( - testHelpers.currentPath(), - 'user.edit', - `should equal 'user.edit'.` - ); - assert.equal( - testHelpers.currentURL(), - '/user/edit', - `should equal '/user/edit'.` - ); + assert.equal(testHelpers.currentRouteName(), 'user.edit', `should equal 'user.edit'.`); + assert.equal(testHelpers.currentPath(), 'user.edit', `should equal 'user.edit'.`); + assert.equal(testHelpers.currentURL(), '/user/edit', `should equal '/user/edit'.`); let userRoute = this.applicationInstance.lookup('route:user'); - assert.equal( - userRoute.get('controller.model.firstName'), - 'Tom', - `should equal 'Tom'.` - ); + assert.equal(userRoute.get('controller.model.firstName'), 'Tom', `should equal 'Tom'.`); }); } } diff --git a/packages/ember-testing/tests/integration_test.js b/packages/ember-testing/tests/integration_test.js index b0a687c7853..4fcd9b22da1 100644 --- a/packages/ember-testing/tests/integration_test.js +++ b/packages/ember-testing/tests/integration_test.js @@ -35,7 +35,7 @@ moduleFor( this.add( 'route:people', Route.extend({ - model: () => this.modelContent + model: () => this.modelContent, }) ); @@ -59,11 +59,7 @@ moduleFor( this.runTask(() => this.application.advanceReadiness()); window.visit('/').then(() => { let rows = window.find('.name').length; - assert.equal( - rows, - 0, - 'successfully stubbed an empty array of people' - ); + assert.equal(rows, 0, 'successfully stubbed an empty array of people'); }); } else { this.runTask(() => this.application.advanceReadiness()); @@ -85,11 +81,7 @@ moduleFor( this.runTask(() => this.application.advanceReadiness()); window.visit('/').then(() => { let rows = window.find('.name').length; - assert.equal( - rows, - 2, - 'successfully stubbed a non empty array of people' - ); + assert.equal(rows, 2, 'successfully stubbed a non empty array of people'); }); } else { assert.expect(0); diff --git a/packages/ember-testing/tests/reexports_test.js b/packages/ember-testing/tests/reexports_test.js index 7ef75891d8b..fc5c0e056fe 100644 --- a/packages/ember-testing/tests/reexports_test.js +++ b/packages/ember-testing/tests/reexports_test.js @@ -9,7 +9,7 @@ class ReexportsTestCase extends AbstractTestCase {} ['Test', 'ember-testing'], ['Test.Adapter', 'ember-testing', 'Adapter'], ['Test.QUnitAdapter', 'ember-testing', 'QUnitAdapter'], - ['setupForTesting', 'ember-testing'] + ['setupForTesting', 'ember-testing'], ].forEach(reexport => { let [path, moduleId, exportName] = reexport; @@ -18,9 +18,7 @@ class ReexportsTestCase extends AbstractTestCase {} exportName = path; } - ReexportsTestCase.prototype[ - `@test Ember.${path} exports correctly` - ] = function(assert) { + ReexportsTestCase.prototype[`@test Ember.${path} exports correctly`] = function(assert) { confirmExport(Ember, assert, path, moduleId, exportName); }; }); diff --git a/packages/ember-testing/tests/test/waiters-test.js b/packages/ember-testing/tests/test/waiters-test.js index e7c9fbad87d..8d045263390 100644 --- a/packages/ember-testing/tests/test/waiters-test.js +++ b/packages/ember-testing/tests/test/waiters-test.js @@ -1,8 +1,4 @@ -import { - registerWaiter, - unregisterWaiter, - checkWaiters -} from '../../test/waiters'; +import { registerWaiter, unregisterWaiter, checkWaiters } from '../../test/waiters'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; class Waiters { @@ -109,10 +105,7 @@ moduleFor( return true; }); - assert.notOk( - this.waiters.check(), - 'checkWaiters returns true if all waiters return true' - ); + assert.notOk(this.waiters.check(), 'checkWaiters returns true if all waiters return true'); } ['@test checkWaiters returns true if any waiters return false'](assert) { @@ -130,10 +123,7 @@ moduleFor( return false; }); - assert.ok( - this.waiters.check(), - 'checkWaiters returns false if any waiters return false' - ); + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); } ['@test checkWaiters short circuits after first falsey waiter'](assert) { @@ -149,10 +139,7 @@ moduleFor( assert.notOk(true, 'waiter should not be called'); }); - assert.ok( - this.waiters.check(), - 'checkWaiters returns false if any waiters return false' - ); + assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false'); } } ); diff --git a/packages/ember-utils/lib/invoke.js b/packages/ember-utils/lib/invoke.js index b82e479b770..0c33d587dd0 100644 --- a/packages/ember-utils/lib/invoke.js +++ b/packages/ember-utils/lib/invoke.js @@ -17,9 +17,7 @@ @private */ export function canInvoke(obj, methodName) { - return ( - obj !== null && obj !== undefined && typeof obj[methodName] === 'function' - ); + return obj !== null && obj !== undefined && typeof obj[methodName] === 'function'; } /** diff --git a/packages/ember-utils/lib/name.js b/packages/ember-utils/lib/name.js index 76bc4ada048..802e088443a 100644 --- a/packages/ember-utils/lib/name.js +++ b/packages/ember-utils/lib/name.js @@ -1,11 +1,9 @@ const NAMES = new WeakMap(); export function setName(obj, name) { - if (obj !== null || typeof obj === 'object' || typeof obj === 'function') - NAMES.set(obj, name); + if (obj !== null || typeof obj === 'object' || typeof obj === 'function') NAMES.set(obj, name); } export function getName(obj) { - if (obj !== null || typeof obj === 'object' || typeof obj === 'function') - return NAMES.get(obj); + if (obj !== null || typeof obj === 'object' || typeof obj === 'function') return NAMES.get(obj); } diff --git a/packages/ember-utils/lib/spec.js b/packages/ember-utils/lib/spec.js index 5d7df523b3c..cf10ae1196b 100644 --- a/packages/ember-utils/lib/spec.js +++ b/packages/ember-utils/lib/spec.js @@ -10,7 +10,5 @@ @function isObject */ export function isObject(value) { - return ( - value !== null && (typeof value === 'object' || typeof value === 'function') - ); + return value !== null && (typeof value === 'object' || typeof value === 'function'); } diff --git a/packages/ember-utils/tests/assign_test.js b/packages/ember-utils/tests/assign_test.js index 31e19b85504..23f4b81376c 100644 --- a/packages/ember-utils/tests/assign_test.js +++ b/packages/ember-utils/tests/assign_test.js @@ -15,16 +15,8 @@ moduleFor( { a: 1, b: 2, c: 3 }, 'assign copies values from one or more source objects to a target object' ); - assert.deepEqual( - src1, - { b: 2 }, - 'assign does not change source object 1' - ); - assert.deepEqual( - src2, - { c: 3 }, - 'assign does not change source object 2' - ); + assert.deepEqual(src1, { b: 2 }, 'assign does not change source object 1'); + assert.deepEqual(src2, { c: 3 }, 'assign does not change source object 2'); } ['@test merging objects with same property'](assert) { @@ -51,11 +43,7 @@ moduleFor( let trgt = { a: 1 }; assign(trgt, null); - assert.deepEqual( - trgt, - { a: 1 }, - 'undefined as a source parameter is ignored' - ); + assert.deepEqual(trgt, { a: 1 }, 'undefined as a source parameter is ignored'); } } ); diff --git a/packages/ember-utils/tests/can_invoke_test.js b/packages/ember-utils/tests/can_invoke_test.js index f2b72f08681..995e459055b 100644 --- a/packages/ember-utils/tests/can_invoke_test.js +++ b/packages/ember-utils/tests/can_invoke_test.js @@ -11,7 +11,7 @@ moduleFor( obj = { foobar: 'foobar', - aMethodThatExists() {} + aMethodThatExists() {}, }; } @@ -33,9 +33,7 @@ moduleFor( assert.equal(canInvoke(obj, 'aMethodThatExists'), true); } - ["@test should return false if the method doesn't exist on the object"]( - assert - ) { + ["@test should return false if the method doesn't exist on the object"](assert) { assert.equal(canInvoke(obj, 'aMethodThatDoesNotExist'), false); } diff --git a/packages/ember-utils/tests/checkHasSuper_test.js b/packages/ember-utils/tests/checkHasSuper_test.js index 19a62f2639b..d15ffeeb20d 100644 --- a/packages/ember-utils/tests/checkHasSuper_test.js +++ b/packages/ember-utils/tests/checkHasSuper_test.js @@ -10,10 +10,7 @@ if (environment.isChrome || environment.isFirefox) { 'checkHasSuper', class extends TestCase { ['@test does not super wrap needlessly [GH #12462]'](assert) { - assert.notOk( - checkHasSuper(function() {}), - 'empty function does not have super' - ); + assert.notOk(checkHasSuper(function() {}), 'empty function does not have super'); } } ); diff --git a/packages/ember-utils/tests/generate_guid_test.js b/packages/ember-utils/tests/generate_guid_test.js index 298b095688a..2454fdb43da 100644 --- a/packages/ember-utils/tests/generate_guid_test.js +++ b/packages/ember-utils/tests/generate_guid_test.js @@ -7,10 +7,7 @@ moduleFor( ['@test Prefix'](assert) { let a = {}; - assert.ok( - generateGuid(a, 'tyrell').indexOf('tyrell') > -1, - 'guid can be prefixed' - ); + assert.ok(generateGuid(a, 'tyrell').indexOf('tyrell') > -1, 'guid can be prefixed'); } } ); diff --git a/packages/ember-utils/tests/guid_for_test.js b/packages/ember-utils/tests/guid_for_test.js index 0b8bb1a0de3..f38259f290b 100644 --- a/packages/ember-utils/tests/guid_for_test.js +++ b/packages/ember-utils/tests/guid_for_test.js @@ -11,10 +11,7 @@ function diffGuid(assert, a, b, message) { function nanGuid(assert, obj) { let type = typeof obj; - assert.ok( - isNaN(parseInt(guidFor(obj), 0)), - 'guids for ' + type + "don't parse to numbers" - ); + assert.ok(isNaN(parseInt(guidFor(obj), 0)), 'guids for ' + type + "don't parse to numbers"); } moduleFor( @@ -35,12 +32,7 @@ moduleFor( let b = 'String B'; sameGuid(assert, a, a, 'same string always yields same guid'); - sameGuid( - assert, - a, - aprime, - 'identical strings always yield the same guid' - ); + sameGuid(assert, a, aprime, 'identical strings always yield the same guid'); diffGuid(assert, a, b, 'different strings yield different guids'); nanGuid(assert, a); } @@ -51,12 +43,7 @@ moduleFor( let b = 34; sameGuid(assert, a, a, 'same numbers always yields same guid'); - sameGuid( - assert, - a, - aprime, - 'identical numbers always yield the same guid' - ); + sameGuid(assert, a, aprime, 'identical numbers always yield the same guid'); diffGuid(assert, a, b, 'different numbers yield different guids'); nanGuid(assert, a); } @@ -81,12 +68,7 @@ moduleFor( let b = false; sameGuid(assert, a, a, 'same booleans always yields same guid'); - sameGuid( - assert, - a, - aprime, - 'identical booleans always yield the same guid' - ); + sameGuid(assert, a, aprime, 'identical booleans always yield the same guid'); diffGuid(assert, a, b, 'different boolean yield different guids'); nanGuid(assert, a); nanGuid(assert, b); @@ -111,12 +93,7 @@ moduleFor( let b = ['1', '2', '3']; sameGuid(assert, a, a, 'same instance always yields same guid'); - diffGuid( - assert, - a, - aprime, - 'identical arrays always yield the same guid' - ); + diffGuid(assert, a, aprime, 'identical arrays always yield the same guid'); diffGuid(assert, a, b, 'different arrays yield different guids'); nanGuid(assert, a); } diff --git a/packages/ember-utils/tests/inspect_test.js b/packages/ember-utils/tests/inspect_test.js index 23bc970a5e0..af80c0f88e4 100644 --- a/packages/ember-utils/tests/inspect_test.js +++ b/packages/ember-utils/tests/inspect_test.js @@ -35,7 +35,7 @@ moduleFor( inspect({ foo() { return this; - } + }, }), '{foo: function() { ... }}' ); @@ -43,10 +43,7 @@ moduleFor( ['@test objects without a prototype'](assert) { let prototypelessObj = Object.create(null); - assert.equal( - inspect({ foo: prototypelessObj }), - '{foo: [object Object]}' - ); + assert.equal(inspect({ foo: prototypelessObj }), '{foo: [object Object]}'); } ['@test array'](assert) { @@ -59,10 +56,7 @@ moduleFor( ['@test date'](assert) { let inspected = inspect(new Date('Sat Apr 30 2011 13:24:11')); - assert.ok( - inspected.match(/Sat Apr 30/), - 'The inspected date has its date' - ); + assert.ok(inspected.match(/Sat Apr 30/), 'The inspected date has its date'); assert.ok(inspected.match(/2011/), 'The inspected date has its year'); assert.ok(inspected.match(/13:24:11/), 'The inspected date has its time'); } diff --git a/packages/ember-utils/tests/to-string-test.js b/packages/ember-utils/tests/to-string-test.js index 71bb6cdb38f..62222c65d38 100644 --- a/packages/ember-utils/tests/to-string-test.js +++ b/packages/ember-utils/tests/to-string-test.js @@ -8,7 +8,7 @@ moduleFor( let obj = { toString() { return 'bob'; - } + }, }; assert.strictEqual(toString(obj), 'bob'); diff --git a/packages/ember-utils/tests/try_invoke_test.js b/packages/ember-utils/tests/try_invoke_test.js index a4fc35967ca..0ae6f73f8c4 100644 --- a/packages/ember-utils/tests/try_invoke_test.js +++ b/packages/ember-utils/tests/try_invoke_test.js @@ -15,7 +15,7 @@ moduleFor( }, aMethodThatTakesArguments(arg1, arg2) { return arg1 === arg2; - } + }, }; } @@ -42,10 +42,7 @@ moduleFor( ['@test should return what the method returns when asked to perform a method that takes arguments and exists on the object']( assert ) { - assert.equal( - tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), - true - ); + assert.equal(tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true); } } ); diff --git a/packages/ember-views/lib/component_lookup.js b/packages/ember-views/lib/component_lookup.js index e6ed863e4a0..096879275ca 100644 --- a/packages/ember-views/lib/component_lookup.js +++ b/packages/ember-views/lib/component_lookup.js @@ -19,5 +19,5 @@ export default EmberObject.extend({ let templateFullName = `template:components/${name}`; return owner.lookup(templateFullName, options); - } + }, }); diff --git a/packages/ember-views/lib/index.js b/packages/ember-views/lib/index.js index dd84972a30a..ba32b39f8d6 100644 --- a/packages/ember-views/lib/index.js +++ b/packages/ember-views/lib/index.js @@ -10,7 +10,7 @@ export { getViewId, getViewElement, setViewElement, - constructStyleDeprecationMessage + constructStyleDeprecationMessage, } from './system/utils'; export { default as EventDispatcher } from './system/event_dispatcher'; export { default as ComponentLookup } from './component_lookup'; @@ -25,6 +25,4 @@ export { MUTABLE_CELL } from './compat/attrs'; export { default as lookupPartial, hasPartial } from './system/lookup_partial'; export { default as lookupComponent } from './utils/lookup-component'; export { default as ActionManager } from './system/action_manager'; -export { - default as fallbackViewRegistry -} from './compat/fallback-view-registry'; +export { default as fallbackViewRegistry } from './compat/fallback-view-registry'; diff --git a/packages/ember-views/lib/mixins/action_support.js b/packages/ember-views/lib/mixins/action_support.js index 686abe357d7..dd97f48e056 100644 --- a/packages/ember-views/lib/mixins/action_support.js +++ b/packages/ember-views/lib/mixins/action_support.js @@ -13,9 +13,7 @@ function validateAction(component, actionName) { assert( `The default action was triggered on the component ${component.toString()}, but the action name (${actionName}) was not a string.`, - isNone(actionName) || - typeof actionName === 'string' || - typeof actionName === 'function' + isNone(actionName) || typeof actionName === 'string' || typeof actionName === 'function' ); return actionName; } @@ -135,7 +133,7 @@ export default Mixin.create({ } else { this.triggerAction({ action: actionName, - actionContext: contexts + actionContext: contexts, }); } }, @@ -163,10 +161,7 @@ export default Mixin.create({ ); target.send(...arguments); } else { - assert( - `${inspect(this)} had no action handler for: ${actionName}`, - action - ); + assert(`${inspect(this)} had no action handler for: ${actionName}`, action); } - } + }, }); diff --git a/packages/ember-views/lib/mixins/child_views_support.js b/packages/ember-views/lib/mixins/child_views_support.js index 0f0b638af5b..9e38aa66009 100644 --- a/packages/ember-views/lib/mixins/child_views_support.js +++ b/packages/ember-views/lib/mixins/child_views_support.js @@ -18,10 +18,10 @@ export default Mixin.create({ enumerable: false, get() { return getChildViews(this); - } + }, }), appendChild(view) { addChildView(this, view); - } + }, }); diff --git a/packages/ember-views/lib/mixins/class_names_support.js b/packages/ember-views/lib/mixins/class_names_support.js index cae535e7b9e..011ee28949c 100644 --- a/packages/ember-views/lib/mixins/class_names_support.js +++ b/packages/ember-views/lib/mixins/class_names_support.js @@ -25,8 +25,7 @@ export default Mixin.create({ ); assert( `Only arrays of static class strings are allowed for 'classNames'. For dynamic classes, use 'classNameBindings'.`, - descriptorFor(this, 'classNames') === undefined && - Array.isArray(this.classNames) + descriptorFor(this, 'classNames') === undefined && Array.isArray(this.classNames) ); }, @@ -87,5 +86,5 @@ export default Mixin.create({ @default [] @public */ - classNameBindings: EMPTY_ARRAY + classNameBindings: EMPTY_ARRAY, }); diff --git a/packages/ember-views/lib/mixins/text_support.js b/packages/ember-views/lib/mixins/text_support.js index 2ce1c154552..78aacf315e2 100644 --- a/packages/ember-views/lib/mixins/text_support.js +++ b/packages/ember-views/lib/mixins/text_support.js @@ -7,7 +7,7 @@ import { TargetActionSupport } from 'ember-runtime'; const KEY_EVENTS = { 13: 'insertNewline', - 27: 'cancel' + 27: 'cancel', }; /** @@ -127,7 +127,7 @@ export default Mixin.create(TargetActionSupport, { 'selectionDirection', 'spellcheck', 'tabindex', - 'title' + 'title', ], placeholder: null, disabled: false, @@ -298,7 +298,7 @@ export default Mixin.create(TargetActionSupport, { */ keyDown(event) { this.sendAction('key-down', get(this, 'value'), event); - } + }, }); // In principle, this shouldn't be necessary, but the legacy diff --git a/packages/ember-views/lib/mixins/view_state_support.js b/packages/ember-views/lib/mixins/view_state_support.js index c5845d6e0f7..8de876bade3 100644 --- a/packages/ember-views/lib/mixins/view_state_support.js +++ b/packages/ember-views/lib/mixins/view_state_support.js @@ -15,5 +15,5 @@ export default Mixin.create({ if (currentState.enter) { currentState.enter(this); } - } + }, }); diff --git a/packages/ember-views/lib/mixins/view_support.js b/packages/ember-views/lib/mixins/view_support.js index 4e6997d84ff..5f94edb96e6 100644 --- a/packages/ember-views/lib/mixins/view_support.js +++ b/packages/ember-views/lib/mixins/view_support.js @@ -87,9 +87,7 @@ export default Mixin.create({ nearestOfType(klass) { let view = this.parentView; let isOfType = - klass instanceof Mixin - ? view => klass.detect(view) - : view => klass.detect(view.constructor); + klass instanceof Mixin ? view => klass.detect(view) : view => klass.detect(view.constructor); while (view) { if (isOfType(view)) { @@ -156,7 +154,7 @@ export default Mixin.create({ enumerable: false, get() { return this.renderer.getElement(this); - } + }, }), /** @@ -177,10 +175,7 @@ export default Mixin.create({ "You cannot access this.$() on a component with `tagName: ''` specified.", this.tagName !== '' ); - assert( - 'You cannot access this.$() with `jQuery` disabled.', - !jQueryDisabled - ); + assert('You cannot access this.$() with `jQuery` disabled.', !jQueryDisabled); if (this.element) { return sel ? jQuery(sel, this.element) : jQuery(this.element); } @@ -208,19 +203,10 @@ export default Mixin.create({ let target; if (env.hasDOM) { - target = - typeof selector === 'string' - ? document.querySelector(selector) - : selector; + target = typeof selector === 'string' ? document.querySelector(selector) : selector; - assert( - `You tried to append to (${selector}) but that isn't in the DOM`, - target - ); - assert( - 'You cannot append to an existing Ember.View.', - !matches(target, '.ember-view') - ); + assert(`You tried to append to (${selector}) but that isn't in the DOM`, target); + assert('You cannot append to an existing Ember.View.', !matches(target, '.ember-view')); assert( 'You cannot append to an existing Ember.View.', (() => { @@ -452,8 +438,7 @@ export default Mixin.create({ { id: 'ember-views.did-init-attrs', until: '3.0.0', - url: - 'https://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs' + url: 'https://emberjs.com/deprecations/v2.x#toc_ember-component-didinitattrs', } ); } else { @@ -463,10 +448,7 @@ export default Mixin.create({ ); } - assert( - 'Using a custom `.render` function is no longer supported.', - !this.render - ); + assert('Using a custom `.render` function is no longer supported.', !this.render); }, // ....................................................... @@ -483,5 +465,5 @@ export default Mixin.create({ */ handleEvent(eventName, evt) { return this._currentState.handleEvent(this, eventName, evt); - } + }, }); diff --git a/packages/ember-views/lib/system/event_dispatcher.js b/packages/ember-views/lib/system/event_dispatcher.js index 71a97d3b7de..94acce17e92 100644 --- a/packages/ember-views/lib/system/event_dispatcher.js +++ b/packages/ember-views/lib/system/event_dispatcher.js @@ -86,7 +86,7 @@ export default EmberObject.extend({ dragleave: 'dragLeave', dragover: 'dragOver', drop: 'drop', - dragend: 'dragEnd' + dragend: 'dragEnd', }, /** @@ -135,11 +135,7 @@ export default EmberObject.extend({ */ setup(addedEvents, _rootElement) { let event, rootElement; - let events = (this._finalEvents = assign( - {}, - get(this, 'events'), - addedEvents - )); + let events = (this._finalEvents = assign({}, get(this, 'events'), addedEvents)); if (!isNone(_rootElement)) { set(this, 'rootElement', _rootElement); @@ -206,10 +202,7 @@ export default EmberObject.extend({ rootElement.classList.add(ROOT_ELEMENT_CLASS); assert( - `Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${get( - this, - 'rootElement' - ) || + `Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${get(this, 'rootElement') || rootElement.tagName}). Make sure you set rootElement to the body or an element in the body.`, rootElement.classList.contains(ROOT_ELEMENT_CLASS) ); @@ -270,11 +263,7 @@ export default EmberObject.extend({ // We have to check for action here since in some cases, jQuery will trigger // an event on `removeChild` (i.e. focusout) after we've already torn down the // action handlers for the view. - if ( - action && - action.eventName === eventName && - handledActions.indexOf(action) === -1 - ) { + if (action && action.eventName === eventName && handledActions.indexOf(action) === -1) { action.handler(evt); // Action handlers can mutate state which in turn creates new attributes on the element. // This effect could cause the `data-ember-action` attribute to shift down and be invoked twice. @@ -315,9 +304,7 @@ export default EmberObject.extend({ let attrName = attr.name; if (attrName.indexOf('data-ember-action-') === 0) { - actions = actions.concat( - ActionManager.registeredActions[attr.value] - ); + actions = actions.concat(ActionManager.registeredActions[attr.value]); } } } @@ -364,8 +351,7 @@ export default EmberObject.extend({ _getViewRegistry() { let owner = getOwner(this); - let viewRegistry = - (owner && owner.lookup('-view-registry:main')) || fallbackViewRegistry; + let viewRegistry = (owner && owner.lookup('-view-registry:main')) || fallbackViewRegistry; return viewRegistry; }, @@ -398,5 +384,5 @@ export default EmberObject.extend({ toString() { return '(EventDispatcher)'; - } + }, }); diff --git a/packages/ember-views/lib/system/jquery.js b/packages/ember-views/lib/system/jquery.js index 843575f9905..86cc1541022 100644 --- a/packages/ember-views/lib/system/jquery.js +++ b/packages/ember-views/lib/system/jquery.js @@ -11,19 +11,13 @@ if (environment.hasDOM) { jQuery.event.addProp('dataTransfer'); } else { // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents - [ - 'dragstart', - 'drag', - 'dragenter', - 'dragleave', - 'dragover', - 'drop', - 'dragend' - ].forEach(eventName => { - jQuery.event.fixHooks[eventName] = { - props: ['dataTransfer'] - }; - }); + ['dragstart', 'drag', 'dragenter', 'dragleave', 'dragover', 'drop', 'dragend'].forEach( + eventName => { + jQuery.event.fixHooks[eventName] = { + props: ['dataTransfer'], + }; + } + ); } } else { jQueryDisabled = true; diff --git a/packages/ember-views/lib/system/lookup_partial.js b/packages/ember-views/lib/system/lookup_partial.js index 006854ae7bf..70041e7d7dd 100644 --- a/packages/ember-views/lib/system/lookup_partial.js +++ b/packages/ember-views/lib/system/lookup_partial.js @@ -14,11 +14,7 @@ export default function lookupPartial(templateName, owner) { return; } - let template = templateFor( - owner, - parseUnderscoredName(templateName), - templateName - ); + let template = templateFor(owner, parseUnderscoredName(templateName), templateName); assert(`Unable to find partial with name "${templateName}"`, !!template); @@ -44,10 +40,7 @@ function templateFor(owner, underscored, name) { if (!name) { return; } - assert( - `templateNames are not allowed to contain periods: ${name}`, - name.indexOf('.') === -1 - ); + assert(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1); if (!owner) { throw new EmberError( @@ -57,7 +50,5 @@ function templateFor(owner, underscored, name) { ); } - return ( - owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`) - ); + return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`); } diff --git a/packages/ember-views/lib/system/utils.js b/packages/ember-views/lib/system/utils.js index 26bf20d95e2..0ff06c43b22 100644 --- a/packages/ember-views/lib/system/utils.js +++ b/packages/ember-views/lib/system/utils.js @@ -6,8 +6,7 @@ import { guidFor, symbol, getOwner } from 'ember-utils'; */ export function isSimpleClick(event) { - let modifier = - event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; + let modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; let secondaryClick = event.which > 1; // IE9 may return undefined return !modifier && !secondaryClick; diff --git a/packages/ember-views/lib/utils/lookup-component.js b/packages/ember-views/lib/utils/lookup-component.js index eeb2a4ecce3..decba0b0a60 100644 --- a/packages/ember-views/lib/utils/lookup-component.js +++ b/packages/ember-views/lib/utils/lookup-component.js @@ -2,12 +2,7 @@ import { privatize as P } from 'container'; import { ENV } from 'ember-environment'; import { EMBER_MODULE_UNIFICATION } from 'ember/features'; -function lookupModuleUnificationComponentPair( - componentLookup, - owner, - name, - options -) { +function lookupModuleUnificationComponentPair(componentLookup, owner, name, options) { let localComponent = componentLookup.componentFor(name, owner, options); let localLayout = componentLookup.layoutFor(name, owner, options); @@ -15,12 +10,10 @@ function lookupModuleUnificationComponentPair( let globalLayout = componentLookup.layoutFor(name, owner); let localAndUniqueComponent = - !!localComponent && - (!globalComponent || localComponent.class !== globalComponent.class); + !!localComponent && (!globalComponent || localComponent.class !== globalComponent.class); let localAndUniqueLayout = !!localLayout && - (!globalLayout || - localLayout.referrer.moduleName !== globalLayout.referrer.moduleName); + (!globalLayout || localLayout.referrer.moduleName !== globalLayout.referrer.moduleName); if (localAndUniqueComponent && localAndUniqueLayout) { return { layout: localLayout, component: localComponent }; @@ -46,12 +39,7 @@ function lookupModuleUnificationComponentPair( function lookupComponentPair(componentLookup, owner, name, options) { if (EMBER_MODULE_UNIFICATION) { - return lookupModuleUnificationComponentPair( - componentLookup, - owner, - name, - options - ); + return lookupModuleUnificationComponentPair(componentLookup, owner, name, options); } let component = componentLookup.componentFor(name, owner, options); @@ -70,12 +58,7 @@ export default function lookupComponent(owner, name, options) { let componentLookup = owner.lookup('component-lookup:main'); if (options && (options.source || options.namespace)) { - let localResult = lookupComponentPair( - componentLookup, - owner, - name, - options - ); + let localResult = lookupComponentPair(componentLookup, owner, name, options); if (localResult.component || localResult.layout) { return localResult; diff --git a/packages/ember-views/lib/views/core_view.js b/packages/ember-views/lib/views/core_view.js index 4b34298aead..a38b94bdf5c 100644 --- a/packages/ember-views/lib/views/core_view.js +++ b/packages/ember-views/lib/views/core_view.js @@ -73,11 +73,11 @@ const CoreView = FrameworkObject.extend(Evented, ActionHandler, { has(name) { return typeof this[name] === 'function' || this._super(name); - } + }, }); CoreView.reopenClass({ - isViewFactory: true + isViewFactory: true, }); export default CoreView; diff --git a/packages/ember-views/lib/views/states.js b/packages/ember-views/lib/views/states.js index b057c768425..37bdf262aee 100644 --- a/packages/ember-views/lib/views/states.js +++ b/packages/ember-views/lib/views/states.js @@ -44,5 +44,5 @@ export let states = { preRender, inDOM, hasElement, - destroying + destroying, }; diff --git a/packages/ember-views/lib/views/states/default.js b/packages/ember-views/lib/views/states/default.js index ee5c979a61a..46a36faf448 100644 --- a/packages/ember-views/lib/views/states/default.js +++ b/packages/ember-views/lib/views/states/default.js @@ -3,9 +3,7 @@ import { Error as EmberError } from 'ember-debug'; export default { // appendChild is only legal while rendering the buffer. appendChild() { - throw new EmberError( - "You can't use appendChild outside of the rendering process" - ); + throw new EmberError("You can't use appendChild outside of the rendering process"); }, // Handle events from `Ember.EventDispatcher` @@ -15,5 +13,5 @@ export default { rerender() {}, - destroy() {} + destroy() {}, }; diff --git a/packages/ember-views/lib/views/states/destroying.js b/packages/ember-views/lib/views/states/destroying.js index d67b5925a72..6d8a7ff28df 100644 --- a/packages/ember-views/lib/views/states/destroying.js +++ b/packages/ember-views/lib/views/states/destroying.js @@ -6,13 +6,11 @@ const destroying = Object.create(_default); assign(destroying, { appendChild() { - throw new EmberError( - "You can't call appendChild on a view being destroyed" - ); + throw new EmberError("You can't call appendChild on a view being destroyed"); }, rerender() { throw new EmberError("You can't call rerender on a view being destroyed"); - } + }, }); export default destroying; diff --git a/packages/ember-views/lib/views/states/has_element.js b/packages/ember-views/lib/views/states/has_element.js index 0738b6b3b1e..651f3ede348 100644 --- a/packages/ember-views/lib/views/states/has_element.js +++ b/packages/ember-views/lib/views/states/has_element.js @@ -18,17 +18,13 @@ assign(hasElement, { if (view.has(eventName)) { // Handler should be able to re-dispatch events, so we don't // preventDefault or stopPropagation. - return flaggedInstrument( - `interaction.${eventName}`, - { event, view }, - () => { - return join(view, view.trigger, eventName, event); - } - ); + return flaggedInstrument(`interaction.${eventName}`, { event, view }, () => { + return join(view, view.trigger, eventName, event); + }); } else { return true; // continue event propagation } - } + }, }); export default hasElement; diff --git a/packages/ember-views/lib/views/states/in_dom.js b/packages/ember-views/lib/views/states/in_dom.js index 256f3d45c41..f38871ebccc 100644 --- a/packages/ember-views/lib/views/states/in_dom.js +++ b/packages/ember-views/lib/views/states/in_dom.js @@ -15,16 +15,14 @@ assign(inDOM, { if (DEBUG) { addObserver(view, 'elementId', () => { - throw new EmberError( - "Changing a view's elementId after creation is not allowed" - ); + throw new EmberError("Changing a view's elementId after creation is not allowed"); }); } }, exit(view) { view.renderer.unregister(view); - } + }, }); export default inDOM; diff --git a/packages/ember/lib/index.js b/packages/ember/lib/index.js index d44c4968dcd..5f7a59db3d5 100644 --- a/packages/ember/lib/index.js +++ b/packages/ember/lib/index.js @@ -53,7 +53,7 @@ Ember.runInDebug = EmberDebug.runInDebug; */ Ember.Debug = { registerDeprecationHandler: EmberDebug.registerDeprecationHandler, - registerWarnHandler: EmberDebug.registerWarnHandler + registerWarnHandler: EmberDebug.registerWarnHandler, }; Ember.merge = metal.merge; @@ -63,7 +63,7 @@ Ember.Instrumentation = { instrument: metal.instrument, subscribe: metal.instrumentationSubscribe, unsubscribe: metal.instrumentationUnsubscribe, - reset: metal.instrumentationReset + reset: metal.instrumentationReset, }; Ember.Error = EmberDebug.Error; @@ -106,7 +106,7 @@ Ember.run.scheduleOnce = metal.scheduleOnce; Ember.run.throttle = metal.throttle; Object.defineProperty(Ember.run, 'currentRunLoop', { get: metal.getCurrentRunLoop, - enumerable: false + enumerable: false, }); Ember.propertyWillChange = metal.propertyWillChange; Ember.propertyDidChange = metal.propertyDidChange; @@ -117,7 +117,7 @@ Ember.endPropertyChanges = metal.endPropertyChanges; Ember.changeProperties = metal.changeProperties; Ember.platform = { defineProperty: true, - hasPropertyAccessors: true + hasPropertyAccessors: true, }; Ember.defineProperty = metal.defineProperty; Ember.watchKey = metal.watchKey; @@ -153,7 +153,7 @@ Object.defineProperty(Ember, 'ENV', { get() { return ENV; }, - enumerable: false + enumerable: false, }); /** @@ -168,7 +168,7 @@ Object.defineProperty(Ember, 'lookup', { set(value) { context.lookup = value; }, - enumerable: false + enumerable: false, }); Ember.EXTEND_PROTOTYPES = ENV.EXTEND_PROTOTYPES; @@ -181,7 +181,7 @@ Object.defineProperty(Ember, 'LOG_STACKTRACE_ON_DEPRECATION', { set(value) { ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; }, - enumerable: false + enumerable: false, }); Object.defineProperty(Ember, 'LOG_VERSION', { @@ -191,7 +191,7 @@ Object.defineProperty(Ember, 'LOG_VERSION', { set(value) { ENV.LOG_VERSION = !!value; }, - enumerable: false + enumerable: false, }); if (DEBUG) { @@ -203,11 +203,10 @@ if (DEBUG) { deprecate('Ember.MODEL_FACTORY_INJECTIONS is no longer required', false, { id: 'ember-metal.model_factory_injections', until: '2.17.0', - url: - 'https://emberjs.com/deprecations/v2.x/#toc_id-ember-metal-model_factory_injections' + url: 'https://emberjs.com/deprecations/v2.x/#toc_id-ember-metal-model_factory_injections', }); }, - enumerable: false + enumerable: false, }); } @@ -218,7 +217,7 @@ Object.defineProperty(Ember, 'LOG_BINDINGS', { set(value) { ENV.LOG_BINDINGS = !!value; }, - enumerable: false + enumerable: false, }); /** @@ -247,13 +246,13 @@ Object.defineProperty(Ember, 'LOG_BINDINGS', { Object.defineProperty(Ember, 'onerror', { get: metal.getOnerror, set: metal.setOnerror, - enumerable: false + enumerable: false, }); Object.defineProperty(Ember, 'testing', { get: EmberDebug.isTesting, set: EmberDebug.setTesting, - enumerable: false + enumerable: false, }); import Backburner from 'backburner'; @@ -336,7 +335,7 @@ import { uniqBy, union, intersect, - collect + collect, } from 'ember-runtime'; Ember.A = A; @@ -423,7 +422,7 @@ computed.collect = collect; Object.defineProperty(Ember, 'STRINGS', { configurable: false, get: getStrings, - set: setStrings + set: setStrings, }); /** @@ -444,7 +443,7 @@ Object.defineProperty(Ember, 'BOOTED', { configurable: false, enumerable: false, get: metal.isNamespaceSearchDisabled, - set: metal.setNamespaceSearchDisabled + set: metal.setNamespaceSearchDisabled, }); import { @@ -462,7 +461,7 @@ import { template, TextField, TextArea, - isSerializationFirstNode + isSerializationFirstNode, } from 'ember-glimmer'; Ember.Component = Component; @@ -477,7 +476,7 @@ Object.defineProperty(Ember, '_setComponentManager', { enumerable: false, get() { return componentManager; - } + }, }); if (ENV.EXTEND_PROTOTYPES.String) { @@ -488,8 +487,7 @@ if (ENV.EXTEND_PROTOTYPES.String) { let EmberHandlebars = (Ember.Handlebars = Ember.Handlebars || {}); let EmberHTMLBars = (Ember.HTMLBars = Ember.HTMLBars || {}); -let EmberHandleBarsUtils = (EmberHandlebars.Utils = - EmberHandlebars.Utils || {}); +let EmberHandleBarsUtils = (EmberHandlebars.Utils = EmberHandlebars.Utils || {}); EmberHTMLBars.template = EmberHandlebars.template = template; EmberHandleBarsUtils.escapeExpression = escapeExpression; @@ -511,7 +509,7 @@ Object.defineProperty(Ember, 'TEMPLATES', { get: getTemplates, set: setTemplates, configurable: false, - enumerable: false + enumerable: false, }); import VERSION from './version'; @@ -542,7 +540,7 @@ Ember.ViewUtils = { getViewBoundingClientRect: views.getViewBoundingClientRect, getRootViews: views.getRootViews, getChildViews: views.getChildViews, - isSerializationFirstNode: isSerializationFirstNode + isSerializationFirstNode: isSerializationFirstNode, }; Ember.TextSupport = views.TextSupport; diff --git a/packages/ember/tests/application_lifecycle_test.js b/packages/ember/tests/application_lifecycle_test.js index 257c880daa7..4fa1d0e24cc 100644 --- a/packages/ember/tests/application_lifecycle_test.js +++ b/packages/ember/tests/application_lifecycle_test.js @@ -15,7 +15,7 @@ moduleFor( this.add( 'router:main', Router.extend({ - location: 'none' + location: 'none', }) ); return application; @@ -35,7 +35,7 @@ moduleFor( }, deactivate() { this.controller.set('selectedMenuItem', null); - } + }, }); this.add('route:index', SettingRoute); this.add('route:application', SettingRoute); @@ -59,10 +59,7 @@ moduleFor( ) { let { indexController, applicationController } = this; assert.equal(indexController.get('selectedMenuItem'), this.menuItem); - assert.equal( - applicationController.get('selectedMenuItem'), - this.menuItem - ); + assert.equal(applicationController.get('selectedMenuItem'), this.menuItem); this.application.reset(); @@ -75,10 +72,7 @@ moduleFor( ) { let { indexController, applicationController } = this; assert.equal(indexController.get('selectedMenuItem'), this.menuItem); - assert.equal( - applicationController.get('selectedMenuItem'), - this.menuItem - ); + assert.equal(applicationController.get('selectedMenuItem'), this.menuItem); this.runTask(() => { this.application.destroy(); @@ -98,7 +92,7 @@ moduleFor( this.add( 'router:main', Router.extend({ - location: 'none' + location: 'none', }) ); return application; @@ -120,23 +114,13 @@ moduleFor( assert.equal(router._toplevelView, null, 'the toplevelView was cleared'); this.runTask(() => route.destroy()); - assert.equal( - router._toplevelView, - null, - 'the toplevelView was not reinitialized' - ); + assert.equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); this.runTask(() => this.application.destroy()); - assert.equal( - router._toplevelView, - null, - 'the toplevelView was not reinitialized' - ); + assert.equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); } - [`@test initializers can augment an applications customEvents hash`]( - assert - ) { + [`@test initializers can augment an applications customEvents hash`](assert) { assert.expect(1); let MyApplication = Application.extend(); @@ -145,9 +129,9 @@ moduleFor( name: 'customize-things', initialize(application) { application.customEvents = { - wowza: 'wowza' + wowza: 'wowza', }; - } + }, }); this.runTask(() => { @@ -158,7 +142,7 @@ moduleFor( Component.extend({ wowza() { assert.ok(true, 'fired the event!'); - } + }, }) ); @@ -169,9 +153,7 @@ moduleFor( this.$('#wowza-thingy').trigger('wowza'); } - [`@test instanceInitializers can augment an the customEvents hash`]( - assert - ) { + [`@test instanceInitializers can augment an the customEvents hash`](assert) { assert.expect(1); let MyApplication = Application.extend(); @@ -180,9 +162,9 @@ moduleFor( name: 'customize-things', initialize(application) { application.customEvents = { - herky: 'jerky' + herky: 'jerky', }; - } + }, }); this.runTask(() => { this.createApplication({}, MyApplication); @@ -192,7 +174,7 @@ moduleFor( Component.extend({ jerky() { assert.ok(true, 'fired the event!'); - } + }, }) ); diff --git a/packages/ember/tests/component_context_test.js b/packages/ember/tests/component_context_test.js index fd4aa79b75f..7809d384061 100644 --- a/packages/ember/tests/component_context_test.js +++ b/packages/ember/tests/component_context_test.js @@ -1,10 +1,6 @@ import { Controller } from 'ember-runtime'; import { Component } from 'ember-glimmer'; -import { - moduleFor, - ApplicationTestCase, - getTextOf -} from 'internal-test-helpers'; +import { moduleFor, ApplicationTestCase, getTextOf } from 'internal-test-helpers'; moduleFor( 'Application Lifecycle - Component Context', @@ -24,23 +20,19 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ - text: 'inner' + text: 'inner', }), - template: `{{text}}-{{yield}}` + template: `{{text}}-{{yield}}`, }); return this.visit('/').then(() => { let text = getTextOf(this.element.querySelector('#wrapper')); - assert.equal( - text, - 'inner-outer', - 'The component is composed correctly' - ); + assert.equal(text, 'inner-outer', 'The component is composed correctly'); }); } @@ -59,13 +51,13 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ - text: 'inner' - }) + text: 'inner', + }), }); return this.visit('/').then(() => { @@ -86,14 +78,14 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ - text: 'inner' + text: 'inner', }), - template: '{{text}}' + template: '{{text}}', }); return this.visit('/').then(() => { @@ -102,9 +94,7 @@ moduleFor( }); } - ['@test Components without a block should have the proper content']( - assert - ) { + ['@test Components without a block should have the proper content'](assert) { this.addTemplate( 'application', ` @@ -115,24 +105,20 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ didInsertElement() { this.element.innerHTML = 'Some text inserted'; - } - }) + }, + }), }); return this.visit('/').then(() => { let text = getTextOf(this.element.querySelector('#wrapper')); - assert.equal( - text, - 'Some text inserted', - 'The component is composed correctly' - ); + assert.equal(text, 'Some text inserted', 'The component is composed correctly'); }); } @@ -149,24 +135,20 @@ moduleFor( 'controller:application', Controller.extend({ text: 'outer', - foo: 'Some text inserted' + foo: 'Some text inserted', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ didInsertElement() { this.element.innerHTML = this.get('data'); - } - }) + }, + }), }); return this.visit('/').then(() => { let text = getTextOf(this.element.querySelector('#wrapper')); - assert.equal( - text, - 'Some text inserted', - 'The component is composed correctly' - ); + assert.equal(text, 'Some text inserted', 'The component is composed correctly'); }); } @@ -184,24 +166,20 @@ moduleFor( 'controller:application', Controller.extend({ text: 'outer', - foo: 'Some text inserted' + foo: 'Some text inserted', }) ); this.addComponent('my-component', { ComponentClass: Component.extend({ didInsertElement() { this.element.innerHTML = this.get('attrs.attrs.value'); - } - }) + }, + }), }); return this.visit('/').then(() => { let text = getTextOf(this.element.querySelector('#wrapper')); - assert.equal( - text, - 'Some text inserted', - 'The component is composed correctly' - ); + assert.equal(text, 'Some text inserted', 'The component is composed correctly'); }); } @@ -225,12 +203,12 @@ moduleFor( actions: { fizzbuzz() { assert.ok(true, 'action triggered on parent'); - } - } + }, + }, }) ); this.addComponent('my-component', { - ComponentClass: Component.extend({}) + ComponentClass: Component.extend({}), }); return this.visit('/').then(() => { @@ -254,8 +232,8 @@ moduleFor( actions: { fizzbuzz() { assert.ok(false, 'action on the wrong context'); - } - } + }, + }, }) ); this.addComponent('my-component', { @@ -263,10 +241,10 @@ moduleFor( actions: { fizzbuzz() { assert.ok(true, 'action triggered on component'); - } - } + }, + }, }), - template: `Fizzbuzz` + template: `Fizzbuzz`, }); return this.visit('/').then(() => { diff --git a/packages/ember/tests/component_registration_test.js b/packages/ember/tests/component_registration_test.js index 792b398ecf1..1676f55fc1e 100644 --- a/packages/ember/tests/component_registration_test.js +++ b/packages/ember/tests/component_registration_test.js @@ -14,26 +14,20 @@ moduleFor( ['@feature(!ember-glimmer-template-only-components) The helper becomes the body of the component']() { this.addTemplate('components/expand-it', '

hello {{yield}}

'); - this.addTemplate( - 'application', - 'Hello world {{#expand-it}}world{{/expand-it}}' - ); + this.addTemplate('application', 'Hello world {{#expand-it}}world{{/expand-it}}'); return this.visit('/').then(() => { this.assertText('Hello world hello world'); this.assertComponentElement(this.element.firstElementChild, { tagName: 'div', - content: '

hello world

' + content: '

hello world

', }); }); } ['@feature(ember-glimmer-template-only-components) The helper becomes the body of the component']() { this.addTemplate('components/expand-it', '

hello {{yield}}

'); - this.addTemplate( - 'application', - 'Hello world {{#expand-it}}world{{/expand-it}}' - ); + this.addTemplate('application', 'Hello world {{#expand-it}}world{{/expand-it}}'); return this.visit('/').then(() => { this.assertInnerHTML('Hello world

hello world

'); @@ -42,10 +36,7 @@ moduleFor( ['@test If a component is registered, it is used'](assert) { this.addTemplate('components/expand-it', '

hello {{yield}}

'); - this.addTemplate( - 'application', - `Hello world {{#expand-it}}world{{/expand-it}}` - ); + this.addTemplate('application', `Hello world {{#expand-it}}world{{/expand-it}}`); this.application.instanceInitializer({ name: 'expand-it-component', @@ -53,31 +44,22 @@ moduleFor( applicationInstance.register( 'component:expand-it', Component.extend({ - classNames: 'testing123' + classNames: 'testing123', }) ); - } + }, }); return this.visit('/').then(() => { let text = this.$('div.testing123') .text() .trim(); - assert.equal( - text, - 'hello world', - 'The component is composed correctly' - ); + assert.equal(text, 'hello world', 'The component is composed correctly'); }); } - ['@test Late-registered components can be rendered with custom `layout` property']( - assert - ) { - this.addTemplate( - 'application', - `
there goes {{my-hero}}
` - ); + ['@test Late-registered components can be rendered with custom `layout` property'](assert) { + this.addTemplate('application', `
there goes {{my-hero}}
`); this.application.instanceInitializer({ name: 'my-hero-component', @@ -86,10 +68,10 @@ moduleFor( 'component:my-hero', Component.extend({ classNames: 'testing123', - layout: compile('watch him as he GOES') + layout: compile('watch him as he GOES'), }) ); - } + }, }); return this.visit('/').then(() => { @@ -119,13 +101,13 @@ moduleFor( 'template:components/sally-rutherford', compile('funkytowny{{yield}}') ); - } + }, }); this.application.instanceInitializer({ name: 'sally-rutherford-component', initialize(applicationInstance) { applicationInstance.register('component:sally-rutherford', Component); - } + }, }); return this.visit('/').then(() => { @@ -155,7 +137,7 @@ moduleFor( 'template:components/borf-snorlax', compile('goodfreakingTIMES{{yield}}') ); - } + }, }); return this.visit('/').then(() => { @@ -170,9 +152,7 @@ moduleFor( }); } - ['@test Assigning layoutName to a component should setup the template as a layout']( - assert - ) { + ['@test Assigning layoutName to a component should setup the template as a layout'](assert) { assert.expect(1); this.addTemplate( @@ -187,10 +167,10 @@ moduleFor( applicationInstance.register( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); - } + }, }); this.application.instanceInitializer({ name: 'my-component-component', @@ -199,27 +179,21 @@ moduleFor( 'component:my-component', Component.extend({ text: 'inner', - layoutName: 'foo-bar-baz' + layoutName: 'foo-bar-baz', }) ); - } + }, }); return this.visit('/').then(() => { let text = this.$('#wrapper') .text() .trim(); - assert.equal( - text, - 'inner-outer', - 'The component is composed correctly' - ); + assert.equal(text, 'inner-outer', 'The component is composed correctly'); }); } - ['@test Assigning layoutName and layout to a component should use the `layout` value']( - assert - ) { + ['@test Assigning layoutName and layout to a component should use the `layout` value'](assert) { assert.expect(1); this.addTemplate( @@ -234,10 +208,10 @@ moduleFor( applicationInstance.register( 'controller:application', Controller.extend({ - text: 'outer' + text: 'outer', }) ); - } + }, }); this.application.instanceInitializer({ name: 'my-component-component-layout', @@ -247,29 +221,22 @@ moduleFor( Component.extend({ text: 'inner', layoutName: 'foo-bar-baz', - layout: compile('{{text}}-{{yield}}') + layout: compile('{{text}}-{{yield}}'), }) ); - } + }, }); return this.visit('/').then(() => { let text = this.$('#wrapper') .text() .trim(); - assert.equal( - text, - 'inner-outer', - 'The component is composed correctly' - ); + assert.equal(text, 'inner-outer', 'The component is composed correctly'); }); } ['@test Using name of component that does not exist']() { - this.addTemplate( - 'application', - `
{{#no-good}} {{/no-good}}
` - ); + this.addTemplate('application', `
{{#no-good}} {{/no-good}}
`); // TODO: Use the async form of expectAssertion here when it is available expectAssertion(() => { diff --git a/packages/ember/tests/controller_test.js b/packages/ember/tests/controller_test.js index 3fb3a00b824..492cfeb9b73 100644 --- a/packages/ember/tests/controller_test.js +++ b/packages/ember/tests/controller_test.js @@ -20,8 +20,8 @@ moduleFor( actions: { componentAction() { assert.ok(true, 'controller received the action'); - } - } + }, + }, }) ); @@ -30,14 +30,11 @@ moduleFor( classNames: ['component-with-action'], click() { this.sendAction(); - } - }) + }, + }), }); - this.addTemplate( - 'index', - '{{component-with-action action="componentAction"}}' - ); + this.addTemplate('index', '{{component-with-action action="componentAction"}}'); return this.visit('/').then(() => { this.runTask(() => this.$('.component-with-action').click()); diff --git a/packages/ember/tests/error_handler_test.js b/packages/ember/tests/error_handler_test.js index 912a6fdfdf4..1a9e3e5c5ac 100644 --- a/packages/ember/tests/error_handler_test.js +++ b/packages/ember/tests/error_handler_test.js @@ -16,7 +16,7 @@ QUnit.module('error_handler', { window.onerror = WINDOW_ONERROR; setOnerror(undefined); - } + }, }); function runThatThrowsSync(message = 'Error for testing error handling') { @@ -34,29 +34,25 @@ QUnit.test('by default there is no onerror - sync run', function(assert) { assert.throws(runThatThrowsSync, Error, 'errors thrown sync are catchable'); }); -QUnit.test( - 'when Ember.onerror (which rethrows) is registered - sync run', - function(assert) { - assert.expect(2); - setOnerror(function(error) { - assert.ok(true, 'onerror called'); - throw error; - }); - assert.throws(runThatThrowsSync, Error, 'error is thrown'); - } -); +QUnit.test('when Ember.onerror (which rethrows) is registered - sync run', function(assert) { + assert.expect(2); + setOnerror(function(error) { + assert.ok(true, 'onerror called'); + throw error; + }); + assert.throws(runThatThrowsSync, Error, 'error is thrown'); +}); -QUnit.test( - 'when Ember.onerror (which does not rethrow) is registered - sync run', - function(assert) { - assert.expect(2); - setOnerror(function() { - assert.ok(true, 'onerror called'); - }); - runThatThrowsSync(); - assert.ok(true, 'no error was thrown, Ember.onerror can intercept errors'); - } -); +QUnit.test('when Ember.onerror (which does not rethrow) is registered - sync run', function( + assert +) { + assert.expect(2); + setOnerror(function() { + assert.ok(true, 'onerror called'); + }); + runThatThrowsSync(); + assert.ok(true, 'no error was thrown, Ember.onerror can intercept errors'); +}); QUnit.test( 'does not swallow exceptions by default (Ember.testing = true, no Ember.onerror) - sync run', @@ -153,7 +149,7 @@ QUnit.test( actual: caughtByWindowOnerror, expected: 'to include `the error`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); done(); @@ -185,7 +181,7 @@ QUnit.test( actual: caughtByWindowOnerror, expected: 'to include `the error`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); done(); @@ -211,11 +207,7 @@ QUnit.test( let thrown = new Error('the error'); setOnerror(function(error) { - assert.strictEqual( - error, - thrown, - 'Ember.onerror is called with the error' - ); + assert.strictEqual(error, thrown, 'Ember.onerror is called with the error'); }); later(() => { @@ -226,68 +218,62 @@ QUnit.test( } ); -function generateRSVPErrorHandlingTests( - message, - generatePromise, - timeout = 10 -) { - QUnit.test( - `${message} when Ember.onerror which does not rethrow is present - rsvp`, - function(assert) { - assert.expect(1); +function generateRSVPErrorHandlingTests(message, generatePromise, timeout = 10) { + QUnit.test(`${message} when Ember.onerror which does not rethrow is present - rsvp`, function( + assert + ) { + assert.expect(1); - let thrown = new Error('the error'); - setOnerror(function(error) { - assert.strictEqual( - error, - thrown, - 'Ember.onerror is called for errors thrown in RSVP promises' - ); - }); + let thrown = new Error('the error'); + setOnerror(function(error) { + assert.strictEqual( + error, + thrown, + 'Ember.onerror is called for errors thrown in RSVP promises' + ); + }); - generatePromise(thrown); + generatePromise(thrown); - // RSVP.Promise's are configured to settle within the run loop, this - // ensures that run loop has completed - return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); - } - ); + // RSVP.Promise's are configured to settle within the run loop, this + // ensures that run loop has completed + return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); + }); - QUnit.test( - `${message} when Ember.onerror which does rethrow is present - rsvp`, - function(assert) { - assert.expect(2); + QUnit.test(`${message} when Ember.onerror which does rethrow is present - rsvp`, function( + assert + ) { + assert.expect(2); - let thrown = new Error('the error'); - setOnerror(function(error) { - assert.strictEqual( - error, - thrown, - 'Ember.onerror is called for errors thrown in RSVP promises' - ); - throw error; - }); + let thrown = new Error('the error'); + setOnerror(function(error) { + assert.strictEqual( + error, + thrown, + 'Ember.onerror is called for errors thrown in RSVP promises' + ); + throw error; + }); - window.onerror = function(message) { - assert.pushResult({ - result: /the error/.test(message), - actual: message, - expected: 'to include `the error`', - message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' - }); + window.onerror = function(message) { + assert.pushResult({ + result: /the error/.test(message), + actual: message, + expected: 'to include `the error`', + message: + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', + }); - // prevent "bubbling" and therefore failing the test - return true; - }; + // prevent "bubbling" and therefore failing the test + return true; + }; - generatePromise(thrown); + generatePromise(thrown); - // RSVP.Promise's are configured to settle within the run loop, this - // ensures that run loop has completed - return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); - } - ); + // RSVP.Promise's are configured to settle within the run loop, this + // ensures that run loop has completed + return new RSVP.Promise(resolve => setTimeout(resolve, timeout)); + }); QUnit.test( `${message} when Ember.onerror which does not rethrow is present (Ember.testing = false) - rsvp`, @@ -334,7 +320,7 @@ function generateRSVPErrorHandlingTests( actual: message, expected: 'to include `the error`', message: - 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)' + 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)', }); // prevent "bubbling" and therefore failing the test diff --git a/packages/ember/tests/helpers/helper_registration_test.js b/packages/ember/tests/helpers/helper_registration_test.js index b0c8b483765..8ef900b71c4 100644 --- a/packages/ember/tests/helpers/helper_registration_test.js +++ b/packages/ember/tests/helpers/helper_registration_test.js @@ -5,13 +5,8 @@ import { Helper, helper } from 'ember-glimmer'; moduleFor( 'Application Lifecycle - Helper Registration', class extends ApplicationTestCase { - ['@test Unbound dashed helpers registered on the container can be late-invoked']( - assert - ) { - this.addTemplate( - 'application', - `
{{x-borf}} {{x-borf 'YES'}}
` - ); + ['@test Unbound dashed helpers registered on the container can be late-invoked'](assert) { + this.addTemplate('application', `
{{x-borf}} {{x-borf 'YES'}}
`); let myHelper = helper(params => params[0] || 'BORF'); this.application.register('helper:x-borf', myHelper); @@ -25,18 +20,13 @@ moduleFor( }); } - ['@test Bound helpers registered on the container can be late-invoked']( - assert - ) { - this.addTemplate( - 'application', - `
{{x-reverse}} {{x-reverse foo}}
` - ); + ['@test Bound helpers registered on the container can be late-invoked'](assert) { + this.addTemplate('application', `
{{x-reverse}} {{x-reverse foo}}
`); this.add( 'controller:application', Controller.extend({ - foo: 'alex' + foo: 'alex', }) ); @@ -61,9 +51,7 @@ moduleFor( }); } - ['@test Undashed helpers registered on the container can be invoked']( - assert - ) { + ['@test Undashed helpers registered on the container can be invoked'](assert) { this.addTemplate( 'application', `
{{omg}}|{{yorp 'boo'}}|{{yorp 'ya'}}
` @@ -92,7 +80,7 @@ moduleFor( Service.extend({ build() { serviceCalled = true; - } + }, }) ); @@ -102,7 +90,7 @@ moduleFor( nameBuilder: inject.service('name-builder'), compute() { this.get('nameBuilder').build(); - } + }, }) ); diff --git a/packages/ember/tests/helpers/link_to_test.js b/packages/ember/tests/helpers/link_to_test.js index 0332769d12c..8661c03f571 100644 --- a/packages/ember/tests/helpers/link_to_test.js +++ b/packages/ember/tests/helpers/link_to_test.js @@ -4,7 +4,7 @@ import { Controller, inject, A as emberA } from 'ember-runtime'; import { instrumentationSubscribe as subscribe, instrumentationReset as reset, - alias + alias, } from 'ember-metal'; import { Route, NoneLocation } from 'ember-routing'; import { EMBER_IMPROVED_INSTRUMENTATION } from 'ember/features'; @@ -24,11 +24,7 @@ function shouldBeActive(assert, element) { function checkActive(assert, element, active) { let classList = element.attr('class'); - assert.equal( - classList.indexOf('active') > -1, - active, - `${element} active should be ${active}` - ); + assert.equal(classList.indexOf('active') > -1, active, `${element} active should be ${active}`); } moduleFor( @@ -62,11 +58,7 @@ moduleFor( ['@test The {{link-to}} helper moves into the named route'](assert) { return this.visit('/') .then(() => { - assert.equal( - this.$('h3.home').length, - 1, - 'The home template was rendered' - ); + assert.equal(this.$('h3.home').length, 1, 'The home template was rendered'); assert.equal( this.$('#self-link.active').length, 1, @@ -81,11 +73,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.$('h3.about').length, - 1, - 'The about template was rendered' - ); + assert.equal(this.$('h3.about').length, 1, 'The about template was rendered'); assert.equal( this.$('#self-link.active').length, 1, @@ -99,9 +87,7 @@ moduleFor( }); } - [`@test the {{link-to}} helper doesn't add an href when the tagName isn't 'a'`]( - assert - ) { + [`@test the {{link-to}} helper doesn't add an href when the tagName isn't 'a'`](assert) { this.addTemplate( 'index', ` @@ -110,11 +96,7 @@ moduleFor( ); return this.visit('/').then(() => { - assert.equal( - this.$('#about-link').attr('href'), - undefined, - 'there is no href attribute' - ); + assert.equal(this.$('#about-link').attr('href'), undefined, 'there is no href attribute'); }); } @@ -131,7 +113,7 @@ moduleFor( 'controller:index', Controller.extend({ shouldDisable: true, - dynamicDisabledWhen: 'shouldDisable' + dynamicDisabledWhen: 'shouldDisable', }) ); @@ -161,10 +143,7 @@ moduleFor( [`@test the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is not provided`]( assert ) { - this.addTemplate( - 'index', - `{{#link-to "about" id="about-link"}}About{{/link-to}}` - ); + this.addTemplate('index', `{{#link-to "about" id="about-link"}}About{{/link-to}}`); return this.visit('/').then(() => { assert.ok( @@ -191,9 +170,7 @@ moduleFor( }); } - [`@test the {{link-to}} helper supports a custom disabledClass set via bound param`]( - assert - ) { + [`@test the {{link-to}} helper supports a custom disabledClass set via bound param`](assert) { this.addTemplate( 'index', ` @@ -204,7 +181,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - disabledClass: 'do-not-want' + disabledClass: 'do-not-want', }) ); @@ -217,9 +194,7 @@ moduleFor( }); } - [`@test the {{link-to}} helper does not respond to clicks when disabledWhen`]( - assert - ) { + [`@test the {{link-to}} helper does not respond to clicks when disabledWhen`](assert) { this.addTemplate( 'index', ` @@ -232,17 +207,11 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.$('h3.about').length, - 0, - 'Transitioning did not occur' - ); + assert.equal(this.$('h3.about').length, 0, 'Transitioning did not occur'); }); } - [`@test the {{link-to}} helper does not respond to clicks when disabled`]( - assert - ) { + [`@test the {{link-to}} helper does not respond to clicks when disabled`](assert) { this.addTemplate( 'index', ` @@ -255,11 +224,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.$('h3.about').length, - 0, - 'Transitioning did not occur' - ); + assert.equal(this.$('h3.about').length, 0, 'Transitioning did not occur'); }); } @@ -276,7 +241,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - disabledWhen: true + disabledWhen: true, }) ); @@ -285,11 +250,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.$('h3.about').length, - 0, - 'Transitioning did not occur' - ); + assert.equal(this.$('h3.about').length, 0, 'Transitioning did not occur'); let controller = this.applicationInstance.lookup('controller:index'); controller.set('disabledWhen', false); @@ -319,11 +280,7 @@ moduleFor( ); return this.visit('/').then(() => { - assert.equal( - this.$('h3.home').length, - 1, - 'The home template was rendered' - ); + assert.equal(this.$('h3.home').length, 1, 'The home template was rendered'); assert.equal( this.$('#self-link.zomg-active').length, 1, @@ -337,9 +294,7 @@ moduleFor( }); } - [`@test The {{link-to}} helper supports a custom activeClass from a bound param`]( - assert - ) { + [`@test The {{link-to}} helper supports a custom activeClass from a bound param`](assert) { this.addTemplate( 'index', ` @@ -352,16 +307,12 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - activeClass: 'zomg-active' + activeClass: 'zomg-active', }) ); return this.visit('/').then(() => { - assert.equal( - this.$('h3.home').length, - 1, - 'The home template was rendered' - ); + assert.equal(this.$('h3.home').length, 1, 'The home template was rendered'); assert.equal( this.$('#self-link.zomg-active').length, 1, @@ -389,7 +340,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - foo: false + foo: false, }) ); @@ -433,7 +384,7 @@ moduleFor( replaceURL() { testContext.replaceCount++; return this._super(...arguments); - } + }, }) ); @@ -480,11 +431,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.updateCount, - this.updateCountAfterVisit, - 'setURL should not be called' - ); + assert.equal(this.updateCount, this.updateCountAfterVisit, 'setURL should not be called'); assert.equal( this.replaceCount, this.replaceCountAfterVisit + 1, @@ -493,9 +440,7 @@ moduleFor( }); } - ['@test The {{link-to}} helper supports URL replacement via replace=boundTruthyThing']( - assert - ) { + ['@test The {{link-to}} helper supports URL replacement via replace=boundTruthyThing'](assert) { this.addTemplate( 'index', ` @@ -507,7 +452,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - boundTruthyThing: true + boundTruthyThing: true, }) ); @@ -516,11 +461,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.updateCount, - this.updateCountAfterVisit, - 'setURL should not be called' - ); + assert.equal(this.updateCount, this.updateCountAfterVisit, 'setURL should not be called'); assert.equal( this.replaceCount, this.replaceCountAfterVisit + 1, @@ -529,9 +470,7 @@ moduleFor( }); } - ['@test The {{link-to}} helper supports setting replace=boundFalseyThing']( - assert - ) { + ['@test The {{link-to}} helper supports setting replace=boundFalseyThing'](assert) { this.addTemplate( 'index', ` @@ -543,7 +482,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - boundFalseyThing: false + boundFalseyThing: false, }) ); @@ -552,11 +491,7 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - this.updateCount, - this.updateCountAfterVisit + 1, - 'setURL should be called' - ); + assert.equal(this.updateCount, this.updateCountAfterVisit + 1, 'setURL should be called'); assert.equal( this.replaceCount, this.replaceCountAfterVisit, @@ -615,32 +550,22 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { }, after() { assert.ok(true, 'instrumentation subscriber was called'); - } + }, }); return this.click('#about-link'); } - ['@test The {{link-to}} helper interaction event includes the route name']( - assert - ) { + ['@test The {{link-to}} helper interaction event includes the route name'](assert) { assert.expect(2); subscribe('interaction.link-to', { before(name, timestamp, { routeName }) { - assert.equal( - routeName, - 'about', - 'instrumentation subscriber was passed route name' - ); + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); }, after(name, timestamp, { routeName }) { - assert.equal( - routeName, - 'about', - 'instrumentation subscriber was passed route name' - ); - } + assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); + }, }); return this.click('#about-link'); @@ -659,7 +584,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { 'about', 'instrumentation subscriber was passed route name' ); - } + }, }); return this.click('#about-link'); @@ -671,9 +596,7 @@ if (EMBER_IMPROVED_INSTRUMENTATION) { moduleFor( 'The {{link-to}} helper - nested routes and link-to arguments', class extends ApplicationTestCase { - ['@test The {{link-to}} helper supports leaving off .index for nested routes']( - assert - ) { + ['@test The {{link-to}} helper supports leaving off .index for nested routes'](assert) { this.router.map(function() { this.route('about', function() { this.route('item'); @@ -682,19 +605,14 @@ moduleFor( this.addTemplate('about', `

About

{{outlet}}`); this.addTemplate('about.index', `
Index
`); - this.addTemplate( - 'about.item', - `
{{#link-to 'about'}}About{{/link-to}}
` - ); + this.addTemplate('about.item', `
{{#link-to 'about'}}About{{/link-to}}
`); return this.visit('/about/item').then(() => { assert.equal(normalizeUrl(this.$('#item a').attr('href')), '/about'); }); } - [`@test The {{link-to}} helper supports custom, nested, current-when`]( - assert - ) { + [`@test The {{link-to}} helper supports custom, nested, current-when`](assert) { this.router.map(function() { this.route('index', { path: '/' }, function() { this.route('about'); @@ -766,7 +684,7 @@ moduleFor( this.add( 'controller:index.about', Controller.extend({ - currentWhen: 'index' + currentWhen: 'index', }) ); @@ -785,9 +703,7 @@ moduleFor( }); } - ['@test The {{link-to}} helper supports multiple current-when routes']( - assert - ) { + ['@test The {{link-to}} helper supports multiple current-when routes'](assert) { this.router.map(function() { this.route('index', { path: '/' }, function() { this.route('about'); @@ -838,9 +754,7 @@ moduleFor( }); } - ['@test The {{link-to}} helper supports boolean values for current-when']( - assert - ) { + ['@test The {{link-to}} helper supports boolean values for current-when'](assert) { this.router.map(function() { this.route('index', { path: '/' }, function() { this.route('about'); @@ -856,10 +770,7 @@ moduleFor( ` ); - this.add( - 'controller:index.about', - Controller.extend({ isCurrent: false }) - ); + this.add('controller:index.about', Controller.extend({ isCurrent: false })); return this.visit('/about').then(() => { assert.ok( @@ -871,9 +782,7 @@ moduleFor( 'The link is not active since current-when is false' ); - let controller = this.applicationInstance.lookup( - 'controller:index.about' - ); + let controller = this.applicationInstance.lookup('controller:index.about'); this.runTask(() => controller.set('isCurrent', true)); assert.ok( @@ -914,8 +823,8 @@ moduleFor( actions: { hide() { hidden++; - } - } + }, + }, }) ); @@ -924,11 +833,7 @@ moduleFor( return this.click('#about-contact'); }) .then(() => { - assert.equal( - this.$('#contact').text(), - 'Contact', - 'precond - the link worked' - ); + assert.equal(this.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 1, 'The link bubbles'); }); @@ -962,8 +867,8 @@ moduleFor( actions: { hide() { hidden++; - } - } + }, + }, }) ); @@ -972,11 +877,7 @@ moduleFor( return this.click('#about-contact'); }) .then(() => { - assert.equal( - this.$('#contact').text(), - 'Contact', - 'precond - the link worked' - ); + assert.equal(this.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); @@ -999,7 +900,7 @@ moduleFor( this.add( 'controller:about', Controller.extend({ - boundFalseyThing: false + boundFalseyThing: false, }) ); @@ -1017,8 +918,8 @@ moduleFor( actions: { hide() { hidden++; - } - } + }, + }, }) ); @@ -1027,18 +928,12 @@ moduleFor( return this.click('#about-contact'); }) .then(() => { - assert.equal( - this.$('#contact').text(), - 'Contact', - 'precond - the link worked' - ); + assert.equal(this.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); } - [`@test The {{link-to}} helper moves into the named route with context`]( - assert - ) { + [`@test The {{link-to}} helper moves into the named route with context`](assert) { this.router.map(function() { this.route('about'); this.route('item', { path: '/item/:id' }); @@ -1085,19 +980,15 @@ moduleFor( return [ { id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, - { id: 'erik', name: 'Erik Brynroflsson' } + { id: 'erik', name: 'Erik Brynroflsson' }, ]; - } + }, }) ); return this.visit('/about') .then(() => { - assert.equal( - this.$('h3.list').length, - 1, - 'The home template was rendered' - ); + assert.equal(this.$('h3.list').length, 1, 'The home template was rendered'); assert.equal( normalizeUrl(this.$('#home-link').attr('href')), '/', @@ -1107,16 +998,8 @@ moduleFor( return this.click('#yehuda'); }) .then(() => { - assert.equal( - this.$('h3.item').length, - 1, - 'The item template was rendered' - ); - assert.equal( - this.$('p').text(), - 'Yehuda Katz', - 'The name is correct' - ); + assert.equal(this.$('h3.item').length, 1, 'The item template was rendered'); + assert.equal(this.$('p').text(), 'Yehuda Katz', 'The name is correct'); return this.click('#home-link'); }) @@ -1124,38 +1007,19 @@ moduleFor( return this.click('#about-link'); }) .then(() => { - assert.equal( - normalizeUrl(this.$('li a#yehuda').attr('href')), - '/item/yehuda' - ); - assert.equal( - normalizeUrl(this.$('li a#tom').attr('href')), - '/item/tom' - ); - assert.equal( - normalizeUrl(this.$('li a#erik').attr('href')), - '/item/erik' - ); + assert.equal(normalizeUrl(this.$('li a#yehuda').attr('href')), '/item/yehuda'); + assert.equal(normalizeUrl(this.$('li a#tom').attr('href')), '/item/tom'); + assert.equal(normalizeUrl(this.$('li a#erik').attr('href')), '/item/erik'); return this.click('#erik'); }) .then(() => { - assert.equal( - this.$('h3.item').length, - 1, - 'The item template was rendered' - ); - assert.equal( - this.$('p').text(), - 'Erik Brynroflsson', - 'The name is correct' - ); + assert.equal(this.$('h3.item').length, 1, 'The item template was rendered'); + assert.equal(this.$('p').text(), 'Erik Brynroflsson', 'The name is correct'); }); } - [`@test The {{link-to}} helper binds some anchor html tag common attributes`]( - assert - ) { + [`@test The {{link-to}} helper binds some anchor html tag common attributes`](assert) { this.addTemplate( 'index', ` @@ -1168,21 +1032,9 @@ moduleFor( return this.visit('/').then(() => { let link = this.$('#self-link'); - assert.equal( - link.attr('title'), - 'title-attr', - 'The self-link contains title attribute' - ); - assert.equal( - link.attr('rel'), - 'rel-attr', - 'The self-link contains rel attribute' - ); - assert.equal( - link.attr('tabindex'), - '-1', - 'The self-link contains tabindex attribute' - ); + assert.equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); + assert.equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); + assert.equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); }); } @@ -1197,11 +1049,7 @@ moduleFor( return this.visit('/').then(() => { let link = this.$('#self-link'); - assert.equal( - link.attr('target'), - '_blank', - 'The self-link contains `target` attribute' - ); + assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); } @@ -1216,17 +1064,13 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - boundLinkTarget: '_blank' + boundLinkTarget: '_blank', }) ); return this.visit('/').then(() => { let link = this.$('#self-link'); - assert.equal( - link.attr('target'), - '_blank', - 'The self-link contains `target` attribute' - ); + assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); } @@ -1260,9 +1104,7 @@ moduleFor( ); return this.visit('/').then(() => { - assertNav({ prevented: false }, () => - this.$('#about-link').trigger('click') - ); + assertNav({ prevented: false }, () => this.$('#about-link').trigger('click')); }); } @@ -1281,14 +1123,12 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - boundFalseyThing: false + boundFalseyThing: false, }) ); return this.visit('/').then(() => { - assertNav({ prevented: false }, () => - this.$('#about-link').trigger('click') - ); + assertNav({ prevented: false }, () => this.$('#about-link').trigger('click')); }); } @@ -1362,7 +1202,7 @@ moduleFor( Controller.extend({ filter: 'unpopular', repo: { owner: 'ember', name: 'ember.js' }, - post_id: 123 + post_id: 123, }) ); @@ -1379,22 +1219,10 @@ moduleFor( ); return this.visit('/filters/popular').then(() => { - assert.equal( - normalizeUrl(this.$('#link').attr('href')), - '/filters/unpopular' - ); - assert.equal( - normalizeUrl(this.$('#path-link').attr('href')), - '/filters/unpopular' - ); - assert.equal( - normalizeUrl(this.$('#post-path-link').attr('href')), - '/post/123' - ); - assert.equal( - normalizeUrl(this.$('#post-number-link').attr('href')), - '/post/123' - ); + assert.equal(normalizeUrl(this.$('#link').attr('href')), '/filters/unpopular'); + assert.equal(normalizeUrl(this.$('#path-link').attr('href')), '/filters/unpopular'); + assert.equal(normalizeUrl(this.$('#post-path-link').attr('href')), '/post/123'); + assert.equal(normalizeUrl(this.$('#post-number-link').attr('href')), '/post/123'); assert.equal( normalizeUrl(this.$('#repo-object-link').attr('href')), '/repo/ember/ember.js' @@ -1419,7 +1247,7 @@ moduleFor( model(params) { assert.equal(params.lobby_id, 'foobar'); return params.lobby_id; - } + }, }) ); @@ -1457,7 +1285,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - foo: 'index' + foo: 'index', }) ); @@ -1476,9 +1304,7 @@ moduleFor( }); } - [`@test The {{link-to}} helper refreshes href element when one of params changes`]( - assert - ) { + [`@test The {{link-to}} helper refreshes href element when one of params changes`](assert) { this.router.map(function() { this.route('post', { path: '/posts/:post_id' }); }); @@ -1496,9 +1322,7 @@ moduleFor( this.add('controller:index', Controller.extend()); return this.visit('/').then(() => { - let indexController = this.applicationInstance.lookup( - 'controller:index' - ); + let indexController = this.applicationInstance.lookup('controller:index'); this.runTask(() => indexController.set('post', post)); assert.equal( @@ -1545,36 +1369,18 @@ moduleFor( return this.visit('/about') .then(() => { - assert.equal( - this.$('#about-link.active').length, - 1, - 'The about route link is active' - ); - assert.equal( - this.$('#item-link.active').length, - 0, - 'The item route link is inactive' - ); + assert.equal(this.$('#about-link.active').length, 1, 'The about route link is active'); + assert.equal(this.$('#item-link.active').length, 0, 'The item route link is inactive'); return this.visit('/about/item'); }) .then(() => { - assert.equal( - this.$('#about-link.active').length, - 1, - 'The about route link is active' - ); - assert.equal( - this.$('#item-link.active').length, - 1, - 'The item route link is active' - ); + assert.equal(this.$('#about-link.active').length, 1, 'The about route link is active'); + assert.equal(this.$('#item-link.active').length, 1, 'The item route link is active'); }); } - [`@test The {{link-to}} helper works in an #each'd array of string route names`]( - assert - ) { + [`@test The {{link-to}} helper works in an #each'd array of string route names`](assert) { this.router.map(function() { this.route('foo'); this.route('bar'); @@ -1586,7 +1392,7 @@ moduleFor( Controller.extend({ routeNames: emberA(['foo', 'bar', 'rar']), route1: 'bar', - route2: 'foo' + route2: 'foo', }) ); @@ -1605,11 +1411,7 @@ moduleFor( ); let linksEqual = (links, expected) => { - assert.equal( - links.length, - expected.length, - 'Has correct number of links' - ); + assert.equal(links.length, expected.length, 'Has correct number of links'); let idx; for (idx = 0; idx < links.length; idx++) { @@ -1624,49 +1426,20 @@ moduleFor( }; return this.visit('/').then(() => { - linksEqual(this.$('a'), [ - '/foo', - '/bar', - '/rar', - '/foo', - '/bar', - '/rar', - '/bar', - '/foo' - ]); - - let indexController = this.applicationInstance.lookup( - 'controller:index' - ); + linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); + + let indexController = this.applicationInstance.lookup('controller:index'); this.runTask(() => indexController.set('route1', 'rar')); - linksEqual(this.$('a'), [ - '/foo', - '/bar', - '/rar', - '/foo', - '/bar', - '/rar', - '/rar', - '/foo' - ]); + linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); this.runTask(() => indexController.routeNames.shiftObject()); - linksEqual(this.$('a'), [ - '/bar', - '/rar', - '/bar', - '/rar', - '/rar', - '/foo' - ]); + linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); }); } - [`@test The non-block form {{link-to}} helper moves into the named route`]( - assert - ) { + [`@test The non-block form {{link-to}} helper moves into the named route`](assert) { assert.expect(3); this.router.map(function() { this.route('contact'); @@ -1694,11 +1467,7 @@ moduleFor( return this.click('#contact-link'); }) .then(() => { - assert.equal( - this.$('h3.contact').length, - 1, - 'The contact template was rendered' - ); + assert.equal(this.$('h3.contact').length, 1, 'The contact template was rendered'); assert.equal( this.$('#self-link.active').length, 1, @@ -1723,7 +1492,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - contactName: 'Jane' + contactName: 'Jane', }) ); @@ -1772,11 +1541,7 @@ moduleFor( return this.click('#contact-link'); }) .then(() => { - assert.equal( - this.$('h3.contact').length, - 1, - 'The contact template was rendered' - ); + assert.equal(this.$('h3.contact').length, 1, 'The contact template was rendered'); assert.equal( this.$('#self-link.active').length, 1, @@ -1791,11 +1556,7 @@ moduleFor( return this.click('#home-link'); }) .then(() => { - assert.equal( - this.$('h3.home').length, - 1, - 'The index template was rendered' - ); + assert.equal(this.$('h3.home').length, 1, 'The index template was rendered'); assert.equal( this.$('#contact-link').text(), 'Robert', @@ -1820,9 +1581,9 @@ moduleFor( return [ { id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, - { id: 'erik', name: 'Erik Brynroflsson' } + { id: 'erik', name: 'Erik Brynroflsson' }, ]; - } + }, }) ); @@ -1853,32 +1614,15 @@ moduleFor( return this.click('#yehuda'); }) .then(() => { - assert.equal( - this.$('h3.item').length, - 1, - 'The item template was rendered' - ); - assert.equal( - this.$('p').text(), - 'Yehuda Katz', - 'The name is correct' - ); + assert.equal(this.$('h3.item').length, 1, 'The item template was rendered'); + assert.equal(this.$('p').text(), 'Yehuda Katz', 'The name is correct'); return this.click('#home-link'); }) .then(() => { - assert.equal( - normalizeUrl(this.$('li a#yehuda').attr('href')), - '/item/yehuda' - ); - assert.equal( - normalizeUrl(this.$('li a#tom').attr('href')), - '/item/tom' - ); - assert.equal( - normalizeUrl(this.$('li a#erik').attr('href')), - '/item/erik' - ); + assert.equal(normalizeUrl(this.$('li a#yehuda').attr('href')), '/item/yehuda'); + assert.equal(normalizeUrl(this.$('li a#tom').attr('href')), '/item/tom'); + assert.equal(normalizeUrl(this.$('li a#erik').attr('href')), '/item/erik'); }); } @@ -1898,7 +1642,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - foo: 'index' + foo: 'index', }) ); @@ -1923,16 +1667,14 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - display: 'blahzorz' + display: 'blahzorz', }) ); return this.visit('/').then(() => { assert.equal(this.$('#link').text(), 'blahzorz'); - let controller = this.applicationInstance.lookup( - 'controller:application' - ); + let controller = this.applicationInstance.lookup('controller:application'); this.runTask(() => controller.set('display', 'BLAMMO')); assert.equal(this.$('#link').text(), 'BLAMMO'); @@ -1940,9 +1682,7 @@ moduleFor( }); } - [`@test the {{link-to}} helper throws a useful error if you invoke it wrong`]( - assert - ) { + [`@test the {{link-to}} helper throws a useful error if you invoke it wrong`](assert) { assert.expect(1); this.router.map(function() { @@ -1958,9 +1698,7 @@ moduleFor( return this.runLoopSettled(); } - [`@test the {{link-to}} helper does not throw an error if its route has exited`]( - assert - ) { + [`@test the {{link-to}} helper does not throw an error if its route has exited`](assert) { assert.expect(0); this.router.map(function() { @@ -1983,7 +1721,7 @@ moduleFor( Controller.extend({ defaultPost: { id: 1 }, postController: inject.controller('post'), - currentPost: alias('postController.model') + currentPost: alias('postController.model'), }) ); @@ -1997,7 +1735,7 @@ moduleFor( }, serialize(model) { return { post_id: model.id }; - } + }, }) ); @@ -2008,9 +1746,7 @@ moduleFor( .then(() => this.click('#home-link')); } - [`@test {{link-to}} active property respects changing parent route context`]( - assert - ) { + [`@test {{link-to}} active property respects changing parent route context`](assert) { this.router.map(function() { this.route('things', { path: '/things/:name' }, function() { this.route('other'); @@ -2045,21 +1781,14 @@ moduleFor( 'controller:index', Controller.extend({ queryParams: ['foo'], - foo: '123' + foo: '123', }) ); - this.addTemplate( - 'index', - `{{#link-to 'index' id='the-link'}}Index{{/link-to}}` - ); + this.addTemplate('index', `{{#link-to 'index' id='the-link'}}Index{{/link-to}}`); return this.visit('/').then(() => { - assert.equal( - this.$('#the-link').attr('href'), - '/', - 'link has right href' - ); + assert.equal(this.$('#the-link').attr('href'), '/', 'link has right href'); }); } @@ -2070,7 +1799,7 @@ moduleFor( 'controller:index', Controller.extend({ queryParams: ['foo'], - foo: '123' + foo: '123', }) ); @@ -2082,17 +1811,11 @@ moduleFor( ); return this.visit('/').then(() => { - assert.equal( - this.$('#the-link').attr('href'), - '/', - 'link has right href' - ); + assert.equal(this.$('#the-link').attr('href'), '/', 'link has right href'); }); } - [`@test {{link-to}} with only query-params and a block updates when route changes`]( - assert - ) { + [`@test {{link-to}} with only query-params and a block updates when route changes`](assert) { this.router.map(function() { this.route('about'); }); @@ -2102,7 +1825,7 @@ moduleFor( Controller.extend({ queryParams: ['foo', 'bar'], foo: '123', - bar: 'yes' + bar: 'yes', }) ); @@ -2132,9 +1855,7 @@ moduleFor( }); } - [`@test Block-less {{link-to}} with only query-params updates when route changes`]( - assert - ) { + [`@test Block-less {{link-to}} with only query-params updates when route changes`](assert) { this.router.map(function() { this.route('about'); }); @@ -2144,7 +1865,7 @@ moduleFor( Controller.extend({ queryParams: ['foo', 'bar'], foo: '123', - bar: 'yes' + bar: 'yes', }) ); @@ -2186,7 +1907,7 @@ moduleFor( init() { this._super(...arguments); this.dynamicLinkParams = ['foo', 'one', 'two']; - } + }, }) ); @@ -2228,7 +1949,7 @@ moduleFor( Route.extend({ afterModel() { this.transitionTo('parent.child'); - } + }, }) ); @@ -2253,9 +1974,7 @@ moduleFor( moduleFor( 'The {{link-to}} helper - loading states and warnings', class extends ApplicationTestCase { - [`@test link-to with null/undefined dynamic parameters are put in a loading state`]( - assert - ) { + [`@test link-to with null/undefined dynamic parameters are put in a loading state`](assert) { assert.expect(19); let warningMessage = 'This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'; @@ -2282,7 +2001,7 @@ moduleFor( Controller.extend({ destinationRoute: null, routeContext: null, - loadingClass: 'i-am-loading' + loadingClass: 'i-am-loading', }) ); @@ -2291,31 +2010,17 @@ moduleFor( Route.extend({ activate() { assert.ok(true, 'About was entered'); - } + }, }) ); function assertLinkStatus(link, url) { if (url) { - assert.equal( - normalizeUrl(link.attr('href')), - url, - 'loaded link-to has expected href' - ); - assert.ok( - !link.hasClass('i-am-loading'), - 'loaded linkComponent has no loadingClass' - ); + assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href'); + assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass'); } else { - assert.equal( - normalizeUrl(link.attr('href')), - '#', - "unloaded link-to has href='#'" - ); - assert.ok( - link.hasClass('i-am-loading'), - 'loading linkComponent has loadingClass' - ); + assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'"); + assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass'); } } diff --git a/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js b/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js index f2967d3a0ae..d345bcf75e4 100644 --- a/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js +++ b/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js @@ -36,7 +36,7 @@ moduleFor( Route.extend({ model() { return _this.aboutDefer.promise; - } + }, }) ); @@ -45,7 +45,7 @@ moduleFor( Route.extend({ model() { return _this.otherDefer.promise; - } + }, }) ); @@ -54,7 +54,7 @@ moduleFor( Route.extend({ model() { return _this.newsDefer.promise; - } + }, }) ); @@ -171,7 +171,7 @@ moduleFor( Route.extend({ model() { return _this.aboutDefer.promise; - } + }, }) ); @@ -180,7 +180,7 @@ moduleFor( Route.extend({ model() { return _this.otherDefer.promise; - } + }, }) ); diff --git a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js index ce1abf790c7..7ca431d5d27 100644 --- a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js +++ b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js @@ -9,7 +9,7 @@ moduleFor( super(); let indexProperties = { foo: '123', - bar: 'abc' + bar: 'abc', }; this.add( 'controller:index', @@ -18,7 +18,7 @@ moduleFor( foo: indexProperties.foo, bar: indexProperties.bar, boundThing: 'OMG', - abool: true + abool: true, }) ); this.add( @@ -26,7 +26,7 @@ moduleFor( Controller.extend({ queryParams: ['baz', 'bat'], baz: 'alex', - bat: 'borf' + bat: 'borf', }) ); this.indexProperties = indexProperties; @@ -53,9 +53,7 @@ moduleFor( ); } - [`@test doesn't update controller QP properties on current route when invoked`]( - assert - ) { + [`@test doesn't update controller QP properties on current route when invoked`](assert) { this.addTemplate( 'index', ` @@ -119,9 +117,7 @@ moduleFor( }); } - ['@test updates controller QP properties on current route when invoked']( - assert - ) { + ['@test updates controller QP properties on current route when invoked'](assert) { this.addTemplate( 'index', ` @@ -299,7 +295,7 @@ moduleFor( 'controller:cars', Controller.extend({ queryParams: ['page'], - page: 1 + page: 1, }) ); @@ -313,35 +309,17 @@ moduleFor( assert.equal(router.currentRouteName, 'cars.index'); assert.equal(router.get('url'), '/cars'); - assert.equal( - carsController.get('page'), - 1, - 'The page query-param is 1' - ); + assert.equal(carsController.get('page'), 1, 'The page query-param is 1'); this.runTask(() => this.click('#page2-link')); - assert.equal( - router.currentRouteName, - 'cars.index', - 'The active route is still cars' - ); - assert.equal( - router.get('url'), - '/cars?page=2', - 'The url has been updated' - ); - assert.equal( - carsController.get('page'), - 2, - 'The query params have been updated' - ); + assert.equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); + assert.equal(router.get('url'), '/cars?page=2', 'The url has been updated'); + assert.equal(carsController.get('page'), 2, 'The query params have been updated'); }); } - ['@test the {{link-to}} applies activeClass when query params are not changed']( - assert - ) { + ['@test the {{link-to}} applies activeClass when query params are not changed'](assert) { this.addTemplate( 'index', ` @@ -387,7 +365,7 @@ moduleFor( Controller.extend({ queryParams: ['search', 'archive'], search: '', - archive: false + archive: false, }) ); @@ -396,7 +374,7 @@ moduleFor( Controller.extend({ queryParams: ['sort', 'showDetails'], sort: 'title', - showDetails: true + showDetails: true, }) ); @@ -433,32 +411,19 @@ moduleFor( this.shouldBeActive(assert, '#both-same'); this.shouldNotBeActive(assert, '#change-one'); - return this.visit( - '/search/results?search=same&sort=title&showDetails=true' - ); + return this.visit('/search/results?search=same&sort=title&showDetails=true'); }) .then(() => { this.shouldBeActive(assert, '#same-sort-child-only'); this.shouldBeActive(assert, '#same-search-parent-only'); this.shouldNotBeActive(assert, '#change-search-parent-only'); - this.shouldBeActive( - assert, - '#same-search-same-sort-child-and-parent' - ); - this.shouldNotBeActive( - assert, - '#same-search-different-sort-child-and-parent' - ); - this.shouldNotBeActive( - assert, - '#change-search-same-sort-child-and-parent' - ); + this.shouldBeActive(assert, '#same-search-same-sort-child-and-parent'); + this.shouldNotBeActive(assert, '#same-search-different-sort-child-and-parent'); + this.shouldNotBeActive(assert, '#change-search-same-sort-child-and-parent'); }); } - ['@test the {{link-to}} applies active class when query-param is a number']( - assert - ) { + ['@test the {{link-to}} applies active class when query-param is a number'](assert) { this.addTemplate( 'index', ` @@ -472,7 +437,7 @@ moduleFor( Controller.extend({ queryParams: ['page'], page: 1, - pageNumber: 5 + pageNumber: 5, }) ); @@ -486,9 +451,7 @@ moduleFor( }); } - ['@test the {{link-to}} applies active class when query-param is an array']( - assert - ) { + ['@test the {{link-to}} applies active class when query-param is an array'](assert) { this.addTemplate( 'index', ` @@ -505,7 +468,7 @@ moduleFor( pages: [], pagesArray: [1, 2], biggerArray: [1, 2, 3], - emptyArray: [] + emptyArray: [], }) ); @@ -535,9 +498,7 @@ moduleFor( this.shouldNotBeActive(assert, '#empty-link'); }); } - ['@test the {{link-to}} helper applies active class to the parent route']( - assert - ) { + ['@test the {{link-to}} helper applies active class to the parent route'](assert) { this.router.map(function() { this.route('parent', function() { this.route('child'); @@ -558,7 +519,7 @@ moduleFor( 'controller:parent.child', Controller.extend({ queryParams: ['foo'], - foo: 'bar' + foo: 'bar', }) ); @@ -605,7 +566,7 @@ moduleFor( 'controller:parent', Controller.extend({ queryParams: ['page'], - page: 1 + page: 1, }) ); @@ -643,9 +604,7 @@ moduleFor( }); } - ['@test link-to default query params while in active transition regression test']( - assert - ) { + ['@test link-to default query params while in active transition regression test'](assert) { this.router.map(function() { this.route('foos'); this.route('bars'); @@ -665,7 +624,7 @@ moduleFor( 'controller:foos', Controller.extend({ queryParams: ['status'], - baz: false + baz: false, }) ); this.add( @@ -673,14 +632,14 @@ moduleFor( Route.extend({ model() { return foos.promise; - } + }, }) ); this.add( 'controller:bars', Controller.extend({ queryParams: ['status'], - quux: false + quux: false, }) ); this.add( @@ -688,7 +647,7 @@ moduleFor( Route.extend({ model() { return bars.promise; - } + }, }) ); @@ -719,15 +678,10 @@ moduleFor( }); } - [`@test the {{link-to}} helper throws a useful error if you invoke it wrong`]( - assert - ) { + [`@test the {{link-to}} helper throws a useful error if you invoke it wrong`](assert) { assert.expect(1); - this.addTemplate( - 'application', - `{{#link-to id='the-link'}}Index{{/link-to}}` - ); + this.addTemplate('application', `{{#link-to id='the-link'}}Index{{/link-to}}`); expectAssertion(() => { this.visit('/'); diff --git a/packages/ember/tests/homepage_example_test.js b/packages/ember/tests/homepage_example_test.js index 6c238dffe81..ddd627d4f3c 100644 --- a/packages/ember/tests/homepage_example_test.js +++ b/packages/ember/tests/homepage_example_test.js @@ -19,7 +19,7 @@ moduleFor( lastName: null, fullName: computed('firstName', 'lastName', function() { return `${this.get('firstName')} ${this.get('lastName')}`; - }) + }), }); this.add( @@ -28,9 +28,9 @@ moduleFor( model() { return emberA([ Person.create({ firstName: 'Tom', lastName: 'Dale' }), - Person.create({ firstName: 'Yehuda', lastName: 'Katz' }) + Person.create({ firstName: 'Yehuda', lastName: 'Katz' }), ]); - } + }, }) ); @@ -40,10 +40,7 @@ moduleFor( assert.equal($.findAll('h1').text(), 'People'); assert.equal($.findAll('li').length, 2); assert.equal($.findAll('li:nth-of-type(1)').text(), 'Hello, Tom Dale!'); - assert.equal( - $.findAll('li:nth-of-type(2)').text(), - 'Hello, Yehuda Katz!' - ); + assert.equal($.findAll('li:nth-of-type(2)').text(), 'Hello, Yehuda Katz!'); }); } } diff --git a/packages/ember/tests/integration/multiple-app-test.js b/packages/ember/tests/integration/multiple-app-test.js index a83e4e6ed1b..a53422041dc 100644 --- a/packages/ember/tests/integration/multiple-app-test.js +++ b/packages/ember/tests/integration/multiple-app-test.js @@ -21,18 +21,14 @@ moduleFor( get applicationOptions() { return assign(super.applicationOptions, { rootElement: '#one', - router: null + router: null, }); } createSecondApplication(options) { let { applicationOptions } = this; let secondApplicationOptions = { rootElement: '#two' }; - let myOptions = assign( - applicationOptions, - secondApplicationOptions, - options - ); + let myOptions = assign(applicationOptions, secondApplicationOptions, options); this.secondApp = Application.create(myOptions); this.secondResolver = myOptions.Resolver.lastInstance; return this.secondApp; @@ -56,8 +52,8 @@ moduleFor( doStuff() { let rootElement = getOwner(this).application.rootElement; actions.push(rootElement); - } - } + }, + }, }) ); @@ -68,7 +64,7 @@ moduleFor(

Node 1

{{special-button}} `, { - moduleName: 'my-app/templates/index.hbs' + moduleName: 'my-app/templates/index.hbs', } ) ); @@ -79,7 +75,7 @@ moduleFor( `, { - moduleName: 'my-app/templates/components/special-button.hbs' + moduleName: 'my-app/templates/components/special-button.hbs', } ) ); diff --git a/packages/ember/tests/production_build_test.js b/packages/ember/tests/production_build_test.js index 9d7d80009b6..428b4f1c69b 100644 --- a/packages/ember/tests/production_build_test.js +++ b/packages/ember/tests/production_build_test.js @@ -15,13 +15,10 @@ if (!DEBUG) { } }); - QUnit.test( - 'runInDebug does not run the callback in production builds', - function(assert) { - let fired = false; - runInDebug(() => (fired = true)); + QUnit.test('runInDebug does not run the callback in production builds', function(assert) { + let fired = false; + runInDebug(() => (fired = true)); - assert.equal(fired, false, 'runInDebug callback should not be ran'); - } - ); + assert.equal(fired, false, 'runInDebug callback should not be ran'); + }); } diff --git a/packages/ember/tests/reexports_test.js b/packages/ember/tests/reexports_test.js index 6a885fe1e31..ea475042394 100644 --- a/packages/ember/tests/reexports_test.js +++ b/packages/ember/tests/reexports_test.js @@ -125,18 +125,10 @@ let allExports = [ ['ViewUtils.getViewElement', 'ember-views', 'getViewElement'], ['ViewUtils.getViewBounds', 'ember-views', 'getViewBounds'], ['ViewUtils.getViewClientRects', 'ember-views', 'getViewClientRects'], - [ - 'ViewUtils.getViewBoundingClientRect', - 'ember-views', - 'getViewBoundingClientRect' - ], + ['ViewUtils.getViewBoundingClientRect', 'ember-views', 'getViewBoundingClientRect'], ['ViewUtils.getRootViews', 'ember-views', 'getRootViews'], ['ViewUtils.getChildViews', 'ember-views', 'getChildViews'], - [ - 'ViewUtils.isSerializationFirstNode', - 'ember-glimmer', - 'isSerializationFirstNode' - ], + ['ViewUtils.isSerializationFirstNode', 'ember-glimmer', 'isSerializationFirstNode'], ['TextSupport', 'ember-views'], ['ComponentLookup', 'ember-views'], ['EventDispatcher', 'ember-views'], @@ -193,7 +185,7 @@ let allExports = [ [ 'BOOTED', 'ember-metal', - { get: 'isNamespaceSearchDisabled', set: 'setNamespaceSearchDisabled' } + { get: 'isNamespaceSearchDisabled', set: 'setNamespaceSearchDisabled' }, ], // ember-routing @@ -219,7 +211,7 @@ let allExports = [ // ember-extension-support ['DataAdapter', 'ember-extension-support'], - ['ContainerDebugAdapter', 'ember-extension-support'] + ['ContainerDebugAdapter', 'ember-extension-support'], ]; if (ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT) { @@ -240,37 +232,20 @@ allExports.forEach(reexport => { }); QUnit.test('Ember.String.isHTMLSafe exports correctly', function(assert) { - confirmExport( - Ember, - assert, - 'String.isHTMLSafe', - 'ember-glimmer', - 'isHTMLSafe' - ); + confirmExport(Ember, assert, 'String.isHTMLSafe', 'ember-glimmer', 'isHTMLSafe'); }); if (DEBUG) { QUnit.test('Ember.MODEL_FACTORY_INJECTIONS', function(assert) { - let descriptor = Object.getOwnPropertyDescriptor( - Ember, - 'MODEL_FACTORY_INJECTIONS' - ); + let descriptor = Object.getOwnPropertyDescriptor(Ember, 'MODEL_FACTORY_INJECTIONS'); assert.equal(descriptor.enumerable, false, 'descriptor is not enumerable'); - assert.equal( - descriptor.configurable, - false, - 'descriptor is not configurable' - ); + assert.equal(descriptor.configurable, false, 'descriptor is not configurable'); assert.equal(Ember.MODEL_FACTORY_INJECTIONS, false); expectDeprecation(function() { Ember.MODEL_FACTORY_INJECTIONS = true; }, 'Ember.MODEL_FACTORY_INJECTIONS is no longer required'); - assert.equal( - Ember.MODEL_FACTORY_INJECTIONS, - false, - 'writing to the property has no affect' - ); + assert.equal(Ember.MODEL_FACTORY_INJECTIONS, false, 'writing to the property has no affect'); }); } diff --git a/packages/ember/tests/routing/decoupled_basic_test.js b/packages/ember/tests/routing/decoupled_basic_test.js index 58b8ea22b2a..003ed4e31d6 100644 --- a/packages/ember/tests/routing/decoupled_basic_test.js +++ b/packages/ember/tests/routing/decoupled_basic_test.js @@ -4,12 +4,7 @@ import RSVP from 'rsvp'; import { compile } from 'ember-template-compiler'; import { ENV } from 'ember-environment'; import { Route, NoneLocation, HistoryLocation } from 'ember-routing'; -import { - Controller, - Object as EmberObject, - A as emberA, - copy -} from 'ember-runtime'; +import { Controller, Object as EmberObject, A as emberA, copy } from 'ember-runtime'; import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; import { Mixin, computed, run, set, addObserver, observer } from 'ember-metal'; import { getTextOf } from 'internal-test-helpers'; @@ -26,14 +21,8 @@ moduleFor( constructor() { super(); this.addTemplate('home', '

Hours

'); - this.addTemplate( - 'camelot', - '

Is a silly place

' - ); - this.addTemplate( - 'homepage', - '

Megatroll

{{model.home}}

' - ); + this.addTemplate('camelot', '

Is a silly place

'); + this.addTemplate('homepage', '

Megatroll

{{model.home}}

'); this.router.map(function() { this.route('home', { path: '/' }); @@ -106,9 +95,7 @@ moduleFor( }); } - [`@test The Homepage and the Camelot page with multiple Router.map calls`]( - assert - ) { + [`@test The Homepage and the Camelot page with multiple Router.map calls`](assert) { this.router.map(function() { this.route('camelot', { path: '/camelot' }); }); @@ -118,11 +105,7 @@ moduleFor( assert.equal(this.currentPath, 'camelot'); let text = this.$('#camelot').text(); - assert.equal( - text, - 'Is a silly place', - 'the camelot template was rendered' - ); + assert.equal(text, 'Is a silly place', 'the camelot template was rendered'); return this.visit('/'); }) @@ -134,15 +117,13 @@ moduleFor( }); } - [`@test The Homepage with explicit template name in renderTemplate`]( - assert - ) { + [`@test The Homepage with explicit template name in renderTemplate`](assert) { this.add( 'route:home', Route.extend({ renderTemplate() { this.render('homepage'); - } + }, }) ); @@ -152,34 +133,28 @@ moduleFor( }); } - [`@test an alternate template will pull in an alternate controller`]( - assert - ) { + [`@test an alternate template will pull in an alternate controller`](assert) { this.add( 'route:home', Route.extend({ renderTemplate() { this.render('homepage'); - } + }, }) ); this.add( 'controller:homepage', Controller.extend({ model: { - home: 'Comes from homepage' - } + home: 'Comes from homepage', + }, }) ); return this.visit('/').then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'Comes from homepage', - 'the homepage template was rendered' - ); + assert.equal(text, 'Comes from homepage', 'the homepage template was rendered'); }); } @@ -192,40 +167,34 @@ moduleFor( controllerName: 'foo', renderTemplate() { this.render('homepage'); - } + }, }) ); this.add( 'controller:foo', Controller.extend({ model: { - home: 'Comes from foo' - } + home: 'Comes from foo', + }, }) ); this.add( 'controller:homepage', Controller.extend({ model: { - home: 'Comes from homepage' - } + home: 'Comes from homepage', + }, }) ); return this.visit('/').then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'Comes from homepage', - 'the homepage template was rendered' - ); + assert.equal(text, 'Comes from homepage', 'the homepage template was rendered'); }); } - [`@test The template will pull in an alternate controller via key/value`]( - assert - ) { + [`@test The template will pull in an alternate controller via key/value`](assert) { this.router.map(function() { this.route('homepage', { path: '/' }); }); @@ -235,15 +204,15 @@ moduleFor( Route.extend({ renderTemplate() { this.render({ controller: 'home' }); - } + }, }) ); this.add( 'controller:home', Controller.extend({ model: { - home: 'Comes from home.' - } + home: 'Comes from home.', + }, }) ); @@ -258,15 +227,13 @@ moduleFor( }); } - [`@test The Homepage with explicit template name in renderTemplate and controller`]( - assert - ) { + [`@test The Homepage with explicit template name in renderTemplate and controller`](assert) { this.add( 'controller:home', Controller.extend({ model: { - home: 'YES I AM HOME' - } + home: 'YES I AM HOME', + }, }) ); this.add( @@ -274,78 +241,56 @@ moduleFor( Route.extend({ renderTemplate() { this.render('homepage'); - } + }, }) ); return this.visit('/').then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'YES I AM HOME', - 'The homepage template was rendered' - ); + assert.equal(text, 'YES I AM HOME', 'The homepage template was rendered'); }); } - [`@test Model passed via renderTemplate model is set as controller's model`]( - assert - ) { + [`@test Model passed via renderTemplate model is set as controller's model`](assert) { this.addTemplate('bio', '

{{model.name}}

'); this.add( 'route:home', Route.extend({ renderTemplate() { this.render('bio', { - model: { name: 'emberjs' } + model: { name: 'emberjs' }, }); - } + }, }) ); return this.visit('/').then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'emberjs', - `Passed model was set as controller's model` - ); + assert.equal(text, 'emberjs', `Passed model was set as controller's model`); }); } ['@test render uses templateName from route'](assert) { - this.addTemplate( - 'the_real_home_template', - '

THIS IS THE REAL HOME

' - ); + this.addTemplate('the_real_home_template', '

THIS IS THE REAL HOME

'); this.add( 'route:home', Route.extend({ - templateName: 'the_real_home_template' + templateName: 'the_real_home_template', }) ); return this.visit('/').then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'THIS IS THE REAL HOME', - 'the homepage template was rendered' - ); + assert.equal(text, 'THIS IS THE REAL HOME', 'the homepage template was rendered'); }); } - ['@test defining templateName allows other templates to be rendered']( - assert - ) { + ['@test defining templateName allows other templates to be rendered'](assert) { this.addTemplate('alert', `
Invader!
`); - this.addTemplate( - 'the_real_home_template', - `

THIS IS THE REAL HOME

{{outlet 'alert'}}` - ); + this.addTemplate('the_real_home_template', `

THIS IS THE REAL HOME

{{outlet 'alert'}}`); this.add( 'route:home', Route.extend({ @@ -354,43 +299,30 @@ moduleFor( showAlert() { this.render('alert', { into: 'home', - outlet: 'alert' + outlet: 'alert', }); - } - } + }, + }, }) ); return this.visit('/') .then(() => { let text = this.$('p').text(); - assert.equal( - text, - 'THIS IS THE REAL HOME', - 'the homepage template was rendered' - ); + assert.equal(text, 'THIS IS THE REAL HOME', 'the homepage template was rendered'); return this.runTask(() => this.appRouter.send('showAlert')); }) .then(() => { let text = this.$('.alert-box').text(); - assert.equal( - text, - 'Invader!', - 'Template for alert was rendered into the outlet' - ); + assert.equal(text, 'Invader!', 'Template for alert was rendered into the outlet'); }); } - ['@test templateName is still used when calling render with no name and options']( - assert - ) { + ['@test templateName is still used when calling render with no name and options'](assert) { this.addTemplate('alert', `
Invader!
`); - this.addTemplate( - 'home', - `

THIS IS THE REAL HOME

{{outlet 'alert'}}` - ); + this.addTemplate('home', `

THIS IS THE REAL HOME

{{outlet 'alert'}}`); this.add( 'route:home', @@ -398,18 +330,14 @@ moduleFor( templateName: 'alert', renderTemplate() { this.render({}); - } + }, }) ); return this.visit('/').then(() => { let text = this.$('.alert-box').text(); - assert.equal( - text, - 'Invader!', - 'default templateName was rendered into outlet' - ); + assert.equal(text, 'Invader!', 'default templateName was rendered into outlet'); }); } @@ -430,9 +358,9 @@ moduleFor( controller.set('hours', [ 'Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', - 'Sunday: Noon to 6pm' + 'Sunday: Noon to 6pm', ]); - } + }, }) ); return this.visit('/').then(() => { @@ -446,16 +374,14 @@ moduleFor( }); } - [`@test The route controller is still set when overriding the setupController hook`]( - assert - ) { + [`@test The route controller is still set when overriding the setupController hook`](assert) { this.add( 'route:home', Route.extend({ setupController() { // no-op // importantly, we are not calling this._super - } + }, }) ); @@ -478,21 +404,19 @@ moduleFor( this.add( 'route:home', Route.extend({ - controllerName: 'myController' + controllerName: 'myController', }) ); this.add( 'controller:myController', Controller.extend({ - myValue: 'foo' + myValue: 'foo', }) ); return this.visit('/').then(() => { let homeRoute = this.applicationInstance.lookup('route:home'); - let myController = this.applicationInstance.lookup( - 'controller:myController' - ); + let myController = this.applicationInstance.lookup('controller:myController'); let text = this.$('p').text(); assert.equal( @@ -508,9 +432,7 @@ moduleFor( }); } - [`@test The route controller specified via controllerName is used in render`]( - assert - ) { + [`@test The route controller specified via controllerName is used in render`](assert) { this.router.map(function() { this.route('home', { path: '/' }); }); @@ -521,27 +443,22 @@ moduleFor( controllerName: 'myController', renderTemplate() { this.render('alternative_home'); - } + }, }) ); this.add( 'controller:myController', Controller.extend({ - myValue: 'foo' + myValue: 'foo', }) ); - this.addTemplate( - 'alternative_home', - '

alternative home: {{myValue}}

' - ); + this.addTemplate('alternative_home', '

alternative home: {{myValue}}

'); return this.visit('/').then(() => { let homeRoute = this.applicationInstance.lookup('route:home'); - let myController = this.applicationInstance.lookup( - 'controller:myController' - ); + let myController = this.applicationInstance.lookup('controller:myController'); let text = this.$('p').text(); assert.equal( @@ -570,29 +487,27 @@ moduleFor( this.add( 'route:home', Route.extend({ - controllerName: 'myController' + controllerName: 'myController', }) ); this.add( 'controller:home', Controller.extend({ - myValue: 'home' + myValue: 'home', }) ); this.add( 'controller:myController', Controller.extend({ - myValue: 'myController' + myValue: 'myController', }) ); return this.visit('/').then(() => { let homeRoute = this.applicationInstance.lookup('route:home'); - let myController = this.applicationInstance.lookup( - 'controller:myController' - ); + let myController = this.applicationInstance.lookup('controller:myController'); let text = this.$('p').text(); assert.equal( @@ -609,9 +524,7 @@ moduleFor( }); } - [`@test The Homepage with a 'setupController' hook modifying other controllers`]( - assert - ) { + [`@test The Homepage with a 'setupController' hook modifying other controllers`](assert) { this.router.map(function() { this.route('home', { path: '/' }); }); @@ -623,16 +536,13 @@ moduleFor( this.controllerFor('home').set('hours', [ 'Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', - 'Sunday: Noon to 6pm' + 'Sunday: Noon to 6pm', ]); - } + }, }) ); - this.addTemplate( - 'home', - '
    {{#each hours as |entry|}}
  • {{entry}}
  • {{/each}}
' - ); + this.addTemplate('home', '
    {{#each hours as |entry|}}
  • {{entry}}
  • {{/each}}
'); return this.visit('/').then(() => { let text = this.$('ul li:nth-child(3)').text(); @@ -645,9 +555,7 @@ moduleFor( }); } - [`@test The Homepage with a computed model that does not get overridden`]( - assert - ) { + [`@test The Homepage with a computed model that does not get overridden`](assert) { this.router.map(function() { this.route('home', { path: '/' }); }); @@ -659,9 +567,9 @@ moduleFor( return [ 'Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', - 'Sunday: Noon to 6pm' + 'Sunday: Noon to 6pm', ]; - }) + }), }) ); @@ -693,7 +601,7 @@ moduleFor( return [ 'Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', - 'Sunday: Noon to 6pm' + 'Sunday: Noon to 6pm', ]; }, @@ -701,14 +609,11 @@ moduleFor( assert.equal(this.controllerFor('home'), controller); this.controllerFor('home').set('hours', model); - } + }, }) ); - this.addTemplate( - 'home', - '
    {{#each hours as |entry|}}
  • {{entry}}
  • {{/each}}
' - ); + this.addTemplate('home', '
    {{#each hours as |entry|}}
  • {{entry}}
  • {{/each}}
'); return this.visit('/').then(() => { let text = this.$('ul li:nth-child(3)').text(); @@ -734,9 +639,9 @@ moduleFor( Route.extend({ model(params) { return EmberObject.create({ - menuItemId: params.menu_item_id + menuItemId: params.menu_item_id, }); - } + }, }) ); @@ -754,7 +659,7 @@ moduleFor( MenuItem.reopenClass({ find(id) { return MenuItem.create({ id }); - } + }, }); this.add('model:menu_item', MenuItem); @@ -786,7 +691,7 @@ moduleFor( return new RSVP.Promise(function(res) { resolve = res; }); - } + }, }); this.add('model:menu_item', MenuItem); @@ -816,7 +721,7 @@ moduleFor( MenuItem.reopenClass({ find(id) { return { id: id }; - } + }, }); this.add('model:menu_item', MenuItem); @@ -826,7 +731,7 @@ moduleFor( Route.extend({ enter() { assert.ok(false, "LoadingRoute shouldn't have been entered."); - } + }, }) ); @@ -840,9 +745,7 @@ moduleFor( }); } - ["@test The Special page returning an error invokes SpecialRoute's error handler"]( - assert - ) { + ["@test The Special page returning an error invokes SpecialRoute's error handler"](assert) { this.router.map(function() { this.route('home', { path: '/' }); this.route('special', { path: '/specials/:menu_item_id' }); @@ -857,7 +760,7 @@ moduleFor( promise = new RSVP.Promise(res => (resolve = res)); return promise; - } + }, }); this.add('model:menu_item', MenuItem); @@ -876,8 +779,8 @@ moduleFor( 'SpecialRoute#error received the error thrown from setup' ); return true; - } - } + }, + }, }) ); @@ -886,9 +789,7 @@ moduleFor( run(() => resolve(menuItem)); } - ["@test ApplicationRoute's default error handler can be overridden"]( - assert - ) { + ["@test ApplicationRoute's default error handler can be overridden"](assert) { assert.expect(2); this.router.map(function() { @@ -904,7 +805,7 @@ moduleFor( find(id) { menuItem = MenuItem.create({ id: id }); return new RSVP.Promise(res => (resolve = res)); - } + }, }); this.add('model:menu_item', MenuItem); @@ -919,8 +820,8 @@ moduleFor( 'error was correctly passed to custom ApplicationRoute handler' ); return true; - } - } + }, + }, }) ); @@ -929,7 +830,7 @@ moduleFor( Route.extend({ setup() { throw 'Setup error'; - } + }, }) ); @@ -938,9 +839,7 @@ moduleFor( run(() => resolve(menuItem)); } - ['@test Moving from one page to another triggers the correct callbacks']( - assert - ) { + ['@test Moving from one page to another triggers the correct callbacks'](assert) { assert.expect(3); this.router.map(function() { @@ -952,7 +851,7 @@ moduleFor( MenuItem.reopenClass({ find(id) { return MenuItem.create({ id: id }); - } + }, }); this.add('model:menu_item', MenuItem); @@ -986,14 +885,14 @@ moduleFor( find(id) { menuItem = MenuItem.create({ id: id }); return menuItem; - } + }, }); this.router.map(function() { this.route('root', { path: '/' }, function() { this.route('special', { path: '/specials/:menu_item_id', - resetNamespace: true + resetNamespace: true, }); }); }); @@ -1017,7 +916,7 @@ moduleFor( serialize() { rootSerialize++; return this._super(...arguments); - } + }, }) ); @@ -1031,7 +930,7 @@ moduleFor( }, setupController(controller, model) { set(controller, 'model', model); - } + }, }) ); @@ -1057,11 +956,7 @@ moduleFor( return router.transitionTo('special', menuItem).then(function() { assert.equal(rootSetup, 1, 'The root setup was not triggered again'); - assert.equal( - rootRender, - 1, - 'The root render was not triggered again' - ); + assert.equal(rootRender, 1, 'The root render was not triggered again'); assert.equal(rootSerialize, 0, 'The root serialize was not called'); // TODO: Should this be changed? @@ -1095,8 +990,8 @@ moduleFor( actions: { showStuff() { stateIsNotCalled = false; - } - } + }, + }, }) ); @@ -1106,18 +1001,11 @@ moduleFor( Controller.extend({ actions: { showStuff(context) { - assert.ok( - stateIsNotCalled, - 'an event on the state is not triggered' - ); - assert.deepEqual( - context, - { name: 'Tom Dale' }, - 'an event with context is passed' - ); + assert.ok(stateIsNotCalled, 'an event on the state is not triggered'); + assert.deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); done(); - } - } + }, + }, }) ); @@ -1129,9 +1017,7 @@ moduleFor( }); } - ['@test Events are triggered on the current state when defined in `actions` object']( - assert - ) { + ['@test Events are triggered on the current state when defined in `actions` object'](assert) { let done = assert.async(); this.router.map(function() { @@ -1146,26 +1032,16 @@ moduleFor( actions: { showStuff(obj) { - assert.ok( - this instanceof HomeRoute, - 'the handler is an App.HomeRoute' - ); + assert.ok(this instanceof HomeRoute, 'the handler is an App.HomeRoute'); // Using Ember.copy removes any private Ember vars which older IE would be confused by - assert.deepEqual( - copy(obj, true), - { name: 'Tom Dale' }, - 'the context is correct' - ); + assert.deepEqual(copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); done(); - } - } + }, + }, }); this.add('route:home', HomeRoute); - this.addTemplate( - 'home', - '{{model.name}}' - ); + this.addTemplate('home', '{{model.name}}'); this.visit('/').then(() => { document @@ -1191,19 +1067,12 @@ moduleFor( let RootRoute = Route.extend({ actions: { showStuff(obj) { - assert.ok( - this instanceof RootRoute, - 'the handler is an App.HomeRoute' - ); + assert.ok(this instanceof RootRoute, 'the handler is an App.HomeRoute'); // Using Ember.copy removes any private Ember vars which older IE would be confused by - assert.deepEqual( - copy(obj, true), - { name: 'Tom Dale' }, - 'the context is correct' - ); + assert.deepEqual(copy(obj, true), { name: 'Tom Dale' }, 'the context is correct'); done(); - } - } + }, + }, }); this.add('route:root', RootRoute); this.add( @@ -1211,14 +1080,11 @@ moduleFor( Route.extend({ model() { return model; - } + }, }) ); - this.addTemplate( - 'root.index', - '{{model.name}}' - ); + this.addTemplate('root.index', '{{model.name}}'); this.visit('/').then(() => { document @@ -1238,8 +1104,8 @@ moduleFor( }, bar(msg) { assert.equal(msg, 'HELLO', 'bar hander in super route'); - } - } + }, + }, }); let RouteMixin = Mixin.create({ @@ -1247,8 +1113,8 @@ moduleFor( bar(msg) { assert.equal(msg, 'HELLO', 'bar handler in mixin'); this._super(msg); - } - } + }, + }, }); this.add( @@ -1257,8 +1123,8 @@ moduleFor( actions: { baz() { assert.ok(true, 'baz', 'baz hander in route'); - } - } + }, + }, }) ); this.addTemplate( @@ -1299,18 +1165,11 @@ moduleFor( actions: { showStuff(context) { - assert.ok( - stateIsNotCalled, - 'an event on the state is not triggered' - ); - assert.deepEqual( - context, - { name: 'Tom Dale' }, - 'an event with context is passed' - ); + assert.ok(stateIsNotCalled, 'an event on the state is not triggered'); + assert.deepEqual(context, { name: 'Tom Dale' }, 'an event with context is passed'); done(); - } - } + }, + }, }) ); @@ -1321,11 +1180,8 @@ moduleFor( Controller.extend({ showStuff() { stateIsNotCalled = false; - assert.ok( - stateIsNotCalled, - 'an event on the state is not triggered' - ); - } + assert.ok(stateIsNotCalled, 'an event on the state is not triggered'); + }, }) ); @@ -1351,24 +1207,17 @@ moduleFor( let RootRoute = Route.extend({ actions: { showStuff(obj1, obj2) { - assert.ok( - this instanceof RootRoute, - 'the handler is an App.HomeRoute' - ); + assert.ok(this instanceof RootRoute, 'the handler is an App.HomeRoute'); // Using Ember.copy removes any private Ember vars which older IE would be confused by - assert.deepEqual( - copy(obj1, true), - { name: 'Tilde' }, - 'the first context is correct' - ); + assert.deepEqual(copy(obj1, true), { name: 'Tilde' }, 'the first context is correct'); assert.deepEqual( copy(obj2, true), { name: 'Tom Dale' }, 'the second context is correct' ); done(); - } - } + }, + }, }); this.add('route:root', RootRoute); @@ -1377,14 +1226,11 @@ moduleFor( 'controller:root.index', Controller.extend({ model1: model1, - model2: model2 + model2: model2, }) ); - this.addTemplate( - 'root.index', - '{{model1.name}}' - ); + this.addTemplate('root.index', '{{model1.name}}'); this.visit('/').then(() => { document @@ -1394,9 +1240,7 @@ moduleFor( }); } - ['@test transitioning multiple times in a single run loop only sets the URL once']( - assert - ) { + ['@test transitioning multiple times in a single run loop only sets the URL once'](assert) { this.router.map(function() { this.route('root', { path: '/' }); this.route('foo'); @@ -1439,9 +1283,7 @@ moduleFor( addObserver(router, 'url', function() { assert.ok(true, 'url change event was fired'); }); - ['foo', 'bar', '/foo'].forEach(destination => - run(router, 'transitionTo', destination) - ); + ['foo', 'bar', '/foo'].forEach(destination => run(router, 'transitionTo', destination)); }); } @@ -1458,8 +1300,8 @@ moduleFor( replaceURL(path) { replaceCount++; set(this, 'path', path); - } - }) + }, + }), }); this.router.map(function() { @@ -1480,9 +1322,7 @@ moduleFor( }); } - ['@test using replaceWith calls setURL if location.replaceURL is not defined']( - assert - ) { + ['@test using replaceWith calls setURL if location.replaceURL is not defined'](assert) { let setCount = 0; this.router.reopen({ @@ -1490,8 +1330,8 @@ moduleFor( setURL(path) { setCount++; set(this, 'path', path); - } - }) + }, + }), }); this.router.map(function() { @@ -1516,13 +1356,9 @@ moduleFor( this.route('the-post', { path: '/posts/:post_id' }, function() { this.route('comments'); - this.route( - 'shares', - { path: '/shares/:share_id', resetNamespace: true }, - function() { - this.route('share'); - } - ); + this.route('shares', { path: '/shares/:share_id', resetNamespace: true }, function() { + this.route('share'); + }); }); }); @@ -1536,12 +1372,12 @@ moduleFor( let posts = { 1: post1, 2: post2, - 3: post3 + 3: post3, }; let shares = { 1: share1, 2: share2, - 3: share3 + 3: share3, }; this.add( @@ -1549,7 +1385,7 @@ moduleFor( Route.extend({ model(params) { return posts[params.post_id]; - } + }, }) ); @@ -1560,7 +1396,7 @@ moduleFor( let parent_model = this.modelFor('the-post'); assert.equal(post, parent_model); - } + }, }) ); @@ -1569,7 +1405,7 @@ moduleFor( Route.extend({ model(params) { return shares[params.share_id]; - } + }, }) ); @@ -1580,7 +1416,7 @@ moduleFor( let parent_model = this.modelFor('shares'); assert.equal(share, parent_model); - } + }, }) ); @@ -1610,9 +1446,7 @@ moduleFor( }); } - ['@test Routes with { resetNamespace: true } inherits model from parent route']( - assert - ) { + ['@test Routes with { resetNamespace: true } inherits model from parent route'](assert) { assert.expect(6); this.router.map(function() { @@ -1628,7 +1462,7 @@ moduleFor( let posts = { 1: post1, 2: post2, - 3: post3 + 3: post3, }; this.add( @@ -1636,7 +1470,7 @@ moduleFor( Route.extend({ model(params) { return posts[params.post_id]; - } + }, }) ); @@ -1647,7 +1481,7 @@ moduleFor( let parent_model = this.modelFor('the-post'); assert.equal(post, parent_model); - } + }, }) ); @@ -1682,7 +1516,7 @@ moduleFor( let posts = { 1: post1, 2: post2, - 3: post3 + 3: post3, }; this.add( @@ -1690,7 +1524,7 @@ moduleFor( Route.extend({ model(params) { return posts[params.post_id]; - } + }, }) ); @@ -1699,7 +1533,7 @@ moduleFor( Route.extend({ model() { assert.equal(this.modelFor('the-post'), currentPost); - } + }, }) ); @@ -1740,7 +1574,7 @@ moduleFor( setupController() { chooseFollowed++; - } + }, }) ); @@ -1757,17 +1591,13 @@ moduleFor( 'The home template was rendered' ); assert.equal( - this.applicationInstance - .lookup('controller:application') - .get('currentPath'), + this.applicationInstance.lookup('controller:application').get('currentPath'), 'home' ); }); } - ['@test Redirecting from the middle of a route aborts the remainder of the routes']( - assert - ) { + ['@test Redirecting from the middle of a route aborts the remainder of the routes'](assert) { assert.expect(3); this.router.map(function() { @@ -1787,7 +1617,7 @@ moduleFor( }, setupController() { assert.ok(false, 'Should transition before setupController'); - } + }, }) ); @@ -1796,7 +1626,7 @@ moduleFor( Route.extend({ enter() { assert.ok(false, 'Should abort transition getting to next route'); - } + }, }) ); @@ -1804,9 +1634,7 @@ moduleFor( let router = this.applicationInstance.lookup('router:main'); this.handleURLAborts(assert, '/foo/bar/baz'); assert.equal( - this.applicationInstance - .lookup('controller:application') - .get('currentPath'), + this.applicationInstance.lookup('controller:application').get('currentPath'), 'home' ); assert.equal(router.get('location').getURL(), '/home'); @@ -1840,7 +1668,7 @@ moduleFor( setupController() { assert.ok(true, "Should still invoke bar's setupController"); - } + }, }) ); @@ -1849,23 +1677,17 @@ moduleFor( Route.extend({ setupController() { assert.ok(true, "Should still invoke bar.baz's setupController"); - } + }, }) ); return this.visit('/foo/bar/baz').then(() => { assert.ok(true, '/foo/bar/baz has been handled'); assert.equal( - this.applicationInstance - .lookup('controller:application') - .get('currentPath'), + this.applicationInstance.lookup('controller:application').get('currentPath'), 'foo.bar.baz' ); - assert.equal( - successCount, - 1, - 'transitionTo success handler was called once' - ); + assert.equal(successCount, 1, 'transitionTo success handler was called once'); }); } @@ -1877,13 +1699,9 @@ moduleFor( this.router.map(function() { this.route('home'); this.route('foo', function() { - this.route( - 'bar', - { path: 'bar/:id', resetNamespace: true }, - function() { - this.route('baz'); - } - ); + this.route('bar', { path: 'bar/:id', resetNamespace: true }, function() { + this.route('baz'); + }); }); }); @@ -1900,7 +1718,7 @@ moduleFor( } else { this.transitionTo('bar.baz', model); } - } + }, }) ); @@ -1909,16 +1727,14 @@ moduleFor( Route.extend({ setupController() { assert.ok(true, 'Should still invoke setupController'); - } + }, }) ); return this.visit('/').then(() => { this.handleURLAborts(assert, '/foo/bar/1/baz'); assert.equal( - this.applicationInstance - .lookup('controller:application') - .get('currentPath'), + this.applicationInstance.lookup('controller:application').get('currentPath'), 'foo.bar.baz' ); assert.equal( @@ -1949,16 +1765,14 @@ moduleFor( actions: { goToQux() { this.transitionTo('foo.qux'); - } - } + }, + }, }) ); return this.visit('/foo/bar/baz').then(() => { assert.ok(true, '/foo/bar/baz has been handled'); - let applicationController = this.applicationInstance.lookup( - 'controller:application' - ); + let applicationController = this.applicationInstance.lookup('controller:application'); let router = this.applicationInstance.lookup('router:main'); assert.equal(applicationController.get('currentPath'), 'foo.bar.baz'); run(() => router.send('goToQux')); @@ -1967,29 +1781,20 @@ moduleFor( }); } - ['@test Generated names can be customized when providing routes with dot notation']( - assert - ) { + ['@test Generated names can be customized when providing routes with dot notation'](assert) { assert.expect(4); this.addTemplate('index', '
Index
'); - this.addTemplate( - 'application', - "

Home

{{outlet}}
" - ); + this.addTemplate('application', "

Home

{{outlet}}
"); this.addTemplate('foo', "
{{outlet}}
"); this.addTemplate('bar', "
{{outlet}}
"); this.addTemplate('bar.baz', '

{{name}}Bottom!

'); this.router.map(function() { this.route('foo', { path: '/top' }, function() { - this.route( - 'bar', - { path: '/middle', resetNamespace: true }, - function() { - this.route('baz', { path: '/bottom' }); - } - ); + this.route('bar', { path: '/middle', resetNamespace: true }, function() { + this.route('baz', { path: '/bottom' }); + }); }); }); @@ -1999,7 +1804,7 @@ moduleFor( renderTemplate() { assert.ok(true, 'FooBarRoute was called'); return this._super(...arguments); - } + }, }) ); @@ -2009,21 +1814,21 @@ moduleFor( renderTemplate() { assert.ok(true, 'BarBazRoute was called'); return this._super(...arguments); - } + }, }) ); this.add( 'controller:bar', Controller.extend({ - name: 'Bar' + name: 'Bar', }) ); this.add( 'controller:bar.baz', Controller.extend({ - name: 'BarBaz' + name: 'BarBaz', }) ); @@ -2038,14 +1843,9 @@ moduleFor( }); } - ["@test Child routes render into their parent route's template by default"]( - assert - ) { + ["@test Child routes render into their parent route's template by default"](assert) { this.addTemplate('index', '
Index
'); - this.addTemplate( - 'application', - "

Home

{{outlet}}
" - ); + this.addTemplate('application', "

Home

{{outlet}}
"); this.addTemplate('top', "
{{outlet}}
"); this.addTemplate('middle', "
{{outlet}}
"); this.addTemplate('middle.bottom', '

Bottom!

'); @@ -2071,10 +1871,7 @@ moduleFor( ['@test Child routes render into specified template'](assert) { this.addTemplate('index', '
Index
'); - this.addTemplate( - 'application', - "

Home

{{outlet}}
" - ); + this.addTemplate('application', "

Home

{{outlet}}
"); this.addTemplate('top', "
{{outlet}}
"); this.addTemplate('middle', "
{{outlet}}
"); this.addTemplate('middle.bottom', '

Bottom!

'); @@ -2092,7 +1889,7 @@ moduleFor( Route.extend({ renderTemplate() { this.render('middle/bottom', { into: 'top' }); - } + }, }) ); @@ -2126,7 +1923,7 @@ moduleFor( renderTemplate() { this.render('person/profile'); this.render('person/details', { into: 'person/profile' }); - } + }, }) ); @@ -2152,13 +1949,9 @@ moduleFor( this.router.map(function() { this.route('posts', function() { - this.route( - 'post', - { path: '/:postId', resetNamespace: true }, - function() { - this.route('edit'); - } - ); + this.route('post', { path: '/:postId', resetNamespace: true }, function() { + this.route('edit'); + }); }); }); @@ -2168,8 +1961,8 @@ moduleFor( actions: { showPost(context) { this.transitionTo('post', context); - } - } + }, + }, }) ); @@ -2187,8 +1980,8 @@ moduleFor( actions: { editPost() { this.transitionTo('post.edit'); - } - } + }, + }, }) ); @@ -2203,7 +1996,7 @@ moduleFor( setup() { this._super(...arguments); editCount++; - } + }, }) ); @@ -2213,11 +2006,7 @@ moduleFor( run(() => router.send('editPost')); run(() => router.send('showPost', { id: '2' })); run(() => router.send('editPost')); - assert.equal( - editCount, - 2, - 'set up the edit route twice without failure' - ); + assert.equal(editCount, 2, 'set up the edit route twice without failure'); assert.deepEqual( editedPostIds, ['1', '2'], @@ -2226,9 +2015,7 @@ moduleFor( }); } - ['@test Router accounts for rootURL on page load when using history location']( - assert - ) { + ['@test Router accounts for rootURL on page load when using history location'](assert) { let rootURL = window.location.pathname + '/app'; let postsTemplateRendered = false; let setHistory; @@ -2246,7 +2033,7 @@ moduleFor( setHistory(this, path); this.set('location', { pathname: path, - href: 'http://localhost/' + path + href: 'http://localhost/' + path, }); }, @@ -2256,9 +2043,9 @@ moduleFor( pushState(path) { setHistory(this, path); - } + }, }), - rootURL: rootURL + rootURL: rootURL, }); this.router.map(function() { @@ -2271,21 +2058,16 @@ moduleFor( model() {}, renderTemplate() { postsTemplateRendered = true; - } + }, }) ); return this.visit('/').then(() => { - assert.ok( - postsTemplateRendered, - 'Posts route successfully stripped from rootURL' - ); + assert.ok(postsTemplateRendered, 'Posts route successfully stripped from rootURL'); }); } - ['@test The rootURL is passed properly to the location implementation']( - assert - ) { + ['@test The rootURL is passed properly to the location implementation'](assert) { assert.expect(1); let rootURL = '/blahzorz'; this.add( @@ -2293,11 +2075,11 @@ moduleFor( HistoryLocation.extend({ rootURL: 'this is not the URL you are looking for', history: { - pushState() {} + pushState() {}, }, initState() { assert.equal(this.get('rootURL'), rootURL); - } + }, }) ); @@ -2308,15 +2090,13 @@ moduleFor( // if the tests are run from a static file _doURLTransition() { return RSVP.resolve(''); - } + }, }); return this.visit('/'); } - ['@test Only use route rendered into main outlet for default into property on child']( - assert - ) { + ['@test Only use route rendered into main outlet for default into property on child'](assert) { this.addTemplate('application', "{{outlet 'menu'}}{{outlet}}"); this.addTemplate('posts', '{{outlet}}'); this.addTemplate('posts.index', '

postsIndex

'); @@ -2333,9 +2113,9 @@ moduleFor( this.render(); this.render('posts/menu', { into: 'application', - outlet: 'menu' + outlet: 'menu', }); - } + }, }) ); @@ -2362,7 +2142,7 @@ moduleFor( let posts = { 1: { id: 1 }, - 2: { id: 2 } + 2: { id: 2 }, }; this.add( @@ -2370,7 +2150,7 @@ moduleFor( Route.extend({ model(params) { return posts[params.post_id]; - } + }, }) ); @@ -2380,17 +2160,13 @@ moduleFor( let route = this.applicationInstance.lookup('route:post'); assert.equal(route.modelFor('post'), posts[1]); - let url = this.applicationInstance - .lookup('router:main') - .generate('post', posts[2]); + let url = this.applicationInstance.lookup('router:main').generate('post', posts[2]); assert.equal(url, '/posts/2'); assert.equal(route.modelFor('post'), posts[1]); }); } - ["@test Nested index route is not overridden by parent's implicit index route"]( - assert - ) { + ["@test Nested index route is not overridden by parent's implicit index route"](assert) { this.router.map(function() { this.route('posts', function() { this.route('index', { path: ':category' }); @@ -2409,10 +2185,7 @@ moduleFor( } ['@test Application template does not duplicate when re-rendered'](assert) { - this.addTemplate( - 'application', - '

I render once

{{outlet}}' - ); + this.addTemplate('application', '

I render once

{{outlet}}'); this.router.map(function() { this.route('posts'); @@ -2423,17 +2196,14 @@ moduleFor( Route.extend({ model() { return emberA(); - } + }, }) ); return this.visit('/posts').then(() => { assert.ok(true, '/posts has been handled'); let rootElement = document.getElementById('qunit-fixture'); - assert.equal( - getTextOf(rootElement.querySelector('h3.render-once')), - 'I render once' - ); + assert.equal(getTextOf(rootElement.querySelector('h3.render-once')), 'I render once'); }); } @@ -2453,7 +2223,7 @@ moduleFor( Route.extend({ afterModel() { this.transitionTo('posts'); - } + }, }) ); @@ -2463,9 +2233,7 @@ moduleFor( }); } - ["@test The template is not re-rendered when the route's context changes"]( - assert - ) { + ["@test The template is not re-rendered when the route's context changes"](assert) { this.router.map(function() { this.route('page', { path: '/page/:name' }); }); @@ -2475,7 +2243,7 @@ moduleFor( Route.extend({ model(params) { return EmberObject.create({ name: params.name }); - } + }, }) ); @@ -2485,7 +2253,7 @@ moduleFor( Component.extend({ didInsertElement() { insertionCount += 1; - } + }, }) ); @@ -2502,23 +2270,13 @@ moduleFor( .then(() => { assert.ok(true, '/page/second has been handled'); assert.equal(getTextOf(rootElement.querySelector('p')), 'second'); - assert.equal( - insertionCount, - 1, - 'view should have inserted only once' - ); + assert.equal(insertionCount, 1, 'view should have inserted only once'); let router = this.applicationInstance.lookup('router:main'); - return run(() => - router.transitionTo('page', EmberObject.create({ name: 'third' })) - ); + return run(() => router.transitionTo('page', EmberObject.create({ name: 'third' }))); }) .then(() => { assert.equal(getTextOf(rootElement.querySelector('p')), 'third'); - assert.equal( - insertionCount, - 1, - 'view should still have inserted only once' - ); + assert.equal(insertionCount, 1, 'view should still have inserted only once'); }); } @@ -2540,21 +2298,18 @@ moduleFor( Component.extend({ didInsertElement() { insertionCount += 1; - } + }, }) ); let SharedRoute = Route.extend({ setupController() { - this.controllerFor('shared').set( - 'message', - 'This is the ' + this.routeName + ' message' - ); + this.controllerFor('shared').set('message', 'This is the ' + this.routeName + ' message'); }, renderTemplate() { this.render('shared', { controller: 'shared' }); - } + }, }); this.add('route:shared', SharedRoute); @@ -2571,19 +2326,13 @@ moduleFor( return this.visit('/first') .then(() => { assert.ok(true, '/first has been handled'); - assert.equal( - getTextOf(rootElement.querySelector('p')), - 'This is the first message' - ); + assert.equal(getTextOf(rootElement.querySelector('p')), 'This is the first message'); assert.equal(insertionCount, 1, 'expected one assertion'); return this.visit('/second'); }) .then(() => { assert.ok(true, '/second has been handled'); - assert.equal( - getTextOf(rootElement.querySelector('p')), - 'This is the second message' - ); + assert.equal(getTextOf(rootElement.querySelector('p')), 'This is the second message'); assert.equal(insertionCount, 1, 'expected one assertion'); return run(() => { this.applicationInstance @@ -2594,36 +2343,24 @@ moduleFor( assert.ok(true, 'expected transition'); }, function(reason) { - assert.ok( - false, - 'unexpected transition failure: ', - QUnit.jsDump.parse(reason) - ); + assert.ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason)); } ); }); }) .then(() => { - assert.equal( - getTextOf(rootElement.querySelector('p')), - 'This is the third message' - ); + assert.equal(getTextOf(rootElement.querySelector('p')), 'This is the third message'); assert.equal(insertionCount, 1, 'expected one assertion'); return this.visit('fourth'); }) .then(() => { assert.ok(true, '/fourth has been handled'); assert.equal(insertionCount, 1, 'expected one assertion'); - assert.equal( - getTextOf(rootElement.querySelector('p')), - 'This is the fourth message' - ); + assert.equal(getTextOf(rootElement.querySelector('p')), 'This is the fourth message'); }); } - ['@test ApplicationRoute with model does not proxy the currentPath']( - assert - ) { + ['@test ApplicationRoute with model does not proxy the currentPath'](assert) { let model = {}; let currentPath; @@ -2636,7 +2373,7 @@ moduleFor( Route.extend({ model() { return model; - } + }, }) ); @@ -2645,7 +2382,7 @@ moduleFor( Controller.extend({ currentPathDidChange: observer('currentPath', function() { currentPath = this.currentPath; - }) + }), }) ); @@ -2659,9 +2396,7 @@ moduleFor( }); } - ['@test Promises encountered on app load put app into loading state until resolved']( - assert - ) { + ['@test Promises encountered on app load put app into loading state until resolved'](assert) { assert.expect(2); let deferred = RSVP.defer(); @@ -2674,7 +2409,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); @@ -2697,18 +2432,12 @@ moduleFor( } ['@test Route should tear down multiple outlets'](assert) { - this.addTemplate( - 'application', - "{{outlet 'menu'}}{{outlet}}{{outlet 'footer'}}" - ); + this.addTemplate('application', "{{outlet 'menu'}}{{outlet}}{{outlet 'footer'}}"); this.addTemplate('posts', '{{outlet}}'); this.addTemplate('users', 'users'); this.addTemplate('posts.index', '

postsIndex

'); this.addTemplate('posts.menu', '
postsMenu
'); - this.addTemplate( - 'posts.footer', - '' - ); + this.addTemplate('posts.footer', ''); this.router.map(function() { this.route('posts', function() {}); @@ -2721,16 +2450,16 @@ moduleFor( renderTemplate() { this.render('posts/menu', { into: 'application', - outlet: 'menu' + outlet: 'menu', }); this.render(); this.render('posts/footer', { into: 'application', - outlet: 'footer' + outlet: 'footer', }); - } + }, }) ); @@ -2790,7 +2519,7 @@ moduleFor( Route.extend({ renderTemplate() { this.render({ into: 'nonexistent' }); - } + }, }) ); @@ -2804,18 +2533,9 @@ moduleFor( this.addTemplate('application', "{{outlet}}{{outlet 'modal'}}"); this.addTemplate('posts', '{{outlet}}'); this.addTemplate('users', 'users'); - this.addTemplate( - 'posts.index', - '
postsIndex {{outlet}}
' - ); - this.addTemplate( - 'posts.modal', - '
postsModal
' - ); - this.addTemplate( - 'posts.extra', - '
postsExtra
' - ); + this.addTemplate('posts.index', '
postsIndex {{outlet}}
'); + this.addTemplate('posts.modal', '
postsModal
'); + this.addTemplate('posts.extra', '
postsExtra
'); this.router.map(function() { this.route('posts', function() {}); @@ -2829,16 +2549,16 @@ moduleFor( showModal() { this.render('posts/modal', { into: 'application', - outlet: 'modal' + outlet: 'modal', }); }, hideModal() { this.disconnectOutlet({ outlet: 'modal', - parentView: 'application' + parentView: 'application', }); - } - } + }, + }, }) ); @@ -2848,13 +2568,13 @@ moduleFor( actions: { showExtra() { this.render('posts/extra', { - into: 'posts/index' + into: 'posts/index', }); }, hideExtra() { this.disconnectOutlet({ parentView: 'posts/index' }); - } - } + }, + }, }) ); @@ -2937,14 +2657,8 @@ moduleFor( this.addTemplate('application', "{{outlet}}{{outlet 'modal'}}"); this.addTemplate('posts', '{{outlet}}'); this.addTemplate('users', 'users'); - this.addTemplate( - 'posts.index', - '
postsIndex {{outlet}}
' - ); - this.addTemplate( - 'posts.modal', - '
postsModal
' - ); + this.addTemplate('posts.index', '
postsIndex {{outlet}}
'); + this.addTemplate('posts.modal', '
postsModal
'); this.router.map(function() { this.route('posts', function() {}); @@ -2958,13 +2672,13 @@ moduleFor( showModal() { this.render('posts/modal', { into: 'application', - outlet: 'modal' + outlet: 'modal', }); }, hideModal() { this.disconnectOutlet('modal'); - } - } + }, + }, }) ); @@ -3005,9 +2719,7 @@ moduleFor( }); } - ['@test Route silently fails when cleaning an outlet from an inactive view']( - assert - ) { + ['@test Route silently fails when cleaning an outlet from an inactive view'](assert) { assert.expect(1); // handleURL this.addTemplate('application', '{{outlet}}'); @@ -3025,7 +2737,7 @@ moduleFor( hideSelf() { this.disconnectOutlet({ outlet: 'main', - parentView: 'application' + parentView: 'application', }); }, showModal() { @@ -3033,8 +2745,8 @@ moduleFor( }, hideModal() { this.disconnectOutlet({ outlet: 'modal', parentView: 'posts' }); - } - } + }, + }, }) ); @@ -3047,9 +2759,7 @@ moduleFor( }); } - ['@test Router `willTransition` hook passes in cancellable transition']( - assert - ) { + ['@test Router `willTransition` hook passes in cancellable transition'](assert) { // Should hit willTransition 3 times, once for the initial route, and then 2 more times // for the two handleURL calls below assert.expect(5); @@ -3065,7 +2775,7 @@ moduleFor( if (transition.intent.url !== '/') { transition.abort(); } - } + }, }); this.add( @@ -3073,7 +2783,7 @@ moduleFor( Route.extend({ activate() { assert.ok(false, 'LoadingRoute was not entered'); - } + }, }) ); @@ -3082,7 +2792,7 @@ moduleFor( Route.extend({ activate() { assert.ok(false, 'NorkRoute was not entered'); - } + }, }) ); @@ -3091,7 +2801,7 @@ moduleFor( Route.extend({ activate() { assert.ok(false, 'AboutRoute was not entered'); - } + }, }) ); @@ -3126,8 +2836,8 @@ moduleFor( } else { transition.abort(); } - } - } + }, + }, }) ); @@ -3141,7 +2851,7 @@ moduleFor( }, deactivate() { assert.ok(true, 'LoadingRoute was exited'); - } + }, }) ); @@ -3150,7 +2860,7 @@ moduleFor( Route.extend({ activate() { assert.ok(true, 'NorkRoute was entered'); - } + }, }) ); @@ -3164,7 +2874,7 @@ moduleFor( if (deferred) { return deferred.promise; } - } + }, }) ); @@ -3229,7 +2939,7 @@ moduleFor( didTransition() { this._super(...arguments); assert.ok(true, 'reopened didTransition was called'); - } + }, }); return this.visit('/'); @@ -3257,7 +2967,7 @@ moduleFor( activate() { assert.ok(true, 'activate hook is called'); - } + }, }) ); @@ -3287,7 +2997,7 @@ moduleFor( deactivate() { assert.ok(true, 'deactivate hook is called'); - } + }, }) ); @@ -3304,8 +3014,8 @@ moduleFor( }, bar(msg) { assert.equal(msg, 'HELLO'); - } - } + }, + }, }); let RouteMixin = Mixin.create({ @@ -3313,8 +3023,8 @@ moduleFor( bar(msg) { assert.equal(msg, 'HELLO'); this._super(msg); - } - } + }, + }, }); this.add( @@ -3323,8 +3033,8 @@ moduleFor( actions: { baz() { assert.ok(true, 'baz'); - } - } + }, + }, }) ); @@ -3396,9 +3106,7 @@ moduleFor( }); return this.visit('/').then(() => { - let appController = this.applicationInstance.lookup( - 'controller:application' - ); + let appController = this.applicationInstance.lookup('controller:application'); let router = this.applicationInstance.lookup('router:main'); function transitionAndCheck(path, expectedPath, expectedRouteName) { @@ -3406,29 +3114,14 @@ moduleFor( run(router, 'transitionTo', path); } assert.equal(appController.get('currentPath'), expectedPath); - assert.equal( - appController.get('currentRouteName'), - expectedRouteName - ); + assert.equal(appController.get('currentRouteName'), expectedRouteName); } transitionAndCheck(null, 'index', 'index'); transitionAndCheck('/be', 'be.index', 'be.index'); - transitionAndCheck( - '/be/excellent', - 'be.excellent.index', - 'excellent.index' - ); - transitionAndCheck( - '/be/excellent/to', - 'be.excellent.to.index', - 'to.index' - ); - transitionAndCheck( - '/be/excellent/to/each', - 'be.excellent.to.each.index', - 'each.index' - ); + transitionAndCheck('/be/excellent', 'be.excellent.index', 'excellent.index'); + transitionAndCheck('/be/excellent/to', 'be.excellent.to.index', 'to.index'); + transitionAndCheck('/be/excellent/to/each', 'be.excellent.to.each.index', 'each.index'); transitionAndCheck( '/be/excellent/to/each/other', 'be.excellent.to.each.other', @@ -3437,18 +3130,10 @@ moduleFor( transitionAndCheck('index', 'index', 'index'); transitionAndCheck('be', 'be.index', 'be.index'); - transitionAndCheck( - 'excellent', - 'be.excellent.index', - 'excellent.index' - ); + transitionAndCheck('excellent', 'be.excellent.index', 'excellent.index'); transitionAndCheck('to.index', 'be.excellent.to.index', 'to.index'); transitionAndCheck('each', 'be.excellent.to.each.index', 'each.index'); - transitionAndCheck( - 'each.other', - 'be.excellent.to.each.other', - 'each.other' - ); + transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other'); }); } @@ -3460,7 +3145,7 @@ moduleFor( find() { post = this; return {}; - } + }, }); this.router.map(function() { @@ -3472,9 +3157,7 @@ moduleFor( }); } - ['@test Routes can refresh themselves causing their model hooks to be re-run']( - assert - ) { + ['@test Routes can refresh themselves causing their model hooks to be re-run'](assert) { this.router.map(function() { this.route('parent', { path: '/parent/:parent_id' }, function() { this.route('child'); @@ -3487,7 +3170,7 @@ moduleFor( Route.extend({ model() { ++appcount; - } + }, }) ); @@ -3502,8 +3185,8 @@ moduleFor( actions: { refreshParent() { this.refresh(); - } - } + }, + }, }) ); @@ -3513,7 +3196,7 @@ moduleFor( Route.extend({ model() { ++childcount; - } + }, }) ); @@ -3539,9 +3222,7 @@ moduleFor( }); } - ['@test Specifying non-existent controller name in route#render throws']( - assert - ) { + ['@test Specifying non-existent controller name in route#render throws'](assert) { assert.expect(1); this.router.map(function() { @@ -3554,10 +3235,10 @@ moduleFor( renderTemplate() { expectAssertion(() => { this.render('homepage', { - controller: 'stefanpenneristhemanforme' + controller: 'stefanpenneristhemanforme', }); }, "You passed `controller: 'stefanpenneristhemanforme'` into the `render` method, but no such controller could be found."); - } + }, }) ); @@ -3577,7 +3258,7 @@ moduleFor( if (model === null) { return { hurhurhur: 'TreeklesMcGeekles' }; } - } + }, }) ); @@ -3586,7 +3267,7 @@ moduleFor( Route.extend({ beforeModel() { this.transitionTo('about', null); - } + }, }) ); @@ -3619,11 +3300,7 @@ moduleFor( rejectedMessage, "the rejected reason's message property is logged" ); - assert.equal( - errorStack, - rejectedStack, - "the rejected reason's stack property is logged" - ); + assert.equal(errorStack, rejectedStack, "the rejected reason's stack property is logged"); }; this.add( @@ -3632,9 +3309,9 @@ moduleFor( model() { return RSVP.reject({ message: rejectedMessage, - stack: rejectedStack + stack: rejectedStack, }); - } + }, }) ); @@ -3672,11 +3349,7 @@ moduleFor( rejectedMessage, "the rejected reason's message property is logged" ); - assert.equal( - errorStack, - rejectedStack, - "the rejected reason's stack property is logged" - ); + assert.equal(errorStack, rejectedStack, "the rejected reason's stack property is logged"); }; this.add( @@ -3684,9 +3357,9 @@ moduleFor( Route.extend({ model() { return RSVP.reject({ - errorThrown: { message: rejectedMessage, stack: rejectedStack } + errorThrown: { message: rejectedMessage, stack: rejectedStack }, }); - } + }, }) ); @@ -3700,9 +3373,7 @@ moduleFor( ); } - ['@test rejecting the model hooks promise with no reason still logs error']( - assert - ) { + ['@test rejecting the model hooks promise with no reason still logs error'](assert) { assert.expect(2); this.router.map(function() { this.route('wowzers', { path: '/' }); @@ -3721,16 +3392,14 @@ moduleFor( Route.extend({ model() { return RSVP.reject(); - } + }, }) ); return assert.throws(() => this.visit('/')); } - ['@test rejecting the model hooks promise with a string shows a good error']( - assert - ) { + ['@test rejecting the model hooks promise with a string shows a good error'](assert) { assert.expect(3); let rejectedMessage = 'Supercalifragilisticexpialidocious'; @@ -3756,15 +3425,11 @@ moduleFor( Route.extend({ model() { return RSVP.reject(rejectedMessage); - } + }, }) ); - assert.throws( - () => this.visit('/'), - new RegExp(rejectedMessage), - 'expected an exception' - ); + assert.throws(() => this.visit('/'), new RegExp(rejectedMessage), 'expected an exception'); } ["@test willLeave, willChangeContext, willChangeModel actions don't fire unless feature flag enabled"]( @@ -3786,8 +3451,8 @@ moduleFor( actions: { willChangeModel: shouldNotFire, willChangeContext: shouldNotFire, - willLeave: shouldNotFire - } + willLeave: shouldNotFire, + }, }) ); @@ -3796,7 +3461,7 @@ moduleFor( Route.extend({ setupController() { assert.ok(true, 'about route was entered'); - } + }, }) ); @@ -3817,7 +3482,7 @@ moduleFor( Route.extend({ redirect() { this.transitionTo('stink-bomb', { something: 'goes boom' }); - } + }, }) ); @@ -3829,11 +3494,7 @@ moduleFor( assert.throws(() => this.visit('/'), /More context objects were passed/); assert.equal(actual.length, 1, 'the error is only logged once'); - assert.equal( - actual[0][0], - 'Error while processing route: yondo', - 'source route is printed' - ); + assert.equal(actual[0][0], 'Error while processing route: yondo', 'source route is printed'); assert.ok( actual[0][1].match( /More context objects were passed than there are dynamic segments for the route: stink-bomb/ @@ -3855,7 +3516,7 @@ moduleFor( Route.extend({ redirect() { this.transitionTo('stink-bomb', { something: 'goes boom' }); - } + }, }) ); @@ -3869,23 +3530,13 @@ moduleFor( }); } - ['@test Route#resetController gets fired when changing models and exiting routes']( - assert - ) { + ['@test Route#resetController gets fired when changing models and exiting routes'](assert) { assert.expect(4); this.router.map(function() { this.route('a', function() { - this.route( - 'b', - { path: '/b/:id', resetNamespace: true }, - function() {} - ); - this.route( - 'c', - { path: '/c/:id', resetNamespace: true }, - function() {} - ); + this.route('b', { path: '/b/:id', resetNamespace: true }, function() {}); + this.route('c', { path: '/c/:id', resetNamespace: true }, function() {}); }); this.route('out'); }); @@ -3899,7 +3550,7 @@ moduleFor( resetController(/* controller */) { calls.push(['reset', this.routeName]); - } + }, }); this.add('route:a', SpyRoute.extend()); @@ -3925,17 +3576,11 @@ moduleFor( return run(router, 'transitionTo', 'out'); }) .then(() => { - assert.deepEqual(calls, [ - ['reset', 'c'], - ['reset', 'a'], - ['setup', 'out'] - ]); + assert.deepEqual(calls, [['reset', 'c'], ['reset', 'a'], ['setup', 'out']]); }); } - ['@test Exception during initialization of non-initial route is not swallowed']( - assert - ) { + ['@test Exception during initialization of non-initial route is not swallowed'](assert) { this.router.map(function() { this.route('boom'); }); @@ -3944,16 +3589,14 @@ moduleFor( Route.extend({ init() { throw new Error('boom!'); - } + }, }) ); return assert.throws(() => this.visit('/boom'), /\bboom\b/); } - ['@test Exception during initialization of initial route is not swallowed']( - assert - ) { + ['@test Exception during initialization of initial route is not swallowed'](assert) { this.router.map(function() { this.route('boom', { path: '/' }); }); @@ -3962,7 +3605,7 @@ moduleFor( Route.extend({ init() { throw new Error('boom!'); - } + }, }) ); return assert.throws(() => this.visit('/'), /\bboom\b/); @@ -3983,31 +3626,15 @@ moduleFor( return this.visit('/') .then(() => { rootElement = document.getElementById('qunit-fixture'); - assert.equal( - rootElement.textContent.trim(), - 'HiBye', - 'initial render' - ); + assert.equal(rootElement.textContent.trim(), 'HiBye', 'initial render'); - run(() => - this.applicationInstance - .lookup('controller:sample') - .set('showTheThing', true) - ); + run(() => this.applicationInstance.lookup('controller:sample').set('showTheThing', true)); - assert.equal( - rootElement.textContent.trim(), - 'HiYayBye', - 'second render' - ); + assert.equal(rootElement.textContent.trim(), 'HiYayBye', 'second render'); return this.visit('/2'); }) .then(() => { - assert.equal( - rootElement.textContent.trim(), - 'HiBooBye', - 'third render' - ); + assert.equal(rootElement.textContent.trim(), 'HiBooBye', 'third render'); }); } @@ -4025,9 +3652,9 @@ moduleFor( this.render(); this.render('modal', { into: 'application', - outlet: 'other' + outlet: 'other', }); - } + }, }) ); @@ -4055,17 +3682,17 @@ moduleFor( this.render(); this.render('modal', { into: 'application', - outlet: 'other' + outlet: 'other', }); }, actions: { banish() { this.disconnectOutlet({ parentView: 'application', - outlet: 'other' + outlet: 'other', }); - } - } + }, + }, }) ); @@ -4079,17 +3706,11 @@ moduleFor( run(this.applicationInstance.lookup('router:main'), 'send', 'banish'); - assert.equal( - rootElement.textContent.trim(), - 'A-The index-B--C', - 'second render' - ); + assert.equal(rootElement.textContent.trim(), 'A-The index-B--C', 'second render'); }); } - ['@test Can render into a named outlet at the top level, with empty main outlet']( - assert - ) { + ['@test Can render into a named outlet at the top level, with empty main outlet'](assert) { this.addTemplate('application', 'A-{{outlet}}-B-{{outlet "other"}}-C'); this.addTemplate('modal', 'Hello world'); @@ -4104,19 +3725,15 @@ moduleFor( this.render(); this.render('modal', { into: 'application', - outlet: 'other' + outlet: 'other', }); - } + }, }) ); return this.visit('/').then(() => { let rootElement = document.getElementById('qunit-fixture'); - assert.equal( - rootElement.textContent.trim(), - 'A--B-Hello world-C', - 'initial render' - ); + assert.equal(rootElement.textContent.trim(), 'A--B-Hello world-C', 'initial render'); }); } @@ -4134,20 +3751,16 @@ moduleFor( launch() { this.render('modal', { into: 'application', - outlet: 'other' + outlet: 'other', }); - } - } + }, + }, }) ); return this.visit('/').then(() => { let rootElement = document.getElementById('qunit-fixture'); - assert.equal( - rootElement.textContent.trim(), - 'A-The index-B--C', - 'initial render' - ); + assert.equal(rootElement.textContent.trim(), 'A-The index-B--C', 'initial render'); run(this.applicationInstance.lookup('router:main'), 'send', 'launch'); assert.equal( rootElement.textContent.trim(), @@ -4157,13 +3770,8 @@ moduleFor( }); } - ["@test Can render routes with no 'main' outlet and their children"]( - assert - ) { - this.addTemplate( - 'application', - '
{{outlet "app"}}
' - ); + ["@test Can render routes with no 'main' outlet and their children"](assert) { + this.addTemplate('application', '
{{outlet "app"}}
'); this.addTemplate( 'app', '
{{outlet "common"}}
{{outlet "sub"}}
' @@ -4183,13 +3791,13 @@ moduleFor( renderTemplate() { this.render('app', { outlet: 'app', - into: 'application' + into: 'application', }); this.render('common', { outlet: 'common', - into: 'app' + into: 'app', }); - } + }, }) ); @@ -4199,9 +3807,9 @@ moduleFor( renderTemplate() { this.render('sub', { outlet: 'sub', - into: 'app' + into: 'app', }); - } + }, }) ); @@ -4244,16 +3852,16 @@ moduleFor( openLayer() { this.render('layer', { into: 'application', - outlet: 'modal' + outlet: 'modal', }); }, close() { this.disconnectOutlet({ outlet: 'modal', - parentView: 'application' + parentView: 'application', }); - } - } + }, + }, }) ); @@ -4284,7 +3892,7 @@ moduleFor( Route.extend({ renderTemplate() { this.render('exports/root'); - } + }, }) ); @@ -4293,7 +3901,7 @@ moduleFor( Route.extend({ renderTemplate() { this.render('exports/index'); - } + }, }) ); @@ -4303,9 +3911,7 @@ moduleFor( }); } - ["@test Allows any route to disconnectOutlet another route's templates"]( - assert - ) { + ["@test Allows any route to disconnectOutlet another route's templates"](assert) { this.addTemplate('application', '{{outlet}}{{outlet "modal"}}'); this.addTemplate('index', 'hi'); this.addTemplate('layer', 'layer'); @@ -4319,10 +3925,10 @@ moduleFor( openLayer() { this.render('layer', { into: 'application', - outlet: 'modal' + outlet: 'modal', }); - } - } + }, + }, }) ); this.add( @@ -4332,10 +3938,10 @@ moduleFor( close() { this.disconnectOutlet({ parentView: 'application', - outlet: 'modal' + outlet: 'modal', }); - } - } + }, + }, }) ); @@ -4375,11 +3981,11 @@ moduleFor( changeToBar() { this.disconnectOutlet({ parentView: 'sidebar', - outlet: 'main' + outlet: 'main', }); this.render('bar', { into: 'sidebar' }); - } - } + }, + }, }) ); @@ -4416,10 +4022,10 @@ moduleFor( disconnect: function() { this.disconnectOutlet({ parentView: 'sidebar', - outlet: 'main' + outlet: 'main', }); - } - } + }, + }, }) ); @@ -4459,26 +4065,20 @@ moduleFor( changeToBar() { this.disconnectOutlet({ parentView: 'index', - outlet: 'main' + outlet: 'main', }); this.render('bar', { into: 'index' }); - } - } + }, + }, }) ); return this.visit('/').then(() => { let rootElement = document.getElementById('qunit-fixture'); let router = this.applicationInstance.lookup('router:main'); - assert.equal( - getTextOf(rootElement.querySelector('.sidebar .index')), - 'other' - ); + assert.equal(getTextOf(rootElement.querySelector('.sidebar .index')), 'other'); run(router, 'send', 'changeToBar'); - assert.equal( - getTextOf(rootElement.querySelector('.sidebar .index')), - 'bar' - ); + assert.equal(getTextOf(rootElement.querySelector('.sidebar .index')), 'bar'); }); } @@ -4508,25 +4108,19 @@ moduleFor( disconnect() { this.disconnectOutlet({ parentView: 'index', - outlet: 'main' + outlet: 'main', }); - } - } + }, + }, }) ); return this.visit('/').then(() => { let rootElement = document.getElementById('qunit-fixture'); let router = this.applicationInstance.lookup('router:main'); - assert.equal( - getTextOf(rootElement.querySelector('.sidebar .index')), - 'other' - ); + assert.equal(getTextOf(rootElement.querySelector('.sidebar .index')), 'other'); run(router, 'send', 'disconnect'); - assert.equal( - getTextOf(rootElement.querySelector('.sidebar .index')), - '' - ); + assert.equal(getTextOf(rootElement.querySelector('.sidebar .index')), ''); }); } @@ -4540,10 +4134,7 @@ moduleFor( }, /Please refactor [\w\{\}"` ]+ to a component/); expectDeprecation(() => { - this.addTemplate( - 'sidebar', - '' - ); + this.addTemplate('sidebar', ''); }, /Please refactor [\w\{\}"` ]+ to a component/); this.router.map(function() { this.route('index', { path: '/' }); @@ -4562,11 +4153,11 @@ moduleFor( changeToBaz() { this.disconnectOutlet({ parentView: 'cart', - outlet: 'main' + outlet: 'main', }); this.render('baz', { into: 'cart' }); - } - } + }, + }, }) ); @@ -4589,10 +4180,7 @@ moduleFor( }, /Please refactor [\w\{\}"` ]+ to a component/); expectDeprecation(() => { - this.addTemplate( - 'sidebar', - '' - ); + this.addTemplate('sidebar', ''); }, /Please refactor [\w\{\}"` ]+ to a component/); this.router.map(function() { this.route('index', { path: '/' }); @@ -4610,10 +4198,10 @@ moduleFor( disconnect() { this.disconnectOutlet({ parentView: 'cart', - outlet: 'main' + outlet: 'main', }); - } - } + }, + }, }) ); @@ -4645,7 +4233,7 @@ moduleFor( this.add( 'controller:index', Controller.extend({ - showFirst: true + showFirst: true, }) ); @@ -4654,7 +4242,7 @@ moduleFor( Route.extend({ setupController(controller) { indexController = controller; - } + }, }) ); @@ -4663,7 +4251,7 @@ moduleFor( Component.extend({ didInsertElement() { myComponentCounter++; - } + }, }) ); @@ -4672,7 +4260,7 @@ moduleFor( Component.extend({ didInsertElement() { otherComponentCounter++; - } + }, }) ); @@ -4720,8 +4308,8 @@ moduleFor( actions: { willTransition() { throw new Error('boom'); - } - } + }, + }, }) ); @@ -4744,16 +4332,16 @@ moduleFor( showModal() { this.render({ outlet: undefined, - parentView: 'application' + parentView: 'application', }); }, hideModal() { this.disconnectOutlet({ outlet: undefined, - parentView: 'application' + parentView: 'application', }); - } - } + }, + }, }) ); @@ -4780,13 +4368,13 @@ moduleFor( let postSerialize = function(params) { assert.ok(true, 'serialize hook runs'); return { - post_id: params.id + post_id: params.id, }; }; let BlogMap = function() { this.route('post', { path: '/post/:post_id', - serialize: postSerialize + serialize: postSerialize, }); }; this.add('route-map:blog', BlogMap); @@ -4805,9 +4393,7 @@ moduleFor( }); } - ['@test Defining a Route#serialize method in an Engine throws an error']( - assert - ) { + ['@test Defining a Route#serialize method in an Engine throws an error'](assert) { assert.expect(1); // Register engine @@ -4827,9 +4413,7 @@ moduleFor( return this.visit('/').then(() => { let router = this.applicationInstance.lookup('router:main'); let PostRoute = Route.extend({ serialize() {} }); - this.applicationInstance - .lookup('engine:blog') - .register('route:post', PostRoute); + this.applicationInstance.lookup('engine:blog').register('route:post', PostRoute); assert.throws( () => router.transitionTo('blog.post'), @@ -4838,9 +4422,7 @@ moduleFor( }); } - ['@test App.destroy does not leave undestroyed views after clearing engines']( - assert - ) { + ['@test App.destroy does not leave undestroyed views after clearing engines'](assert) { assert.expect(4); let engineInstance; @@ -4851,7 +4433,7 @@ moduleFor( init() { this._super(...arguments); engineInstance = getOwner(this); - } + }, }); // Register engine route map @@ -4877,31 +4459,17 @@ moduleFor( let router = this.applicationInstance.lookup('router:main'); run(router, 'destroy'); - assert.equal( - router._toplevelView, - null, - 'the toplevelView was cleared' - ); + assert.equal(router._toplevelView, null, 'the toplevelView was cleared'); run(route, 'destroy'); - assert.equal( - router._toplevelView, - null, - 'the toplevelView was not reinitialized' - ); + assert.equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); run(this.applicationInstance, 'destroy'); - assert.equal( - router._toplevelView, - null, - 'the toplevelView was not reinitialized' - ); + assert.equal(router._toplevelView, null, 'the toplevelView was not reinitialized'); }); } - ["@test Generated route should be an instance of App's default route if provided"]( - assert - ) { + ["@test Generated route should be an instance of App's default route if provided"](assert) { let generatedRoute; this.router.map(function() { @@ -4914,10 +4482,7 @@ moduleFor( return this.visit('/posts').then(() => { generatedRoute = this.applicationInstance.lookup('route:posts'); - assert.ok( - generatedRoute instanceof AppRoute, - 'should extend the correct route' - ); + assert.ok(generatedRoute instanceof AppRoute, 'should extend the correct route'); }); } } diff --git a/packages/ember/tests/routing/query_params_test.js b/packages/ember/tests/routing/query_params_test.js index 02bfb41ee0a..c919b6009e0 100644 --- a/packages/ember/tests/routing/query_params_test.js +++ b/packages/ember/tests/routing/query_params_test.js @@ -3,16 +3,12 @@ import { RSVP, Object as EmberObject, A as emberA, - String as StringUtils + String as StringUtils, } from 'ember-runtime'; import { run, get, computed, peekMeta } from 'ember-metal'; import { Route } from 'ember-routing'; -import { - QueryParamTestCase, - moduleFor, - getTextOf -} from 'internal-test-helpers'; +import { QueryParamTestCase, moduleFor, getTextOf } from 'internal-test-helpers'; moduleFor( 'Query Params - main', @@ -30,34 +26,33 @@ moduleFor( Route.extend({ queryParams: { appomg: { - defaultValue: 'applol' - } + defaultValue: 'applol', + }, }, model(/* params */) { appModelCount++; - } + }, }) ); this.setSingleQPController('index', 'omg', undefined, { - omg: undefined + omg: undefined, }); - let actionName = - typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore'; + let actionName = typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore'; let indexModelCount = 0; this.add( 'route:index', Route.extend({ queryParams: { omg: { - refreshModel: true - } + refreshModel: true, + }, }, actions: { [actionName]: function() { return loadingReturn; - } + }, }, model(params) { indexModelCount++; @@ -74,7 +69,7 @@ moduleFor( "Model hook reruns even if the previous one didn't finish" ); } - } + }, }) ); @@ -96,17 +91,11 @@ moduleFor( promiseResolve(); }); - assert.equal( - get(indexController, 'omg'), - 'hello', - 'At the end last value prevails' - ); + assert.equal(get(indexController, 'omg'), 'hello', 'At the end last value prevails'); }); } - ["@test No replaceURL occurs on startup because default values don't show up in URL"]( - assert - ) { + ["@test No replaceURL occurs on startup because default values don't show up in URL"](assert) { assert.expect(1); this.setSingleQPController('index'); @@ -131,7 +120,7 @@ moduleFor( Route.extend({ afterModel() { this.transitionTo('parent.sibling'); - } + }, }) ); @@ -150,9 +139,7 @@ moduleFor( }); } - ['@test Single query params can be set on the controller and reflected in the url']( - assert - ) { + ['@test Single query params can be set on the controller and reflected in the url'](assert) { assert.expect(3); this.router.map(function() { @@ -172,9 +159,7 @@ moduleFor( }); } - ['@test Query params can map to different url keys configured on the controller']( - assert - ) { + ['@test Query params can map to different url keys configured on the controller'](assert) { assert.expect(6); this.add( @@ -182,7 +167,7 @@ moduleFor( Controller.extend({ queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }], foo: 'FOO', - bar: 'BAR' + bar: 'BAR', }) ); @@ -190,47 +175,29 @@ moduleFor( let controller = this.getController('index'); this.setAndFlush(controller, 'foo', 'LEX'); - this.assertCurrentPath( - '/?other_foo=LEX', - "QP mapped correctly without 'as'" - ); + this.assertCurrentPath('/?other_foo=LEX', "QP mapped correctly without 'as'"); this.setAndFlush(controller, 'foo', 'WOO'); - this.assertCurrentPath( - '/?other_foo=WOO', - "QP updated correctly without 'as'" - ); + this.assertCurrentPath('/?other_foo=WOO', "QP updated correctly without 'as'"); this.transitionTo('/?other_foo=NAW'); - assert.equal( - controller.get('foo'), - 'NAW', - 'QP managed correctly on URL transition' - ); + assert.equal(controller.get('foo'), 'NAW', 'QP managed correctly on URL transition'); this.setAndFlush(controller, 'bar', 'NERK'); - this.assertCurrentPath( - '/?other_bar=NERK&other_foo=NAW', - "QP mapped correctly with 'as'" - ); + this.assertCurrentPath('/?other_bar=NERK&other_foo=NAW', "QP mapped correctly with 'as'"); this.setAndFlush(controller, 'bar', 'NUKE'); - this.assertCurrentPath( - '/?other_bar=NUKE&other_foo=NAW', - "QP updated correctly with 'as'" - ); + this.assertCurrentPath('/?other_bar=NUKE&other_foo=NAW', "QP updated correctly with 'as'"); }); } - ['@test Routes have a private overridable serializeQueryParamKey hook']( - assert - ) { + ['@test Routes have a private overridable serializeQueryParamKey hook'](assert) { assert.expect(2); this.add( 'route:index', Route.extend({ - serializeQueryParamKey: StringUtils.dasherize + serializeQueryParamKey: StringUtils.dasherize, }) ); @@ -253,7 +220,7 @@ moduleFor( queryParams: computed(function() { return ['c']; }), - c: true + c: true, }); return this.visitAndAssert('/').then(() => { @@ -267,14 +234,12 @@ moduleFor( }); } - ['@test Can concatenate inherited QP behavior by specifying queryParams as an array']( - assert - ) { + ['@test Can concatenate inherited QP behavior by specifying queryParams as an array'](assert) { assert.expect(3); this.setSingleQPController('index', 'a', 0, { queryParams: ['c'], - c: true + c: true, }); return this.visitAndAssert('/').then(() => { @@ -298,16 +263,14 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { foo: 'bar' }); - } + }, }) ); return this.visitAndAssert('/'); } - ['@test model hooks receives query params with dynamic segment params']( - assert - ) { + ['@test model hooks receives query params with dynamic segment params'](assert) { assert.expect(2); this.router.map(function() { @@ -321,16 +284,14 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { foo: 'bar', id: 'baz' }); - } + }, }) ); return this.visitAndAssert('/baz'); } - ['@test model hooks receives query params (overridden by incoming url value)']( - assert - ) { + ['@test model hooks receives query params (overridden by incoming url value)'](assert) { assert.expect(2); this.router.map(function() { @@ -344,16 +305,14 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { foo: 'baz', id: 'boo' }); - } + }, }) ); return this.visitAndAssert('/boo?foo=baz'); } - ['@test error is thrown if dynamic segment and query param have same name']( - assert - ) { + ['@test error is thrown if dynamic segment and query param have same name'](assert) { assert.expect(1); this.router.map(function() { @@ -367,9 +326,7 @@ moduleFor( }, `The route 'index' has both a dynamic segment and query param with name 'foo'. Please rename one to avoid collisions.`); } - ['@test query params have been set by the time setupController is called']( - assert - ) { + ['@test query params have been set by the time setupController is called'](assert) { assert.expect(2); this.setSingleQPController('application'); @@ -383,16 +340,14 @@ moduleFor( 'YEAH', "controller's foo QP property set before setupController called" ); - } + }, }) ); return this.visitAndAssert('/?foo=YEAH'); } - ['@test mapped query params have been set by the time setupController is called']( - assert - ) { + ['@test mapped query params have been set by the time setupController is called'](assert) { assert.expect(2); this.setSingleQPController('application', { faz: 'foo' }); @@ -406,7 +361,7 @@ moduleFor( 'YEAH', "controller's foo QP property set before setupController called" ); - } + }, }) ); @@ -431,16 +386,14 @@ moduleFor( { something: 'baz', foo: 'bar' }, 'could retrieve params for index' ); - } + }, }) ); return this.visitAndAssert('/baz'); } - ['@test Route#paramsFor fetches query params with non-default value']( - assert - ) { + ['@test Route#paramsFor fetches query params with non-default value'](assert) { assert.expect(2); this.router.map(function() { @@ -458,7 +411,7 @@ moduleFor( { something: 'baz', foo: 'boo' }, 'could retrieve params for index' ); - } + }, }) ); @@ -483,7 +436,7 @@ moduleFor( { something: 'baz', foo: false }, 'could retrieve params for index' ); - } + }, }) ); @@ -508,7 +461,7 @@ moduleFor( { something: 'baz', foo: false }, 'could retrieve params for index' ); - } + }, }) ); @@ -526,7 +479,7 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { appomg: 'applol' }); - } + }, }) ); @@ -536,9 +489,9 @@ moduleFor( model(params) { assert.deepEqual(params, { omg: 'lol' }); assert.deepEqual(this.paramsFor('application'), { - appomg: 'applol' + appomg: 'applol', }); - } + }, }) ); @@ -558,7 +511,7 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { appomg: 'appyes' }); - } + }, }) ); @@ -568,18 +521,16 @@ moduleFor( model(params) { assert.deepEqual(params, { omg: 'yes' }); assert.deepEqual(this.paramsFor('application'), { - appomg: 'appyes' + appomg: 'appyes', }); - } + }, }) ); return this.visitAndAssert('/?appomg=appyes&omg=yes'); } - ['@test can opt into full transition by setting refreshModel in route queryParams']( - assert - ) { + ['@test can opt into full transition by setting refreshModel in route queryParams'](assert) { assert.expect(7); this.setSingleQPController('application', 'appomg', 'applol'); @@ -591,7 +542,7 @@ moduleFor( Route.extend({ model(/* params, transition */) { appModelCount++; - } + }, }) ); @@ -601,26 +552,18 @@ moduleFor( Route.extend({ queryParams: { omg: { - refreshModel: true - } + refreshModel: true, + }, }, model(params) { indexModelCount++; if (indexModelCount === 1) { - assert.deepEqual( - params, - { omg: 'lol' }, - 'params are correct on first pass' - ); + assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass'); } else if (indexModelCount === 2) { - assert.deepEqual( - params, - { omg: 'lex' }, - 'params are correct on second pass' - ); + assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass'); } - } + }, }) ); @@ -632,11 +575,7 @@ moduleFor( this.setAndFlush(indexController, 'omg', 'lex'); assert.equal(appModelCount, 1, 'app model hook did not run again'); - assert.equal( - indexModelCount, - 2, - 'index model hook ran again due to refreshModel' - ); + assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel'); }); } @@ -652,7 +591,7 @@ moduleFor( Route.extend({ model(/* params */) { appModelCount++; - } + }, }) ); @@ -663,26 +602,18 @@ moduleFor( queryParams: { omg: { refreshModel: true, - replace: true - } + replace: true, + }, }, model(params) { indexModelCount++; if (indexModelCount === 1) { - assert.deepEqual( - params, - { omg: 'lol' }, - 'params are correct on first pass' - ); + assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass'); } else if (indexModelCount === 2) { - assert.deepEqual( - params, - { omg: 'lex' }, - 'params are correct on second pass' - ); + assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass'); } - } + }, }) ); @@ -695,17 +626,11 @@ moduleFor( this.setAndFlush(indexController, 'omg', 'lex'); assert.equal(appModelCount, 1, 'app model hook did not run again'); - assert.equal( - indexModelCount, - 2, - 'index model hook ran again due to refreshModel' - ); + assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel'); }); } - ['@test multiple QP value changes only cause a single model refresh']( - assert - ) { + ['@test multiple QP value changes only cause a single model refresh'](assert) { assert.expect(2); this.setSingleQPController('index', 'alex', 'lol'); @@ -717,15 +642,15 @@ moduleFor( Route.extend({ queryParams: { alex: { - refreshModel: true + refreshModel: true, }, steely: { - refreshModel: true - } + refreshModel: true, + }, }, refresh() { refreshCount++; - } + }, }) ); @@ -733,15 +658,13 @@ moduleFor( let indexController = this.getController('index'); run(indexController, 'setProperties', { alex: 'fran', - steely: 'david' + steely: 'david', }); assert.equal(refreshCount, 1, 'index refresh hook only run once'); }); } - ['@test refreshModel does not cause a second transition during app boot ']( - assert - ) { + ['@test refreshModel does not cause a second transition during app boot '](assert) { assert.expect(1); this.setSingleQPController('application', 'appomg', 'applol'); @@ -752,12 +675,12 @@ moduleFor( Route.extend({ queryParams: { omg: { - refreshModel: true - } + refreshModel: true, + }, }, refresh() { assert.ok(false); - } + }, }) ); @@ -777,8 +700,8 @@ moduleFor( increment() { this.incrementProperty('foo'); this.send('refreshRoute'); - } - } + }, + }, }); this.add( @@ -787,8 +710,8 @@ moduleFor( actions: { refreshRoute() { this.refresh(); - } - } + }, + }, }) ); @@ -805,9 +728,7 @@ moduleFor( }); } - ["@test Use Ember.get to retrieve query params 'refreshModel' configuration"]( - assert - ) { + ["@test Use Ember.get to retrieve query params 'refreshModel' configuration"](assert) { assert.expect(7); this.setSingleQPController('application', 'appomg', 'applol'); @@ -819,7 +740,7 @@ moduleFor( Route.extend({ model(/* params */) { appModelCount++; - } + }, }) ); @@ -830,7 +751,7 @@ moduleFor( queryParams: EmberObject.create({ unknownProperty() { return { refreshModel: true }; - } + }, }), model(params) { indexModelCount++; @@ -840,7 +761,7 @@ moduleFor( } else if (indexModelCount === 2) { assert.deepEqual(params, { omg: 'lex' }); } - } + }, }) ); @@ -856,9 +777,7 @@ moduleFor( }); } - ['@test can use refreshModel even with URL changes that remove QPs from address bar']( - assert - ) { + ['@test can use refreshModel even with URL changes that remove QPs from address bar'](assert) { assert.expect(4); this.setSingleQPController('index', 'omg', 'lol'); @@ -869,8 +788,8 @@ moduleFor( Route.extend({ queryParams: { omg: { - refreshModel: true - } + refreshModel: true, + }, }, model(params) { indexModelCount++; @@ -882,12 +801,8 @@ moduleFor( data = 'lol'; } - assert.deepEqual( - params, - { omg: data }, - 'index#model receives right data' - ); - } + assert.deepEqual(params, { omg: data }, 'index#model receives right data'); + }, }) ); @@ -911,9 +826,9 @@ moduleFor( Route.extend({ queryParams: { alex: { - replace: true - } - } + replace: true, + }, + }, }) ); @@ -932,7 +847,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - queryParams: [{ commitBy: 'commit_by' }] + queryParams: [{ commitBy: 'commit_by' }], }) ); @@ -941,9 +856,9 @@ moduleFor( Route.extend({ queryParams: { commitBy: { - replace: true - } - } + replace: true, + }, + }, }) ); @@ -954,9 +869,7 @@ moduleFor( }); } - ['@test An explicit replace:false on a changed QP always wins and causes a pushState']( - assert - ) { + ['@test An explicit replace:false on a changed QP always wins and causes a pushState'](assert) { assert.expect(3); this.add( @@ -964,7 +877,7 @@ moduleFor( Controller.extend({ queryParams: ['alex', 'steely'], alex: 'matchneer', - steely: 'dan' + steely: 'dan', }) ); @@ -973,12 +886,12 @@ moduleFor( Route.extend({ queryParams: { alex: { - replace: true + replace: true, }, steely: { - replace: false - } - } + replace: false, + }, + }, }) ); @@ -1019,9 +932,9 @@ moduleFor( }, queryParams: { foo: { - refreshModel: true - } - } + refreshModel: true, + }, + }, }) ); @@ -1035,9 +948,7 @@ moduleFor( }); } - ["@test Use Ember.get to retrieve query params 'replace' configuration"]( - assert - ) { + ["@test Use Ember.get to retrieve query params 'replace' configuration"](assert) { assert.expect(2); this.setSingleQPController('application', 'alex', 'matchneer'); @@ -1049,8 +960,8 @@ moduleFor( unknownProperty(/* keyName */) { // We are simulating all qps requiring refresh return { replace: true }; - } - }) + }, + }), }) ); @@ -1080,8 +991,8 @@ moduleFor( actions: { queryParamsDidChange() { assert.ok(false, "queryParamsDidChange shouldn't fire"); - } - } + }, + }, }) ); @@ -1110,22 +1021,18 @@ moduleFor( actions: { queryParamsDidChange() { assert.ok(false, "queryParamsDidChange shouldn't fire"); - } - } + }, + }, }) ); return this.visitAndAssert('/about').then(() => { this.transitionTo('index'); - this.assertCurrentPath( - '/?omg=' + encodeURIComponent(JSON.stringify(['OVERRIDE'])) - ); + this.assertCurrentPath('/?omg=' + encodeURIComponent(JSON.stringify(['OVERRIDE']))); }); } - ['@test URL transitions that remove QPs still register as QP changes']( - assert - ) { + ['@test URL transitions that remove QPs still register as QP changes'](assert) { assert.expect(2); this.setSingleQPController('index', 'omg', 'lol'); @@ -1158,10 +1065,7 @@ moduleFor( return this.visitAndAssert('/').then(() => { assert.equal(this.$('#one').attr('href'), '/abcdef?foo=123'); - assert.equal( - this.$('#two').attr('href'), - '/abcdef/zoo?bar=456&foo=123' - ); + assert.equal(this.$('#two').attr('href'), '/abcdef/zoo?bar=456&foo=123'); run(this.$('#one'), 'click'); this.assertCurrentPath('/abcdef?foo=123'); @@ -1195,7 +1099,7 @@ moduleFor( Controller.extend({ queryParams: ['foo', 'bar'], foo: 'lol', - bar: 'wat' + bar: 'wat', }) ); @@ -1214,9 +1118,7 @@ moduleFor( }); } - ["@test setting controller QP to empty string doesn't generate null in URL"]( - assert - ) { + ["@test setting controller QP to empty string doesn't generate null in URL"](assert) { assert.expect(1); this.setSingleQPController('index', 'foo', '123'); @@ -1237,9 +1139,9 @@ moduleFor( Route.extend({ queryParams: { foo: { - defaultValue: '123' - } - } + defaultValue: '123', + }, + }, }) ); @@ -1251,9 +1153,7 @@ moduleFor( }); } - ['@test A default boolean value deserializes QPs as booleans rather than strings']( - assert - ) { + ['@test A default boolean value deserializes QPs as booleans rather than strings'](assert) { assert.expect(3); this.setSingleQPController('index', 'foo', false); @@ -1262,12 +1162,8 @@ moduleFor( 'route:index', Route.extend({ model(params) { - assert.equal( - params.foo, - true, - 'model hook received foo as boolean true' - ); - } + assert.equal(params.foo, true, 'model hook received foo as boolean true'); + }, }) ); @@ -1287,7 +1183,7 @@ moduleFor( 'controller:index', Controller.extend({ queryParams: ['foo'], - foo: '' + foo: '', }) ); @@ -1332,9 +1228,7 @@ moduleFor( }); } - ['@test Url with array query param sets controller property to array']( - assert - ) { + ['@test Url with array query param sets controller property to array'](assert) { assert.expect(1); this.setSingleQPController('index', 'foo', ''); @@ -1391,9 +1285,7 @@ moduleFor( }); } - ["@test Overwriting with array with same content shouldn't refire update"]( - assert - ) { + ["@test Overwriting with array with same content shouldn't refire update"](assert) { assert.expect(4); this.router.map(function() { @@ -1406,7 +1298,7 @@ moduleFor( Route.extend({ model() { modelCount++; - } + }, }) ); @@ -1443,11 +1335,8 @@ moduleFor( Route.extend({ model(p, trans) { let m = peekMeta(trans.params.application); - assert.ok( - m === undefined, - "A meta object isn't constructed for this params POJO" - ); - } + assert.ok(m === undefined, "A meta object isn't constructed for this params POJO"); + }, }) ); @@ -1492,9 +1381,7 @@ moduleFor( }); } - ['@test {{link-to}} with null or undefined QPs does not get serialized into url']( - assert - ) { + ['@test {{link-to}} with null or undefined QPs does not get serialized into url'](assert) { assert.expect(3); this.addTemplate( @@ -1508,7 +1395,7 @@ moduleFor( this.setSingleQPController('home', 'foo', [], { nullValue: null, - undefinedValue: undefined + undefinedValue: undefined, }); return this.visitAndAssert('/home').then(() => { @@ -1523,7 +1410,7 @@ moduleFor( assert.expect(2); this.setSingleQPController('index', 'woot', undefined, { - woot: undefined + woot: undefined, }); this.add( @@ -1531,7 +1418,7 @@ moduleFor( Route.extend({ model(/* p, trans */) { return { woot: true }; - } + }, }) ); @@ -1544,16 +1431,14 @@ moduleFor( { woot: true }, 'index route inherited model route from parent route' ); - } + }, }) ); return this.visitAndAssert('/'); } - ['@test opting into replace does not affect transitions between routes']( - assert - ) { + ['@test opting into replace does not affect transitions between routes'](assert) { assert.expect(5); this.addTemplate( @@ -1573,9 +1458,9 @@ moduleFor( Route.extend({ queryParams: { raytiley: { - replace: true - } - } + replace: true, + }, + }, }) ); @@ -1612,7 +1497,7 @@ moduleFor( ); this.setSingleQPController('example', 'foo', undefined, { - foo: undefined + foo: undefined, }); this.add( @@ -1620,7 +1505,7 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { foo: undefined }); - } + }, }) ); @@ -1632,7 +1517,7 @@ moduleFor( ); return this.transitionTo('example', { - queryParams: { foo: undefined } + queryParams: { foo: undefined }, }).then(() => { this.assertCurrentPath('/example'); }); @@ -1659,7 +1544,7 @@ moduleFor( this.add( 'route:application', Route.extend({ - queryParams: [{ commitBy: { replace: true } }] + queryParams: [{ commitBy: { replace: true } }], }) ); @@ -1668,9 +1553,7 @@ moduleFor( }, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array'); } - ['@test handle route names that clash with Object.prototype properties']( - assert - ) { + ['@test handle route names that clash with Object.prototype properties'](assert) { assert.expect(1); this.router.map(function() { @@ -1682,9 +1565,9 @@ moduleFor( Route.extend({ queryParams: { foo: { - defaultValue: '123' - } - } + defaultValue: '123', + }, + }, }) ); diff --git a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js index 51e0168fb8a..81624cede5f 100644 --- a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js +++ b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js @@ -88,10 +88,7 @@ class ModelDependentQPTestCase extends QueryParamTestCase { assert.equal(this.controller.get('z'), 123); assert.equal(this.$link1.getAttribute('href'), `${urlPrefix}/a-1?q=lol`); assert.equal(this.$link2.getAttribute('href'), `${urlPrefix}/a-2?q=lol`); - assert.equal( - this.$link3.getAttribute('href'), - `${urlPrefix}/a-3?q=lol&z=123` - ); + assert.equal(this.$link3.getAttribute('href'), `${urlPrefix}/a-3?q=lol&z=123`); }); } @@ -143,10 +140,7 @@ class ModelDependentQPTestCase extends QueryParamTestCase { assert.equal(this.controller.get('q'), 'lol'); assert.equal(this.controller.get('z'), 1); assert.equal(this.$link1.getAttribute('href'), `${urlPrefix}/a-1`); - assert.equal( - this.$link2.getAttribute('href'), - `${urlPrefix}/a-2?q=lol&z=1` - ); + assert.equal(this.$link2.getAttribute('href'), `${urlPrefix}/a-2?q=lol&z=1`); assert.equal(this.$link3.getAttribute('href'), `${urlPrefix}/a-3?q=hay`); }); } @@ -159,7 +153,7 @@ class ModelDependentQPTestCase extends QueryParamTestCase { this.setupApplication(); this.reopenController(articleLookup, { - queryParams: { q: { scope: 'controller' } } + queryParams: { q: { scope: 'controller' } }, }); return this.visitApplication().then(() => { @@ -191,19 +185,13 @@ class ModelDependentQPTestCase extends QueryParamTestCase { assert.equal(this.$link1.getAttribute('href'), `${urlPrefix}/a-1?q=haha`); assert.equal(this.$link2.getAttribute('href'), `${urlPrefix}/a-2?q=haha`); - assert.equal( - this.$link3.getAttribute('href'), - `${urlPrefix}/a-3?q=haha&z=123` - ); + assert.equal(this.$link3.getAttribute('href'), `${urlPrefix}/a-3?q=haha&z=123`); this.setAndFlush(this.controller, 'q', 'woot'); assert.equal(this.$link1.getAttribute('href'), `${urlPrefix}/a-1?q=woot`); assert.equal(this.$link2.getAttribute('href'), `${urlPrefix}/a-2?q=woot`); - assert.equal( - this.$link3.getAttribute('href'), - `${urlPrefix}/a-3?q=woot&z=123` - ); + assert.equal(this.$link3.getAttribute('href'), `${urlPrefix}/a-3?q=woot&z=123`); }); } @@ -248,7 +236,7 @@ class ModelDependentQPTestCase extends QueryParamTestCase { if (isExiting) { controller.set('q', 'imdone'); } - } + }, }); this.addTemplate( @@ -304,7 +292,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - articles + articles, }) ); @@ -323,7 +311,7 @@ moduleFor( self.expectedModelHookParams = null; } return articles.findBy('id', params.id); - } + }, }) ); @@ -332,7 +320,7 @@ moduleFor( Controller.extend({ queryParams: ['q', 'z'], q: 'wat', - z: 0 + z: 0, }) ); @@ -340,7 +328,7 @@ moduleFor( 'controller:comments', Controller.extend({ queryParams: 'page', - page: 1 + page: 1, }) ); @@ -410,7 +398,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - articles: site_articles + articles: site_articles, }) ); @@ -429,7 +417,7 @@ moduleFor( self.expectedModelHookParams = null; } return site_articles.findBy('id', params.id); - } + }, }) ); @@ -438,7 +426,7 @@ moduleFor( Controller.extend({ queryParams: ['q', 'z'], q: 'wat', - z: 0 + z: 0, }) ); @@ -446,7 +434,7 @@ moduleFor( 'controller:site.article.comments', Controller.extend({ queryParams: 'page', - page: 1 + page: 1, }) ); @@ -493,11 +481,7 @@ moduleFor( } ['@test can reset query params using the resetController hook']() { - return this.queryParamsStickyTest6( - '/site/a', - 'site.article', - 'site.article.comments' - ); + return this.queryParamsStickyTest6('/site/a', 'site.article', 'site.article.comments'); } } ); @@ -533,14 +517,14 @@ moduleFor( return { id: `${site.id}-${article.id}`, site_id: site.id, - article_id: article.id + article_id: article.id, }; }) ); }); return ret; - } - }) + }, + }), }) ); @@ -559,7 +543,7 @@ moduleFor( self.expectedSiteModelHookParams = null; } return sites.findBy('id', params.site_id); - } + }, }) ); @@ -576,7 +560,7 @@ moduleFor( self.expectedArticleModelHookParams = null; } return site_articles.findBy('id', params.article_id); - } + }, }) ); @@ -584,7 +568,7 @@ moduleFor( 'controller:site', Controller.extend({ queryParams: ['country'], - country: 'au' + country: 'au', }) ); @@ -593,7 +577,7 @@ moduleFor( Controller.extend({ queryParams: ['q', 'z'], q: 'wat', - z: 0 + z: 0, }) ); @@ -601,7 +585,7 @@ moduleFor( 'controller:site.article.comments', Controller.extend({ queryParams: ['page'], - page: 1 + page: 1, }) ); @@ -626,42 +610,15 @@ moduleFor( this.links['s-3-a-2'] = document.getElementById('s-3-a-2'); this.links['s-3-a-3'] = document.getElementById('s-3-a-3'); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.site_controller = this.getController('site'); this.article_controller = this.getController('site.article'); @@ -679,42 +636,15 @@ moduleFor( this.setAndFlush(this.article_controller, 'q', 'lol'); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?q=lol' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.setAndFlush(this.site_controller, 'country', 'us'); @@ -722,38 +652,14 @@ moduleFor( this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?country=us&q=lol' ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?country=us' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?country=us' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?q=lol' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); run(this.links['s-1-a-2'], 'click'); @@ -766,38 +672,14 @@ moduleFor( this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?country=us&q=lol' ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?country=us' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?country=us' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?q=lol' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); run(this.links['s-2-a-2'], 'click'); @@ -810,44 +692,18 @@ moduleFor( this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?country=us&q=lol' ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?country=us' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?country=us' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?q=lol' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?country=us'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?country=us'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); }); } - ["@test query params have 'model' stickiness by default (url changes)"]( - assert - ) { + ["@test query params have 'model' stickiness by default (url changes)"](assert) { assert.expect(88); return this.boot().then(() => { @@ -855,7 +711,7 @@ moduleFor( this.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', - z: 0 + z: 0, }; this.transitionTo('/site/s-1/a/a-1?q=lol'); @@ -872,48 +728,21 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'au'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?q=lol' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?q=lol'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; this.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', - z: 0 + z: 0, }; this.transitionTo('/site/s-2/a/a-1?country=us&q=lol'); @@ -930,48 +759,24 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'us'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=lol' ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2?country=us' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3?country=us' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?country=us'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; this.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', - z: 0 + z: 0, }; this.transitionTo('/site/s-2/a/a-2?country=us&q=lol'); @@ -988,18 +793,9 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'us'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=lol' @@ -1008,28 +804,16 @@ moduleFor( this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?country=us&q=lol' ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3?country=us' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?country=us'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; this.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', - z: 123 + z: 123, }; this.transitionTo('/site/s-2/a/a-3?country=us&q=lol&z=123'); @@ -1046,18 +830,9 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'us'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 123); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=lol&z=123' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=lol&z=123'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=lol' @@ -1070,24 +845,15 @@ moduleFor( this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123' ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=lol' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3?q=lol&z=123' - ); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=lol'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3?q=lol&z=123'); this.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; this.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', - z: 123 + z: 123, }; this.transitionTo('/site/s-3/a/a-3?country=nz&q=lol&z=123'); @@ -1104,18 +870,9 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'nz'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 123); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=lol' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=lol&z=123' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=lol'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=lol&z=123'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=lol' @@ -1143,9 +900,7 @@ moduleFor( }); } - ["@test query params have 'model' stickiness by default (params-based transitions)"]( - assert - ) { + ["@test query params have 'model' stickiness by default (params-based transitions)"](assert) { assert.expect(118); return this.boot().then(() => { @@ -1153,7 +908,7 @@ moduleFor( this.expectedArticleModelHookParams = { article_id: 'a-1', q: 'wat', - z: 0 + z: 0, }; this.transitionTo('site.article', 's-1', 'a-1'); @@ -1162,51 +917,24 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'au'); assert.equal(this.article_controller.get('q'), 'wat'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; this.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', - z: 0 + z: 0, }; this.transitionTo('site.article', 's-1', 'a-2', { - queryParams: { q: 'lol' } + queryParams: { q: 'lol' }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-1' }); @@ -1214,51 +942,24 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'au'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2?q=lol' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3'); this.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; this.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', - z: 0 + z: 0, }; this.transitionTo('site.article', 's-1', 'a-3', { - queryParams: { q: 'hay' } + queryParams: { q: 'hay' }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-1' }); @@ -1266,51 +967,24 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'au'); assert.equal(this.article_controller.get('q'), 'hay'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=hay' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2?q=lol' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3?q=hay' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3?q=hay' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?q=lol'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3?q=hay'); this.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' }; this.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', - z: 1 + z: 1, }; this.transitionTo('site.article', 's-1', 'a-2', { - queryParams: { z: 1 } + queryParams: { z: 1 }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-1' }); @@ -1318,51 +992,24 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'au'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 1); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=hay' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1' - ); - assert.equal( - this.links['s-2-a-2'].getAttribute('href'), - '/site/s-2/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-2-a-3'].getAttribute('href'), - '/site/s-2/a/a-3?q=hay' - ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3?q=hay' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1'); + assert.equal(this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?q=hay'); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3?q=hay'); this.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; this.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', - z: 1 + z: 1, }; this.transitionTo('site.article', 's-2', 'a-2', { - queryParams: { country: 'us' } + queryParams: { country: 'us' }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-2' }); @@ -1370,22 +1017,10 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'us'); assert.equal(this.article_controller.get('q'), 'lol'); assert.equal(this.article_controller.get('z'), 1); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=hay' - ); - assert.equal( - this.links['s-2-a-1'].getAttribute('href'), - '/site/s-2/a/a-1?country=us' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=hay'); + assert.equal(this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us'); assert.equal( this.links['s-2-a-2'].getAttribute('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1' @@ -1394,27 +1029,18 @@ moduleFor( this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?country=us&q=hay' ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3?q=hay' - ); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3?q=hay'); this.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' }; this.expectedArticleModelHookParams = { article_id: 'a-1', q: 'yeah', - z: 0 + z: 0, }; this.transitionTo('site.article', 's-2', 'a-1', { - queryParams: { q: 'yeah' } + queryParams: { q: 'yeah' }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-2' }); @@ -1422,18 +1048,9 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'us'); assert.equal(this.article_controller.get('q'), 'yeah'); assert.equal(this.article_controller.get('z'), 0); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=yeah' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=hay' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=hay'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=yeah' @@ -1446,27 +1063,18 @@ moduleFor( this.links['s-2-a-3'].getAttribute('href'), '/site/s-2/a/a-3?country=us&q=hay' ); - assert.equal( - this.links['s-3-a-1'].getAttribute('href'), - '/site/s-3/a/a-1?q=yeah' - ); - assert.equal( - this.links['s-3-a-2'].getAttribute('href'), - '/site/s-3/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-3-a-3'].getAttribute('href'), - '/site/s-3/a/a-3?q=hay' - ); + assert.equal(this.links['s-3-a-1'].getAttribute('href'), '/site/s-3/a/a-1?q=yeah'); + assert.equal(this.links['s-3-a-2'].getAttribute('href'), '/site/s-3/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-3-a-3'].getAttribute('href'), '/site/s-3/a/a-3?q=hay'); this.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' }; this.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', - z: 3 + z: 3, }; this.transitionTo('site.article', 's-3', 'a-3', { - queryParams: { country: 'nz', z: 3 } + queryParams: { country: 'nz', z: 3 }, }); assert.deepEqual(this.site_controller.get('model'), { id: 's-3' }); @@ -1474,18 +1082,9 @@ moduleFor( assert.equal(this.site_controller.get('country'), 'nz'); assert.equal(this.article_controller.get('q'), 'hay'); assert.equal(this.article_controller.get('z'), 3); - assert.equal( - this.links['s-1-a-1'].getAttribute('href'), - '/site/s-1/a/a-1?q=yeah' - ); - assert.equal( - this.links['s-1-a-2'].getAttribute('href'), - '/site/s-1/a/a-2?q=lol&z=1' - ); - assert.equal( - this.links['s-1-a-3'].getAttribute('href'), - '/site/s-1/a/a-3?q=hay&z=3' - ); + assert.equal(this.links['s-1-a-1'].getAttribute('href'), '/site/s-1/a/a-1?q=yeah'); + assert.equal(this.links['s-1-a-2'].getAttribute('href'), '/site/s-1/a/a-2?q=lol&z=1'); + assert.equal(this.links['s-1-a-3'].getAttribute('href'), '/site/s-1/a/a-3?q=hay&z=3'); assert.equal( this.links['s-2-a-1'].getAttribute('href'), '/site/s-2/a/a-1?country=us&q=yeah' diff --git a/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js b/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js index 7f69741ed02..6d331e09538 100644 --- a/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js +++ b/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js @@ -54,9 +54,7 @@ moduleFor( }); } - ['@test query params can be either controller property or url key']( - assert - ) { + ['@test query params can be either controller property or url key'](assert) { assert.expect(3); this.setMappedQPController('parent'); @@ -86,7 +84,7 @@ moduleFor( this.assertCurrentPath('/parent/child?parentPage=3'); this.transitionTo('parent.child', { - queryParams: { index: 2, page: 2 } + queryParams: { index: 2, page: 2 }, }); this.assertCurrentPath('/parent/child?page=2&parentPage=2'); }); @@ -108,12 +106,12 @@ moduleFor( this.assertCurrentPath('/parent/child?parentPage=3'); this.transitionTo('parent.child', { - queryParams: { childPage: 2, page: 2 } + queryParams: { childPage: 2, page: 2 }, }); this.assertCurrentPath('/parent/child?childPage=2&parentPage=2'); this.transitionTo('parent.child', { - queryParams: { childPage: 3, parentPage: 4 } + queryParams: { childPage: 3, parentPage: 4 }, }); this.assertCurrentPath('/parent/child?childPage=3&parentPage=4'); }); @@ -125,13 +123,10 @@ moduleFor( assert.expect(1); let parentController = Controller.extend({ - queryParams: { page: 'page' } + queryParams: { page: 'page' }, }); this.add('controller:parent', parentController); - this.add( - 'route:parent.child', - Route.extend({ controllerName: 'parent' }) - ); + this.add('route:parent.child', Route.extend({ controllerName: 'parent' })); return this.setupBase('/parent').then(() => { this.transitionTo('parent.child', { queryParams: { page: 2 } }); @@ -156,13 +151,13 @@ moduleFor( let HasPage = Mixin.create({ queryParams: 'page', - page: 1 + page: 1, }); this.add( 'controller:parent', Controller.extend(HasPage, { - queryParams: { page: 'yespage' } + queryParams: { page: 'yespage' }, }) ); diff --git a/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js b/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js index 683b3940d67..eae622bcc69 100644 --- a/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js +++ b/packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js @@ -50,7 +50,7 @@ moduleFor( })) ); }; - } + }, }; } @@ -97,9 +97,7 @@ moduleFor( }); } - ['@test can transitionTo to an asynchronously loaded route with simple query params']( - assert - ) { + ['@test can transitionTo to an asynchronously loaded route with simple query params'](assert) { assert.expect(6); this.router.map(function() { @@ -120,7 +118,7 @@ moduleFor( }) .then(() => { return this.transitionTo('post', 1337, { - queryParams: { foo: 'boo' } + queryParams: { foo: 'boo' }, }).then(() => { assert.equal( postController.get('foo'), @@ -132,7 +130,7 @@ moduleFor( }) .then(() => { return this.transitionTo('post', 1337, { - queryParams: { foo: 'bar' } + queryParams: { foo: 'bar' }, }).then(() => { assert.equal( postController.get('foo'), @@ -144,9 +142,7 @@ moduleFor( }); } - ['@test can transitionTo to an asynchronously loaded route with array query params']( - assert - ) { + ['@test can transitionTo to an asynchronously loaded route with array query params'](assert) { assert.expect(5); this.router.map(function() { @@ -160,7 +156,7 @@ moduleFor( .then(() => { postController = this.getController('post'); return this.transitionTo('post', 1337, { - queryParams: { comments: [1, 2] } + queryParams: { comments: [1, 2] }, }).then(() => { assert.deepEqual( postController.get('comments'), @@ -182,9 +178,7 @@ moduleFor( }); } - ['@test can transitionTo to an asynchronously loaded route with mapped query params']( - assert - ) { + ['@test can transitionTo to an asynchronously loaded route with mapped query params'](assert) { assert.expect(7); this.router.map(function() { @@ -205,7 +199,7 @@ moduleFor( postIndexController = this.getController('post.index'); return this.transitionTo('post.index', 1337, { - queryParams: { note: 6, foo: 'boo' } + queryParams: { note: 6, foo: 'boo' }, }).then(() => { assert.equal( postController.get('foo'), @@ -222,7 +216,7 @@ moduleFor( }) .then(() => { return this.transitionTo('post', 1337, { - queryParams: { foo: 'bar' } + queryParams: { foo: 'bar' }, }).then(() => { assert.equal( postController.get('foo'), @@ -303,7 +297,7 @@ moduleFor( ); this.setSingleQPController('example', 'foo', undefined, { - foo: undefined + foo: undefined, }); this.add( @@ -311,7 +305,7 @@ moduleFor( Route.extend({ model(params) { assert.deepEqual(params, { foo: undefined }); - } + }, }) ); @@ -323,7 +317,7 @@ moduleFor( ); return this.transitionTo('example', { - queryParams: { foo: undefined } + queryParams: { foo: undefined }, }).then(() => { this.assertCurrentPath('/example'); }); diff --git a/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js b/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js index edf82ff6a44..e66656d18e2 100644 --- a/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js +++ b/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js @@ -7,24 +7,18 @@ moduleFor( testParamlessLinks(assert, routeName) { assert.expect(1); - this.addTemplate( - routeName, - "{{link-to 'index' 'index' id='index-link'}}" - ); + this.addTemplate(routeName, "{{link-to 'index' 'index' id='index-link'}}"); this.add( `controller:${routeName}`, Controller.extend({ queryParams: ['foo'], - foo: 'wat' + foo: 'wat', }) ); return this.visit('/?foo=YEAH').then(() => { - assert.equal( - document.getElementById('index-link').getAttribute('href'), - '/?foo=YEAH' - ); + assert.equal(document.getElementById('index-link').getAttribute('href'), '/?foo=YEAH'); }); } diff --git a/packages/ember/tests/routing/query_params_test/shared_state_test.js b/packages/ember/tests/routing/query_params_test/shared_state_test.js index 809e2e57a7b..7ed3e56c536 100644 --- a/packages/ember/tests/routing/query_params_test/shared_state_test.js +++ b/packages/ember/tests/routing/query_params_test/shared_state_test.js @@ -19,14 +19,14 @@ moduleFor( this.add( 'service:filters', Service.extend({ - shared: true + shared: true, }) ); this.add( 'controller:home', Controller.extend({ - filters: inject.service() + filters: inject.service(), }) ); @@ -34,14 +34,11 @@ moduleFor( 'controller:dashboard', Controller.extend({ filters: inject.service(), - queryParams: [{ 'filters.shared': 'shared' }] + queryParams: [{ 'filters.shared': 'shared' }], }) ); - this.addTemplate( - 'application', - `{{link-to 'Home' 'home' }}
{{outlet}}
` - ); + this.addTemplate('application', `{{link-to 'Home' 'home' }}
{{outlet}}
`); this.addTemplate( 'home', `{{link-to 'Dashboard' 'dashboard' }}{{input type="checkbox" id='filters-checkbox' checked=(mut filters.shared) }}` @@ -67,9 +64,7 @@ moduleFor( }); } - ['@test can modify shared state back to the default value before transition']( - assert - ) { + ['@test can modify shared state back to the default value before transition'](assert) { assert.expect(1); return this.boot().then(() => { diff --git a/packages/ember/tests/routing/router_service_test/basic_test.js b/packages/ember/tests/routing/router_service_test/basic_test.js index df0d7392f10..1bdb45cad7a 100644 --- a/packages/ember/tests/routing/router_service_test/basic_test.js +++ b/packages/ember/tests/routing/router_service_test/basic_test.js @@ -8,35 +8,23 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { moduleFor( 'Router Service - main', class extends RouterTestCase { - ['@test RouterService#currentRouteName is correctly set for top level route']( - assert - ) { + ['@test RouterService#currentRouteName is correctly set for top level route'](assert) { assert.expect(1); return this.visit('/').then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.index' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.index'); }); } - ['@test RouterService#currentRouteName is correctly set for child route']( - assert - ) { + ['@test RouterService#currentRouteName is correctly set for child route'](assert) { assert.expect(1); return this.visit('/child').then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.child' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.child'); }); } - ['@test RouterService#currentRouteName is correctly set after transition']( - assert - ) { + ['@test RouterService#currentRouteName is correctly set after transition'](assert) { assert.expect(1); return this.visit('/child') @@ -44,46 +32,30 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.sister'); }) .then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.sister' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); }); } - ['@test RouterService#currentRouteName is correctly set on each transition']( - assert - ) { + ['@test RouterService#currentRouteName is correctly set on each transition'](assert) { assert.expect(3); return this.visit('/child') .then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.child' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.child'); return this.visit('/sister'); }) .then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.sister' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); return this.visit('/brother'); }) .then(() => { - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.brother' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.brother'); }); } - ['@test RouterService#rootURL is correctly set to the default value']( - assert - ) { + ['@test RouterService#rootURL is correctly set to the default value'](assert) { assert.expect(1); return this.visit('/').then(() => { @@ -91,9 +63,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#rootURL is correctly set to a custom value']( - assert - ) { + ['@test RouterService#rootURL is correctly set to a custom value'](assert) { assert.expect(1); this.add( @@ -102,7 +72,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { init() { this._super(); set(this._router, 'rootURL', '/homepage'); - } + }, }) ); @@ -111,9 +81,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#location is correctly delegated from router:main']( - assert - ) { + ['@test RouterService#location is correctly delegated from router:main'](assert) { assert.expect(2); return this.visit('/').then(() => { diff --git a/packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js b/packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js index ae1ac1d0b94..96d38b60cca 100644 --- a/packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js +++ b/packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js @@ -15,30 +15,18 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { beforeModel() { let service = get(this, 'routerService'); - results.push([ - service.get('currentRouteName'), - 'beforeModel', - service.get('currentURL') - ]); + results.push([service.get('currentRouteName'), 'beforeModel', service.get('currentURL')]); }, model() { let service = get(this, 'routerService'); - results.push([ - service.get('currentRouteName'), - 'model', - service.get('currentURL') - ]); + results.push([service.get('currentRouteName'), 'model', service.get('currentURL')]); }, afterModel() { let service = get(this, 'routerService'); - results.push([ - service.get('currentRouteName'), - 'afterModel', - service.get('currentURL') - ]); - } + results.push([service.get('currentRouteName'), 'afterModel', service.get('currentURL')]); + }, }); moduleFor( @@ -58,15 +46,13 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { this.addComponent('current-url', { ComponentClass: Component.extend({ routerService: inject.service('router'), - currentURL: readOnly('routerService.currentURL') + currentURL: readOnly('routerService.currentURL'), }), - template: '{{currentURL}}' + template: '{{currentURL}}', }); } - ['@test RouterService#currentURL is correctly set for top level route']( - assert - ) { + ['@test RouterService#currentURL is correctly set for top level route'](assert) { assert.expect(1); return this.visit('/').then(() => { @@ -74,9 +60,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#currentURL is correctly set for child route']( - assert - ) { + ['@test RouterService#currentURL is correctly set for child route'](assert) { assert.expect(1); return this.visit('/child').then(() => { @@ -84,9 +68,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#currentURL is correctly set after transition']( - assert - ) { + ['@test RouterService#currentURL is correctly set after transition'](assert) { assert.expect(1); return this.visit('/child') @@ -98,9 +80,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#currentURL is correctly set on each transition']( - assert - ) { + ['@test RouterService#currentURL is correctly set on each transition'](assert) { assert.expect(3); return this.visit('/child') @@ -119,9 +99,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#currentURL is not set during lifecycle hooks']( - assert - ) { + ['@test RouterService#currentURL is not set during lifecycle hooks'](assert) { assert.expect(2); return this.visit('/') @@ -129,7 +107,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { assert.deepEqual(results, [ [null, 'beforeModel', null], [null, 'model', null], - [null, 'afterModel', null] + [null, 'afterModel', null], ]); results = []; @@ -140,7 +118,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { assert.deepEqual(results, [ ['parent.index', 'beforeModel', '/'], ['parent.index', 'model', '/'], - ['parent.index', 'afterModel', '/'] + ['parent.index', 'afterModel', '/'], ]); }); } diff --git a/packages/ember/tests/routing/router_service_test/isActive_test.js b/packages/ember/tests/routing/router_service_test/isActive_test.js index 54b9bb1ff33..5385ea6deab 100644 --- a/packages/ember/tests/routing/router_service_test/isActive_test.js +++ b/packages/ember/tests/routing/router_service_test/isActive_test.js @@ -22,9 +22,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#isActive returns true for simple route with dynamic segments']( - assert - ) { + ['@test RouterService#isActive returns true for simple route with dynamic segments'](assert) { assert.expect(1); let dynamicModel = { id: 1 }; @@ -54,7 +52,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { init() { assert.ok(false, 'should never create'); this._super(...arguments); - } + }, }) ); @@ -63,15 +61,11 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.brother'); }) .then(() => { - assert.notOk( - this.routerService.isActive('parent.sister', queryParams) - ); + assert.notOk(this.routerService.isActive('parent.sister', queryParams)); }); } - ['@test RouterService#isActive is correct for simple route with basic query params']( - assert - ) { + ['@test RouterService#isActive is correct for simple route with basic query params'](assert) { assert.expect(2); let queryParams = this.buildQueryParams({ sort: 'ASC' }); @@ -80,7 +74,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: ['sort'], - sort: 'ASC' + sort: 'ASC', }) ); @@ -91,17 +85,12 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { .then(() => { assert.ok(this.routerService.isActive('parent.child', queryParams)); assert.notOk( - this.routerService.isActive( - 'parent.child', - this.buildQueryParams({ sort: 'DESC' }) - ) + this.routerService.isActive('parent.child', this.buildQueryParams({ sort: 'DESC' })) ); }); } - ['@test RouterService#isActive for simple route with array as query params']( - assert - ) { + ['@test RouterService#isActive for simple route with array as query params'](assert) { assert.expect(1); let queryParams = this.buildQueryParams({ sort: ['ascending'] }); diff --git a/packages/ember/tests/routing/router_service_test/replaceWith_test.js b/packages/ember/tests/routing/router_service_test/replaceWith_test.js index 394885b297a..aa549bce4f7 100644 --- a/packages/ember/tests/routing/router_service_test/replaceWith_test.js +++ b/packages/ember/tests/routing/router_service_test/replaceWith_test.js @@ -26,14 +26,14 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { replaceURL(path) { testCase.state.splice(testCase.state.length - 1, 1, path); this.set('path', path); - } + }, }) ); } get routerOptions() { return { - location: 'test' + location: 'test', }; } @@ -51,9 +51,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#replaceWith with basic route replaces location']( - assert - ) { + ['@test RouterService#replaceWith with basic route replaces location'](assert) { assert.expect(1); return this.visit('/') @@ -71,9 +69,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#replaceWith with basic route using URLs replaces location']( - assert - ) { + ['@test RouterService#replaceWith with basic route using URLs replaces location'](assert) { assert.expect(1); return this.visit('/') @@ -123,7 +119,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: ['sort'], - sort: 'ASC' + sort: 'ASC', }) ); diff --git a/packages/ember/tests/routing/router_service_test/transitionTo_test.js b/packages/ember/tests/routing/router_service_test/transitionTo_test.js index 7eca063aff4..bffc9315fba 100644 --- a/packages/ember/tests/routing/router_service_test/transitionTo_test.js +++ b/packages/ember/tests/routing/router_service_test/transitionTo_test.js @@ -29,14 +29,14 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { replaceURL(path) { testCase.state.splice(testCase.state.length - 1, 1, path); this.set('path', path); - } + }, }) ); } get routerOptions() { return { - location: 'test' + location: 'test', }; } @@ -54,9 +54,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#transitionTo with basic route updates location']( - assert - ) { + ['@test RouterService#transitionTo with basic route updates location'](assert) { assert.expect(1); return this.visit('/') @@ -70,12 +68,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.brother'); }) .then(() => { - assert.deepEqual(this.state, [ - '/', - '/child', - '/sister', - '/brother' - ]); + assert.deepEqual(this.state, ['/', '/child', '/sister', '/brother']); }); } @@ -98,13 +91,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.sister'); }) .then(() => { - assert.deepEqual(this.state, [ - '/', - '/child', - '/sister', - '/brother', - '/sister' - ]); + assert.deepEqual(this.state, ['/', '/child', '/sister', '/brother', '/sister']); }); } @@ -125,10 +112,10 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { actions: { transitionToSister() { get(this, 'routerService').transitionTo('parent.sister'); - } - } + }, + }, }), - template: `foo-bar` + template: `foo-bar`, }); return this.visit('/').then(() => { @@ -136,10 +123,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { componentInstance.send('transitionToSister'); }); - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.sister' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); }); } @@ -160,10 +144,10 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { actions: { transitionToSister() { get(this, 'routerService').transitionTo('/sister'); - } - } + }, + }, }), - template: `foo-bar` + template: `foo-bar`, }); return this.visit('/').then(() => { @@ -171,10 +155,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { componentInstance.send('transitionToSister'); }); - assert.equal( - this.routerService.get('currentRouteName'), - 'parent.sister' - ); + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); }); } @@ -196,14 +177,11 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }, actions: { transitionToDynamic() { - get(this, 'routerService').transitionTo( - 'dynamic', - dynamicModel - ); - } - } + get(this, 'routerService').transitionTo('dynamic', dynamicModel); + }, + }, }), - template: `foo-bar` + template: `foo-bar`, }); return this.visit('/').then(() => { @@ -217,9 +195,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#transitionTo with dynamic segment and model hook']( - assert - ) { + ['@test RouterService#transitionTo with dynamic segment and model hook'](assert) { assert.expect(3); let componentInstance; @@ -230,7 +206,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { Route.extend({ model() { return dynamicModel; - } + }, }) ); @@ -247,10 +223,10 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { actions: { transitionToDynamic() { get(this, 'routerService').transitionTo('dynamic', 1); - } - } + }, + }, }), - template: `foo-bar` + template: `foo-bar`, }); return this.visit('/').then(() => { @@ -273,7 +249,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: ['sort'], - sort: 'ASC' + sort: 'ASC', }) ); @@ -284,22 +260,17 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.child', queryParams); }) .then(() => { - assert.equal( - this.routerService.get('currentURL'), - '/child?sort=ASC' - ); + assert.equal(this.routerService.get('currentURL'), '/child?sort=ASC'); }); } - ['@test RouterService#transitionTo passing only queryParams works']( - assert - ) { + ['@test RouterService#transitionTo passing only queryParams works'](assert) { assert.expect(2); this.add( 'controller:parent.child', Controller.extend({ - queryParams: ['sort'] + queryParams: ['sort'], }) ); @@ -316,16 +287,11 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo(queryParams); }) .then(() => { - assert.equal( - this.routerService.get('currentURL'), - '/child?sort=DESC' - ); + assert.equal(this.routerService.get('currentURL'), '/child?sort=DESC'); }); } - ['@test RouterService#transitionTo with unspecified query params']( - assert - ) { + ['@test RouterService#transitionTo with unspecified query params'](assert) { assert.expect(1); this.add( @@ -334,7 +300,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { queryParams: ['sort', 'page', 'category', 'extra'], sort: 'ASC', page: null, - category: undefined + category: undefined, }) ); @@ -345,10 +311,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.child', queryParams); }) .then(() => { - assert.equal( - this.routerService.get('currentURL'), - '/child?sort=ASC' - ); + assert.equal(this.routerService.get('currentURL'), '/child?sort=ASC'); }); } @@ -361,9 +324,9 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: { - cont_sort: 'url_sort' + cont_sort: 'url_sort', }, - cont_sort: 'ASC' + cont_sort: 'ASC', }) ); @@ -374,10 +337,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.routerService.transitionTo('parent.child', queryParams); }) .then(() => { - assert.equal( - this.routerService.get('currentURL'), - '/child?url_sort=ASC' - ); + assert.equal(this.routerService.get('currentURL'), '/child?url_sort=ASC'); }); } @@ -390,9 +350,9 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: { - cont_sort: 'url_sort' + cont_sort: 'url_sort', }, - cont_sort: 'ASC' + cont_sort: 'ASC', }) ); diff --git a/packages/ember/tests/routing/router_service_test/urlFor_test.js b/packages/ember/tests/routing/router_service_test/urlFor_test.js index d0ada34266a..3f688ffe4fe 100644 --- a/packages/ember/tests/routing/router_service_test/urlFor_test.js +++ b/packages/ember/tests/routing/router_service_test/urlFor_test.js @@ -10,10 +10,8 @@ function setupController(app, name) { Object.defineProperty(app, controllerName, { get() { - throw new Error( - `Generating a URL should not require instantiation of a ${controllerName}.` - ); - } + throw new Error(`Generating a URL should not require instantiation of a ${controllerName}.`); + }, }); } @@ -31,9 +29,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#urlFor returns URL for simple route with dynamic segments']( - assert - ) { + ['@test RouterService#urlFor returns URL for simple route with dynamic segments'](assert) { assert.expect(1); setupController(this.application, 'dynamic'); @@ -47,18 +43,13 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { }); } - ['@test RouterService#urlFor returns URL for simple route with basic query params']( - assert - ) { + ['@test RouterService#urlFor returns URL for simple route with basic query params'](assert) { assert.expect(1); let queryParams = this.buildQueryParams({ foo: 'bar' }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + let expectedURL = this.routerService.urlFor('parent.child', queryParams); assert.equal('/child?foo=bar', expectedURL); }); @@ -73,17 +64,14 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: ['sort'], - sort: 'ASC' + sort: 'ASC', }) ); let queryParams = this.buildQueryParams({ sort: 'ASC' }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + let expectedURL = this.routerService.urlFor('parent.child', queryParams); assert.equal('/child?sort=ASC', expectedURL); }); @@ -98,14 +86,12 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { 'controller:parent.child', Controller.extend({ queryParams: ['sort', 'foo'], - sort: 'ASC' + sort: 'ASC', }) ); return this.visit('/child/?sort=DESC').then(() => { - let controller = this.applicationInstance.lookup( - 'controller:parent.child' - ); + let controller = this.applicationInstance.lookup('controller:parent.child'); assert.equal(get(controller, 'sort'), 'DESC', 'sticky is set'); let queryParams = this.buildQueryParams({ foo: 'derp' }); @@ -121,34 +107,23 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { assert.expect(1); let queryParams = this.buildQueryParams({ - selectedItems: ['a', 'b', 'c'] + selectedItems: ['a', 'b', 'c'], }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + let expectedURL = this.routerService.urlFor('parent.child', queryParams); - assert.equal( - '/child?selectedItems[]=a&selectedItems[]=b&selectedItems[]=c', - expectedURL - ); + assert.equal('/child?selectedItems[]=a&selectedItems[]=b&selectedItems[]=c', expectedURL); }); } - ['@test RouterService#urlFor returns URL for simple route with null query params']( - assert - ) { + ['@test RouterService#urlFor returns URL for simple route with null query params'](assert) { assert.expect(1); let queryParams = this.buildQueryParams({ foo: null }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + let expectedURL = this.routerService.urlFor('parent.child', queryParams); assert.equal('/child', expectedURL); }); @@ -162,10 +137,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { let queryParams = this.buildQueryParams({ foo: undefined }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + let expectedURL = this.routerService.urlFor('parent.child', queryParams); assert.equal('/child', expectedURL); }); @@ -179,11 +151,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { let queryParams = this.buildQueryParams({ foo: 'bar' }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'dynamic', - { id: 1 }, - queryParams - ); + let expectedURL = this.routerService.urlFor('dynamic', { id: 1 }, queryParams); assert.equal('/dynamic/1?foo=bar', expectedURL); }); @@ -195,15 +163,11 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { assert.expect(1); let queryParams = this.buildQueryParams({ - selectedItems: ['a', 'b', 'c'] + selectedItems: ['a', 'b', 'c'], }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'dynamic', - { id: 1 }, - queryParams - ); + let expectedURL = this.routerService.urlFor('dynamic', { id: 1 }, queryParams); assert.equal( '/dynamic/1?selectedItems[]=a&selectedItems[]=b&selectedItems[]=c', @@ -220,11 +184,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { let queryParams = this.buildQueryParams({ foo: null }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'dynamic', - { id: 1 }, - queryParams - ); + let expectedURL = this.routerService.urlFor('dynamic', { id: 1 }, queryParams); assert.equal('/dynamic/1', expectedURL); }); @@ -238,19 +198,13 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { let queryParams = this.buildQueryParams({ foo: undefined }); return this.visit('/').then(() => { - let expectedURL = this.routerService.urlFor( - 'dynamic', - { id: 1 }, - queryParams - ); + let expectedURL = this.routerService.urlFor('dynamic', { id: 1 }, queryParams); assert.equal('/dynamic/1', expectedURL); }); } - ['@test RouterService#urlFor correctly transitions to route via generated path']( - assert - ) { + ['@test RouterService#urlFor correctly transitions to route via generated path'](assert) { assert.expect(1); let expectedURL; @@ -279,7 +233,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { Route.extend({ model() { return dynamicModel; - } + }, }) ); @@ -305,10 +259,7 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { return this.visit('/') .then(() => { - expectedURL = this.routerService.urlFor( - 'parent.child', - queryParams - ); + expectedURL = this.routerService.urlFor('parent.child', queryParams); return this.routerService.transitionTo(expectedURL); }) @@ -334,17 +285,13 @@ if (EMBER_ROUTING_ROUTER_SERVICE) { Route.extend({ model() { return dynamicModel; - } + }, }) ); return this.visit('/') .then(() => { - expectedURL = this.routerService.urlFor( - 'dynamic', - dynamicModel, - queryParams - ); + expectedURL = this.routerService.urlFor('dynamic', dynamicModel, queryParams); return this.routerService.transitionTo(expectedURL); }) diff --git a/packages/ember/tests/routing/substates_test.js b/packages/ember/tests/routing/substates_test.js index dc6912f416e..9d5e9e2ec12 100644 --- a/packages/ember/tests/routing/substates_test.js +++ b/packages/ember/tests/routing/substates_test.js @@ -5,11 +5,7 @@ import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; let counter; function step(assert, expectedValue, description) { - assert.equal( - counter, - expectedValue, - 'Step ' + expectedValue + ': ' + description - ); + assert.equal(counter, expectedValue, 'Step ' + expectedValue + ': ' + description); counter++; } @@ -32,9 +28,7 @@ moduleFor( return this.getController('application').get('currentPath'); } - ['@test Slow promise from a child route of application enters nested loading state']( - assert - ) { + ['@test Slow promise from a child route of application enters nested loading state'](assert) { let turtleDeferred = RSVP.defer(); this.router.map(function() { @@ -46,7 +40,7 @@ moduleFor( Route.extend({ setupController() { step(assert, 2, 'ApplicationRoute#setupController'); - } + }, }) ); @@ -56,7 +50,7 @@ moduleFor( model() { step(assert, 1, 'TurtleRoute#model'); return turtleDeferred.promise; - } + }, }) ); this.addTemplate('turtle', 'TURTLE'); @@ -82,9 +76,7 @@ moduleFor( return promise; } - [`@test Slow promises returned from ApplicationRoute#model don't enter LoadingRoute`]( - assert - ) { + [`@test Slow promises returned from ApplicationRoute#model don't enter LoadingRoute`](assert) { let appDeferred = RSVP.defer(); this.add( @@ -92,7 +84,7 @@ moduleFor( Route.extend({ model() { return appDeferred.promise; - } + }, }) ); this.add( @@ -100,7 +92,7 @@ moduleFor( Route.extend({ setupController() { assert.ok(false, `shouldn't get here`); - } + }, }) ); @@ -119,9 +111,7 @@ moduleFor( return promise; } - [`@test Don't enter loading route unless either route or template defined`]( - assert - ) { + [`@test Don't enter loading route unless either route or template defined`](assert) { let deferred = RSVP.defer(); this.router.map(function() { @@ -132,7 +122,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); this.addTemplate('dummy', 'DUMMY'); @@ -169,7 +159,7 @@ moduleFor( model() { step(assert, 1, 'DummyRoute#model'); return deferred.promise; - } + }, }) ); this.add( @@ -177,7 +167,7 @@ moduleFor( Route.extend({ setupController() { step(assert, 2, 'LoadingRoute#setupController'); - } + }, }) ); this.addTemplate('dummy', 'DUMMY'); @@ -206,7 +196,7 @@ moduleFor( Route.extend({ model() { return appDeferred.promise; - } + }, }) ); let loadingRouteEntered = false; @@ -215,7 +205,7 @@ moduleFor( Route.extend({ setupController() { loadingRouteEntered = true; - } + }, }) ); @@ -244,7 +234,7 @@ moduleFor( Route.extend({ model() { return appDeferred.promise; - } + }, }) ); @@ -252,11 +242,7 @@ moduleFor( let length = this.$('#toplevel-loading').length; text = this.$('#app').text(); - assert.equal( - length, - 0, - `top-level loading view has been entirely removed from the DOM` - ); + assert.equal(length, 0, `top-level loading view has been entirely removed from the DOM`); assert.equal(text, 'INDEX', 'index has fully rendered'); }); let text = this.$('#toplevel-loading').text(); @@ -267,9 +253,7 @@ moduleFor( return promise; } - ['@test Prioritized substate entry works with preserved-namespace nested routes']( - assert - ) { + ['@test Prioritized substate entry works with preserved-namespace nested routes'](assert) { let deferred = RSVP.defer(); this.addTemplate('foo.bar_loading', 'FOOBAR LOADING'); @@ -286,7 +270,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); @@ -309,9 +293,7 @@ moduleFor( }); } - ['@test Prioritized substate entry works with reset-namespace nested routes']( - assert - ) { + ['@test Prioritized substate entry works with reset-namespace nested routes'](assert) { let deferred = RSVP.defer(); this.addTemplate('bar_loading', 'BAR LOADING'); @@ -319,11 +301,7 @@ moduleFor( this.router.map(function() { this.route('foo', function() { - this.route( - 'bar', - { path: '/bar', resetNamespace: true }, - function() {} - ); + this.route('bar', { path: '/bar', resetNamespace: true }, function() {}); }); }); @@ -332,7 +310,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); @@ -375,7 +353,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); @@ -413,9 +391,9 @@ moduleFor( Route.extend({ model() { return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); - } + }, }) ); @@ -430,9 +408,7 @@ moduleFor( }); }); } - ['@test Prioritized loading substate entry works with auto-generated index routes']( - assert - ) { + ['@test Prioritized loading substate entry works with auto-generated index routes'](assert) { let deferred = RSVP.defer(); this.addTemplate('foo.index_loading', 'FOO LOADING'); this.addTemplate('foo.index', 'YAY'); @@ -449,7 +425,7 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); this.add( @@ -457,7 +433,7 @@ moduleFor( Route.extend({ model() { return true; - } + }, }) ); @@ -474,9 +450,7 @@ moduleFor( return promise; } - ['@test Prioritized error substate entry works with auto-generated index routes']( - assert - ) { + ['@test Prioritized error substate entry works with auto-generated index routes'](assert) { this.addTemplate('foo.index_error', 'FOO ERROR: {{model.msg}}'); this.addTemplate('foo.index', 'YAY'); this.addTemplate('foo', '{{outlet}}'); @@ -492,9 +466,9 @@ moduleFor( Route.extend({ model() { return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); - } + }, }) ); this.add( @@ -502,7 +476,7 @@ moduleFor( Route.extend({ model() { return true; - } + }, }) ); @@ -510,11 +484,7 @@ moduleFor( return this.visit('/foo').then(() => { let text = this.$('#app').text(); - assert.equal( - text, - 'FOO ERROR: did it broke?', - 'foo.index_error was entered' - ); + assert.equal(text, 'FOO ERROR: did it broke?', 'foo.index_error was entered'); }); }); } @@ -537,7 +507,7 @@ moduleFor( } else { return {}; } - } + }, }) ); @@ -551,11 +521,7 @@ moduleFor( return this.visit('/') .then(() => { let text = this.$('#toplevel-error').text(); - assert.equal( - text, - 'TOPLEVEL ERROR: BAD NEWS BEARS', - 'toplevel error rendered' - ); + assert.equal(text, 'TOPLEVEL ERROR: BAD NEWS BEARS', 'toplevel error rendered'); reject = false; }) .then(() => { @@ -614,46 +580,28 @@ moduleFor( Route.extend({ model() { return momDeferred.promise; - } + }, }) ); let promise = this.visit('/grandma/mom').then(() => { text = this.$('#app').text(); - assert.equal( - text, - 'GRANDMA MOM', - `Grandma.mom loaded text is displayed` - ); - assert.equal( - this.currentPath, - 'grandma.mom.index', - `currentPath reflects final state` - ); + assert.equal(text, 'GRANDMA MOM', `Grandma.mom loaded text is displayed`); + assert.equal(this.currentPath, 'grandma.mom.index', `currentPath reflects final state`); }); let text = this.$('#app').text(); - assert.equal( - text, - 'GRANDMA GRANDMALOADING', - `Grandma.mom loading text displayed` - ); + assert.equal(text, 'GRANDMA GRANDMALOADING', `Grandma.mom loading text displayed`); - assert.equal( - this.currentPath, - 'grandma.loading', - `currentPath reflects loading state` - ); + assert.equal(this.currentPath, 'grandma.loading', `currentPath reflects loading state`); momDeferred.resolve(); return promise; } - [`@test Loading actions bubble to root but don't enter substates above pivot `]( - assert - ) { + [`@test Loading actions bubble to root but don't enter substates above pivot `](assert) { let sallyDeferred = RSVP.defer(); let puppiesDeferred = RSVP.defer(); @@ -663,8 +611,8 @@ moduleFor( actions: { loading() { assert.ok(true, 'loading action received on ApplicationRoute'); - } - } + }, + }, }) ); @@ -673,7 +621,7 @@ moduleFor( Route.extend({ model() { return sallyDeferred.promise; - } + }, }) ); @@ -682,7 +630,7 @@ moduleFor( Route.extend({ model() { return puppiesDeferred.promise; - } + }, }) ); @@ -693,11 +641,7 @@ moduleFor( promise .then(() => { - assert.equal( - this.currentPath, - 'grandma.mom.sally', - 'transition completed' - ); + assert.equal(this.currentPath, 'grandma.mom.sally', 'transition completed'); let visit = this.visit('/grandma/puppies'); assert.equal( @@ -711,11 +655,7 @@ moduleFor( .then(() => { this.runTask(() => puppiesDeferred.resolve()); - assert.equal( - this.currentPath, - 'grandma.puppies', - 'Finished transition' - ); + assert.equal(this.currentPath, 'grandma.puppies', 'Finished transition'); }); return promise; @@ -730,15 +670,15 @@ moduleFor( model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { error() { step(assert, 2, 'MomSallyRoute#actions.error'); return true; - } - } + }, + }, }) ); @@ -748,11 +688,7 @@ moduleFor( let text = this.$('#app').text(); assert.equal(text, 'GRANDMA ERROR: did it broke?', 'error bubbles'); - assert.equal( - this.currentPath, - 'grandma.error', - 'Initial route fully loaded' - ); + assert.equal(this.currentPath, 'grandma.error', 'Initial route fully loaded'); }); } @@ -762,15 +698,15 @@ moduleFor( Route.extend({ model() { return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { error(err) { // returns undefined which is falsey throw err; - } - } + }, + }, }) ); @@ -796,7 +732,7 @@ moduleFor( model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { @@ -806,8 +742,8 @@ moduleFor( this.transitionTo('mom.this-route-throws'); return false; - } - } + }, + }, }) ); @@ -817,7 +753,7 @@ moduleFor( model() { step(assert, 3, 'MomThisRouteThrows#model'); throw handledError; - } + }, }) ); @@ -834,24 +770,22 @@ moduleFor( return this.runLoopSettled(); } - ['@test errors that are bubbled are thrown at a higher level if not handled']( - assert - ) { + ['@test errors that are bubbled are thrown at a higher level if not handled'](assert) { this.add( 'route:mom.sally', Route.extend({ model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { error() { step(assert, 2, 'MomSallyRoute#actions.error'); return true; - } - } + }, + }, }) ); @@ -868,9 +802,7 @@ moduleFor( return this.runLoopSettled(); } - [`@test Handled errors that are thrown through rejection aren't swallowed`]( - assert - ) { + [`@test Handled errors that are thrown through rejection aren't swallowed`](assert) { let handledError; this.add( @@ -879,7 +811,7 @@ moduleFor( model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { @@ -889,8 +821,8 @@ moduleFor( this.transitionTo('mom.this-route-throws'); return false; - } - } + }, + }, }) ); @@ -900,7 +832,7 @@ moduleFor( model() { step(assert, 3, 'MomThisRouteThrows#model'); return RSVP.reject(handledError); - } + }, }) ); @@ -929,15 +861,15 @@ moduleFor( model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { error() { step(assert, 2, 'MomSallyRoute#actions.error'); return true; - } - } + }, + }, }) ); @@ -950,11 +882,7 @@ moduleFor( 'the more specifically named mome error substate was entered over the other error route' ); - assert.equal( - this.currentPath, - 'grandma.mom_error', - 'Initial route fully loaded' - ); + assert.equal(this.currentPath, 'grandma.mom_error', 'Initial route fully loaded'); }); } @@ -973,7 +901,7 @@ moduleFor( model() { step(assert, 1, 'GrandmaRoute#model'); return grandmaDeferred.promise; - } + }, }) ); @@ -983,7 +911,7 @@ moduleFor( model() { step(assert, 2, 'MomRoute#model'); return {}; - } + }, }) ); @@ -996,7 +924,7 @@ moduleFor( }, setupController() { step(assert, 4, 'SallyRoute#setupController'); - } + }, }) ); @@ -1035,7 +963,7 @@ moduleFor( Route.extend({ setupController() { step(assert, 1, 'SallyRoute#setupController'); - } + }, }) ); @@ -1044,46 +972,32 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); return this.visit('/grandma/mom/sally').then(() => { - assert.equal( - this.currentPath, - 'grandma.mom.sally', - 'Initial route fully loaded' - ); + assert.equal(this.currentPath, 'grandma.mom.sally', 'Initial route fully loaded'); let promise = this.visit('/grandma/puppies').then(() => { - assert.equal( - this.currentPath, - 'grandma.puppies', - 'Finished transition' - ); + assert.equal(this.currentPath, 'grandma.puppies', 'Finished transition'); }); - assert.equal( - this.currentPath, - 'grandma.loading', - `in pivot route's child loading state` - ); + assert.equal(this.currentPath, 'grandma.loading', `in pivot route's child loading state`); deferred.resolve(); return promise; }); } - [`@test Error events that aren't bubbled don't throw application assertions`]( - assert - ) { + [`@test Error events that aren't bubbled don't throw application assertions`](assert) { this.add( 'route:mom.sally', Route.extend({ model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { @@ -1091,17 +1005,15 @@ moduleFor( step(assert, 2, 'MomSallyRoute#actions.error'); assert.equal(err.msg, 'did it broke?', `it didn't break`); return false; - } - } + }, + }, }) ); return this.visit('/grandma/mom/sally'); } - ['@test Handled errors that bubble can be handled at a higher level']( - assert - ) { + ['@test Handled errors that bubble can be handled at a higher level'](assert) { let handledError; this.add( @@ -1115,8 +1027,8 @@ moduleFor( handledError, `error handled and rebubbled is handleable at higher route` ); - } - } + }, + }, }) ); @@ -1126,7 +1038,7 @@ moduleFor( model() { step(assert, 1, 'MomSallyRoute#model'); return RSVP.reject({ - msg: 'did it broke?' + msg: 'did it broke?', }); }, actions: { @@ -1135,17 +1047,15 @@ moduleFor( handledError = err; return true; - } - } + }, + }, }) ); return this.visit('/grandma/mom/sally'); } - ['@test Setting a query param during a slow transition should work']( - assert - ) { + ['@test Setting a query param during a slow transition should work'](assert) { let deferred = RSVP.defer(); this.addTemplate('memere.loading', 'MMONEYLOADING'); @@ -1154,7 +1064,7 @@ moduleFor( Route.extend({ beforeModel: function() { this.transitionTo('memere', 1); - } + }, }) ); @@ -1162,8 +1072,8 @@ moduleFor( 'route:memere', Route.extend({ queryParams: { - test: { defaultValue: 1 } - } + test: { defaultValue: 1 }, + }, }) ); @@ -1172,32 +1082,20 @@ moduleFor( Route.extend({ model() { return deferred.promise; - } + }, }) ); let promise = this.visit('/grandma').then(() => { - assert.equal( - this.currentPath, - 'memere.index', - 'Transition should be complete' - ); + assert.equal(this.currentPath, 'memere.index', 'Transition should be complete'); }); let memereController = this.getController('memere'); - assert.equal( - this.currentPath, - 'memere.loading', - 'Initial route should be loading' - ); + assert.equal(this.currentPath, 'memere.loading', 'Initial route should be loading'); memereController.set('test', 3); - assert.equal( - this.currentPath, - 'memere.loading', - 'Initial route should still be loading' - ); + assert.equal(this.currentPath, 'memere.loading', 'Initial route should still be loading'); assert.equal( memereController.get('test'), diff --git a/packages/ember/tests/service_injection_test.js b/packages/ember/tests/service_injection_test.js index 5765ca83e3c..39f8ba6e87d 100644 --- a/packages/ember/tests/service_injection_test.js +++ b/packages/ember/tests/service_injection_test.js @@ -2,10 +2,7 @@ import { Controller } from 'ember-runtime'; import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; import { inject, Service } from 'ember-runtime'; import { computed } from 'ember-metal'; -import { - EMBER_METAL_ES5_GETTERS, - EMBER_MODULE_UNIFICATION -} from 'ember/features'; +import { EMBER_METAL_ES5_GETTERS, EMBER_MODULE_UNIFICATION } from 'ember/features'; moduleFor( 'Service Injection', @@ -14,7 +11,7 @@ moduleFor( this.add( 'controller:application', Controller.extend({ - myService: inject.service('my-service') + myService: inject.service('my-service'), }) ); let MyService = Service.extend(); @@ -22,9 +19,7 @@ moduleFor( this.addTemplate('application', ''); this.visit('/').then(() => { - let controller = this.applicationInstance.lookup( - 'controller:application' - ); + let controller = this.applicationInstance.lookup('controller:application'); assert.ok(controller.get('myService') instanceof MyService); }); } @@ -35,27 +30,23 @@ if (EMBER_METAL_ES5_GETTERS) { moduleFor( 'Service Injection with ES5 Getters', class extends ApplicationTestCase { - ['@test Service can be injected and is resolved without calling `get`']( - assert - ) { + ['@test Service can be injected and is resolved without calling `get`'](assert) { this.add( 'controller:application', Controller.extend({ - myService: inject.service('my-service') + myService: inject.service('my-service'), }) ); let MyService = Service.extend({ name: computed(function() { return 'The service name'; - }) + }), }); this.add('service:my-service', MyService); this.addTemplate('application', ''); this.visit('/').then(() => { - let controller = this.applicationInstance.lookup( - 'controller:application' - ); + let controller = this.applicationInstance.lookup('controller:application'); assert.ok(controller.myService instanceof MyService); assert.equal( controller.myService.name, @@ -77,22 +68,20 @@ if (EMBER_MODULE_UNIFICATION) { this.add( 'controller:application', Controller.extend({ - myService: inject.service('my-service', { source }) + myService: inject.service('my-service', { source }), }) ); let MyService = Service.extend(); this.add( { specifier: 'service:my-service', - source + source, }, MyService ); return this.visit('/').then(() => { - let controller = this.applicationInstance.lookup( - 'controller:application' - ); + let controller = this.applicationInstance.lookup('controller:application'); assert.ok(controller.get('myService') instanceof MyService); }); @@ -109,14 +98,14 @@ if (EMBER_MODULE_UNIFICATION) { this.add( 'controller:route-a', Controller.extend({ - myService: inject.service('my-service', { source: routeASource }) + myService: inject.service('my-service', { source: routeASource }), }) ); this.add( 'controller:route-b', Controller.extend({ - myService: inject.service('my-service', { source: routeBSource }) + myService: inject.service('my-service', { source: routeBSource }), }) ); @@ -124,7 +113,7 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'service:my-service', - source: routeASource + source: routeASource, }, LocalLookupService ); @@ -133,29 +122,22 @@ if (EMBER_MODULE_UNIFICATION) { this.add( { specifier: 'service:my-service', - source: routeBSource + source: routeBSource, }, MyService ); return this.visit('/').then(() => { - let controllerA = this.applicationInstance.lookup( - 'controller:route-a' - ); + let controllerA = this.applicationInstance.lookup('controller:route-a'); let serviceFromControllerA = controllerA.get('myService'); assert.ok( serviceFromControllerA instanceof LocalLookupService, 'local lookup service is returned' ); - let controllerB = this.applicationInstance.lookup( - 'controller:route-b' - ); + let controllerB = this.applicationInstance.lookup('controller:route-b'); let serviceFromControllerB = controllerB.get('myService'); - assert.ok( - serviceFromControllerB instanceof MyService, - 'global service is returned' - ); + assert.ok(serviceFromControllerB instanceof MyService, 'global service is returned'); assert.notStrictEqual(serviceFromControllerA, serviceFromControllerB); }); @@ -170,39 +152,32 @@ if (EMBER_MODULE_UNIFICATION) { this.add( 'controller:route-a', Controller.extend({ - myService: inject.service('my-service', { source: routeASource }) + myService: inject.service('my-service', { source: routeASource }), }) ); this.add( 'controller:route-b', Controller.extend({ - myService: inject.service('my-service', { source: routeBSource }) + myService: inject.service('my-service', { source: routeBSource }), }) ); let MyService = Service.extend(); this.add( { - specifier: 'service:my-service' + specifier: 'service:my-service', }, MyService ); return this.visit('/').then(() => { - let controllerA = this.applicationInstance.lookup( - 'controller:route-a' - ); + let controllerA = this.applicationInstance.lookup('controller:route-a'); let serviceFromControllerA = controllerA.get('myService'); assert.ok(serviceFromControllerA instanceof MyService); - let controllerB = this.applicationInstance.lookup( - 'controller:route-b' - ); - assert.strictEqual( - serviceFromControllerA, - controllerB.get('myService') - ); + let controllerB = this.applicationInstance.lookup('controller:route-b'); + assert.strictEqual(serviceFromControllerA, controllerB.get('myService')); }); } @@ -223,43 +198,33 @@ if (EMBER_MODULE_UNIFICATION) { this.add( 'controller:route-a', Controller.extend({ - myService: inject.service('my-service', { source: routeASource }) + myService: inject.service('my-service', { source: routeASource }), }) ); this.add( 'controller:route-b', Controller.extend({ - myService: inject.service('my-service') + myService: inject.service('my-service'), }) ); let MyService = Service.extend(); this.add( { - specifier: 'service:my-service' + specifier: 'service:my-service', }, MyService ); return this.visit('/').then(() => { - let controllerA = this.applicationInstance.lookup( - 'controller:route-a' - ); + let controllerA = this.applicationInstance.lookup('controller:route-a'); let serviceFromControllerA = controllerA.get('myService'); - assert.ok( - serviceFromControllerA instanceof MyService, - 'global service is returned' - ); + assert.ok(serviceFromControllerA instanceof MyService, 'global service is returned'); - let controllerB = this.applicationInstance.lookup( - 'controller:route-b' - ); + let controllerB = this.applicationInstance.lookup('controller:route-b'); let serviceFromControllerB = controllerB.get('myService'); - assert.ok( - serviceFromControllerB instanceof MyService, - 'global service is returned' - ); + assert.ok(serviceFromControllerB instanceof MyService, 'global service is returned'); assert.strictEqual(serviceFromControllerA, serviceFromControllerB); }); @@ -269,22 +234,20 @@ if (EMBER_MODULE_UNIFICATION) { this.add( 'controller:application', Controller.extend({ - myService: inject.service('my-namespace::my-service') + myService: inject.service('my-namespace::my-service'), }) ); let MyService = Service.extend(); this.add( { specifier: 'service:my-service', - namespace: 'my-namespace' + namespace: 'my-namespace', }, MyService ); this.visit('/').then(() => { - let controller = this.applicationInstance.lookup( - 'controller:application' - ); + let controller = this.applicationInstance.lookup('controller:application'); assert.ok(controller.get('myService') instanceof MyService); }); } diff --git a/packages/ember/tests/view_instrumentation_test.js b/packages/ember/tests/view_instrumentation_test.js index 70632e4244e..4973cff066e 100644 --- a/packages/ember/tests/view_instrumentation_test.js +++ b/packages/ember/tests/view_instrumentation_test.js @@ -1,7 +1,4 @@ -import { - instrumentationSubscribe as subscribe, - instrumentationReset as reset -} from 'ember-metal'; +import { instrumentationSubscribe as subscribe, instrumentationReset as reset } from 'ember-metal'; import { moduleFor, ApplicationTestCase } from 'internal-test-helpers'; moduleFor( @@ -29,16 +26,12 @@ moduleFor( before() { called = true; }, - after() {} + after() {}, }); return this.visit('/') .then(() => { - assert.equal( - this.textValue(), - 'Index', - 'It rendered the correct template' - ); + assert.equal(this.textValue(), 'Index', 'It rendered the correct template'); assert.ok(called, 'Instrumentation called on first render'); called = false; @@ -46,15 +39,8 @@ moduleFor( return this.visit('/posts'); }) .then(() => { - assert.equal( - this.textValue(), - 'Posts', - 'It rendered the correct template' - ); - assert.ok( - called, - 'Instrumentation called on transition to non-view backed route' - ); + assert.equal(this.textValue(), 'Posts', 'It rendered the correct template'); + assert.ok(called, 'Instrumentation called on transition to non-view backed route'); }); } } diff --git a/packages/external-helpers/lib/external-helpers-dev.js b/packages/external-helpers/lib/external-helpers-dev.js index 39c53a5eb91..48cdb004f89 100644 --- a/packages/external-helpers/lib/external-helpers-dev.js +++ b/packages/external-helpers/lib/external-helpers-dev.js @@ -7,8 +7,7 @@ export function classCallCheck(instance, Constructor) { export function inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError( - 'Super expression must either be null or a function, not ' + - typeof superClass + 'Super expression must either be null or a function, not ' + typeof superClass ); } @@ -17,8 +16,8 @@ export function inherits(subClass, superClass) { value: subClass, enumerable: false, writable: true, - configurable: true - } + configurable: true, + }, }); if (superClass) @@ -62,13 +61,9 @@ export function defaults(obj, defaults) { export const possibleConstructorReturn = function(self, call) { if (!self) { - throw new ReferenceError( - `this hasn't been initialized - super() hasn't been called` - ); + throw new ReferenceError(`this hasn't been initialized - super() hasn't been called`); } - return call && (typeof call === 'object' || typeof call === 'function') - ? call - : self; + return call && (typeof call === 'object' || typeof call === 'function') ? call : self; }; export const slice = Array.prototype.slice; diff --git a/packages/external-helpers/lib/external-helpers-prod.js b/packages/external-helpers/lib/external-helpers-prod.js index 72c99587cbe..6624e463d78 100644 --- a/packages/external-helpers/lib/external-helpers-prod.js +++ b/packages/external-helpers/lib/external-helpers-prod.js @@ -4,8 +4,8 @@ export function inherits(subClass, superClass) { value: subClass, enumerable: false, writable: true, - configurable: true - } + configurable: true, + }, }); if (superClass) @@ -48,9 +48,7 @@ export function defaults(obj, defaults) { } export const possibleConstructorReturn = function(self, call) { - return call && (typeof call === 'object' || typeof call === 'function') - ? call - : self; + return call && (typeof call === 'object' || typeof call === 'function') ? call : self; }; export const slice = Array.prototype.slice; diff --git a/packages/internal-test-helpers/lib/build-owner.js b/packages/internal-test-helpers/lib/build-owner.js index e20174c3c69..fa1c29a2bf0 100644 --- a/packages/internal-test-helpers/lib/build-owner.js +++ b/packages/internal-test-helpers/lib/build-owner.js @@ -1,11 +1,7 @@ import { Registry } from 'container'; import { Router } from 'ember-routing'; import { Application, ApplicationInstance } from 'ember-application'; -import { - RegistryProxyMixin, - ContainerProxyMixin, - Object as EmberObject -} from 'ember-runtime'; +import { RegistryProxyMixin, ContainerProxyMixin, Object as EmberObject } from 'ember-runtime'; export default function buildOwner(options = {}) { let ownerOptions = options.ownerOptions || {}; @@ -18,15 +14,15 @@ export default function buildOwner(options = {}) { Resolver: { create() { return resolver; - } - } + }, + }, }); let fallbackRegistry = Application.buildRegistry(namespace); fallbackRegistry.register('router:main', Router); let registry = new Registry({ - fallback: fallbackRegistry + fallback: fallbackRegistry, }); ApplicationInstance.setupRegistry(registry, bootOptions); @@ -34,7 +30,7 @@ export default function buildOwner(options = {}) { let owner = Owner.create( { __registry__: registry, - __container__: null + __container__: null, }, ownerOptions ); diff --git a/packages/internal-test-helpers/lib/confirm-export.js b/packages/internal-test-helpers/lib/confirm-export.js index 774a7fd5fb1..c85b7a039b3 100644 --- a/packages/internal-test-helpers/lib/confirm-export.js +++ b/packages/internal-test-helpers/lib/confirm-export.js @@ -14,51 +14,21 @@ function getDescriptor(obj, path) { return Object.getOwnPropertyDescriptor(value, last); } -export default function confirmExport( - Ember, - assert, - path, - moduleId, - exportName -) { +export default function confirmExport(Ember, assert, path, moduleId, exportName) { let desc = getDescriptor(Ember, path); assert.ok(desc, 'the property exists on the global'); let mod = require(moduleId); if (typeof exportName === 'string') { - assert.equal( - desc.value, - mod[exportName], - `Ember.${path} is exported correctly` - ); - assert.notEqual( - mod[exportName], - undefined, - `Ember.${path} is not \`undefined\`` - ); + assert.equal(desc.value, mod[exportName], `Ember.${path} is exported correctly`); + assert.notEqual(mod[exportName], undefined, `Ember.${path} is not \`undefined\``); } else { - assert.equal( - desc.get, - mod[exportName.get], - `Ember.${path} getter is exported correctly` - ); - assert.notEqual( - desc.get, - undefined, - `Ember.${path} getter is not undefined` - ); + assert.equal(desc.get, mod[exportName.get], `Ember.${path} getter is exported correctly`); + assert.notEqual(desc.get, undefined, `Ember.${path} getter is not undefined`); if (exportName.set) { - assert.equal( - desc.set, - mod[exportName.set], - `Ember.${path} setter is exported correctly` - ); - assert.notEqual( - desc.set, - undefined, - `Ember.${path} setter is not undefined` - ); + assert.equal(desc.set, mod[exportName.set], `Ember.${path} setter is exported correctly`); + assert.notEqual(desc.set, undefined, `Ember.${path} setter is not undefined`); } } } diff --git a/packages/internal-test-helpers/lib/ember-dev/assertion.js b/packages/internal-test-helpers/lib/ember-dev/assertion.js index a7dd752e280..4fd7fced5e6 100644 --- a/packages/internal-test-helpers/lib/ember-dev/assertion.js +++ b/packages/internal-test-helpers/lib/ember-dev/assertion.js @@ -70,16 +70,13 @@ AssertionAssert.prototype = { restore() { window.expectAssertion = null; window.ignoreAssertion = null; - } + }, }; function check(assert, sawCall, actualMessage, expectedMessage) { // Run assertions in an order that is useful when debugging a test failure. if (!sawCall) { - assert.ok( - false, - `Expected Ember.assert to be called (Not called with any value).` - ); + assert.ok(false, `Expected Ember.assert to be called (Not called with any value).`); } else if (!actualMessage) { assert.ok( false, diff --git a/packages/internal-test-helpers/lib/ember-dev/deprecation.js b/packages/internal-test-helpers/lib/ember-dev/deprecation.js index 3ffe5131dd0..92304e81b58 100644 --- a/packages/internal-test-helpers/lib/ember-dev/deprecation.js +++ b/packages/internal-test-helpers/lib/ember-dev/deprecation.js @@ -24,9 +24,7 @@ class DeprecationAssert extends DebugAssert { this.runExpectation(func, tracker => { if (tracker.isExpectingCalls()) { - throw new Error( - 'expectNoDeprecation was called after expectDeprecation was called!' - ); + throw new Error('expectNoDeprecation was called after expectDeprecation was called!'); } tracker.expectNoCalls(); @@ -53,9 +51,7 @@ class DeprecationAssert extends DebugAssert { this.runExpectation(func, tracker => { if (tracker.isExpectingNoCalls()) { - throw new Error( - 'expectDeprecation was called after expectNoDeprecation was called!' - ); + throw new Error('expectDeprecation was called after expectNoDeprecation was called!'); } tracker.expectCall(message); diff --git a/packages/internal-test-helpers/lib/ember-dev/index.js b/packages/internal-test-helpers/lib/ember-dev/index.js index e853cf480ca..01c4ae6488f 100644 --- a/packages/internal-test-helpers/lib/ember-dev/index.js +++ b/packages/internal-test-helpers/lib/ember-dev/index.js @@ -9,7 +9,7 @@ var EmberDevTestHelperAssert = buildCompositeAssert([ DeprecationAssert, WarningAssert, AssertionAssert, - RunLoopAssert + RunLoopAssert, ]); export default EmberDevTestHelperAssert; diff --git a/packages/internal-test-helpers/lib/ember-dev/method-call-tracker.js b/packages/internal-test-helpers/lib/ember-dev/method-call-tracker.js index 183cf28303b..47322d08ddb 100644 --- a/packages/internal-test-helpers/lib/ember-dev/method-call-tracker.js +++ b/packages/internal-test-helpers/lib/ember-dev/method-call-tracker.js @@ -65,10 +65,7 @@ MethodCallTracker.prototype = { } if (env.runningProdBuild) { - assert.ok( - true, - `calls to Ember.${methodName} disabled in production builds.` - ); + assert.ok(true, `calls to Ember.${methodName} disabled in production builds.`); return; } @@ -81,9 +78,7 @@ MethodCallTracker.prototype = { } assert.ok( actualMessages.length === 0, - `Expected no Ember.${methodName} calls, got ${ - actuals.length - }: ${actualMessages.join(', ')}` + `Expected no Ember.${methodName} calls, got ${actuals.length}: ${actualMessages.join(', ')}` ); return; } @@ -110,21 +105,13 @@ MethodCallTracker.prototype = { } if (!actual) { - assert.ok( - false, - `Received no Ember.${methodName} calls at all, expecting: ${expected}` - ); + assert.ok(false, `Received no Ember.${methodName} calls at all, expecting: ${expected}`); } else if (match && !match[1]) { - assert.ok( - true, - `Received failing Ember.${methodName} call with message: ${match[0]}` - ); + assert.ok(true, `Received failing Ember.${methodName} call with message: ${match[0]}`); } else if (match && match[1]) { assert.ok( false, - `Expected failing Ember.${methodName} call, got succeeding with message: ${ - match[0] - }` + `Expected failing Ember.${methodName} call, got succeeding with message: ${match[0]}` ); } else if (actual[1]) { assert.ok( @@ -142,7 +129,7 @@ MethodCallTracker.prototype = { ); } } - } + }, }; export default MethodCallTracker; diff --git a/packages/internal-test-helpers/lib/ember-dev/run-loop.js b/packages/internal-test-helpers/lib/ember-dev/run-loop.js index 4aeb5428775..f40d38bd48f 100644 --- a/packages/internal-test-helpers/lib/ember-dev/run-loop.js +++ b/packages/internal-test-helpers/lib/ember-dev/run-loop.js @@ -1,9 +1,4 @@ -import { - getCurrentRunLoop, - hasScheduledTimers, - cancelTimers, - end -} from 'ember-metal'; +import { getCurrentRunLoop, hasScheduledTimers, cancelTimers, end } from 'ember-metal'; function RunLoopAssertion(env) { this.env = env; @@ -23,14 +18,11 @@ RunLoopAssertion.prototype = { } if (hasScheduledTimers()) { - assert.ok( - false, - 'Ember run should not have scheduled timers at end of test' - ); + assert.ok(false, 'Ember run should not have scheduled timers at end of test'); cancelTimers(); } }, - restore: function() {} + restore: function() {}, }; export default RunLoopAssertion; diff --git a/packages/internal-test-helpers/lib/ember-dev/setup-qunit.js b/packages/internal-test-helpers/lib/ember-dev/setup-qunit.js index e544dc0b2bf..78e663fff4f 100644 --- a/packages/internal-test-helpers/lib/ember-dev/setup-qunit.js +++ b/packages/internal-test-helpers/lib/ember-dev/setup-qunit.js @@ -10,8 +10,7 @@ export default function setupQUnit(assertion, _qunitGlobal) { qunitGlobal.module = function(name, _options) { var options = _options || {}; var originalSetup = options.setup || options.beforeEach || function() {}; - var originalTeardown = - options.teardown || options.afterEach || function() {}; + var originalTeardown = options.teardown || options.afterEach || function() {}; delete options.setup; delete options.teardown; diff --git a/packages/internal-test-helpers/lib/ember-dev/utils.js b/packages/internal-test-helpers/lib/ember-dev/utils.js index 458e013920b..741e245dc83 100644 --- a/packages/internal-test-helpers/lib/ember-dev/utils.js +++ b/packages/internal-test-helpers/lib/ember-dev/utils.js @@ -15,7 +15,7 @@ export function buildCompositeAssert(assertClasses) { reset: callForEach('asserts', 'reset'), inject: callForEach('asserts', 'inject'), assert: callForEach('asserts', 'assert'), - restore: callForEach('asserts', 'restore') + restore: callForEach('asserts', 'restore'), }; return Composite; diff --git a/packages/internal-test-helpers/lib/ember-dev/warning.js b/packages/internal-test-helpers/lib/ember-dev/warning.js index ec6af0e0c44..7977ed99cf9 100644 --- a/packages/internal-test-helpers/lib/ember-dev/warning.js +++ b/packages/internal-test-helpers/lib/ember-dev/warning.js @@ -24,9 +24,7 @@ class WarningAssert extends DebugAssert { this.runExpectation(func, tracker => { if (tracker.isExpectingCalls()) { - throw new Error( - 'expectNoWarning was called after expectWarning was called!' - ); + throw new Error('expectNoWarning was called after expectWarning was called!'); } tracker.expectNoCalls(); @@ -53,9 +51,7 @@ class WarningAssert extends DebugAssert { this.runExpectation(fn, tracker => { if (tracker.isExpectingNoCalls()) { - throw new Error( - 'expectWarning was called after expectNoWarning was called!' - ); + throw new Error('expectWarning was called after expectNoWarning was called!'); } tracker.expectCall(message); diff --git a/packages/internal-test-helpers/lib/equal-inner-html.js b/packages/internal-test-helpers/lib/equal-inner-html.js index 6481b0d91a7..1e1896a52f5 100644 --- a/packages/internal-test-helpers/lib/equal-inner-html.js +++ b/packages/internal-test-helpers/lib/equal-inner-html.js @@ -32,6 +32,6 @@ export default function equalInnerHTML(assert, fragment, html) { assert.pushResult({ result: actualHTML === html, actual: actualHTML, - expected: html + expected: html, }); } diff --git a/packages/internal-test-helpers/lib/equal-tokens.js b/packages/internal-test-helpers/lib/equal-tokens.js index 784c92c492f..24b172e61f3 100644 --- a/packages/internal-test-helpers/lib/equal-tokens.js +++ b/packages/internal-test-helpers/lib/equal-tokens.js @@ -4,12 +4,12 @@ function generateTokens(containerOrHTML) { if (typeof containerOrHTML === 'string') { return { tokens: tokenize(containerOrHTML), - html: containerOrHTML + html: containerOrHTML, }; } else { return { tokens: tokenize(containerOrHTML.innerHTML), - html: containerOrHTML.innerHTML + html: containerOrHTML.innerHTML, }; } } @@ -30,11 +30,7 @@ function normalizeTokens(tokens) { }); } -export default function equalTokens( - actualContainer, - expectedHTML, - message = null -) { +export default function equalTokens(actualContainer, expectedHTML, message = null) { let actual = generateTokens(actualContainer); let expected = generateTokens(expectedHTML); @@ -51,7 +47,7 @@ export default function equalTokens( result: QUnit.equiv(actual.tokens, expected.tokens), actual: actual.html, expected: expected.html, - message + message, }); } } diff --git a/packages/internal-test-helpers/lib/index.js b/packages/internal-test-helpers/lib/index.js index 85b2d338c3d..1876562f85f 100644 --- a/packages/internal-test-helpers/lib/index.js +++ b/packages/internal-test-helpers/lib/index.js @@ -12,26 +12,20 @@ export { runAppend, runDestroy } from './run'; export { testBoth, testWithDefault } from './test-groups'; export { default as AbstractTestCase } from './test-cases/abstract'; -export { - default as AbstractApplicationTestCase -} from './test-cases/abstract-application'; +export { default as AbstractApplicationTestCase } from './test-cases/abstract-application'; export { default as ApplicationTestCase } from './test-cases/application'; export { default as QueryParamTestCase } from './test-cases/query-param'; -export { - default as AbstractRenderingTestCase -} from './test-cases/abstract-rendering'; +export { default as AbstractRenderingTestCase } from './test-cases/abstract-rendering'; export { default as RenderingTestCase } from './test-cases/rendering'; export { default as RouterTestCase } from './test-cases/router'; +export { default as AutobootApplicationTestCase } from './test-cases/autoboot-application'; export { - default as AutobootApplicationTestCase -} from './test-cases/autoboot-application'; -export { - default as DefaultResolverApplicationTestCase + default as DefaultResolverApplicationTestCase, } from './test-cases/default-resolver-application'; export { default as TestResolver, - ModuleBasedResolver as ModuleBasedTestResolver + ModuleBasedResolver as ModuleBasedTestResolver, } from './test-resolver'; export { isIE11 } from './browser-detect'; diff --git a/packages/internal-test-helpers/lib/matchers.js b/packages/internal-test-helpers/lib/matchers.js index d484e100ed0..4010f6dff4f 100644 --- a/packages/internal-test-helpers/lib/matchers.js +++ b/packages/internal-test-helpers/lib/matchers.js @@ -19,7 +19,7 @@ function equalsAttr(expected) { message() { return `should equal ${this.expected()}`; - } + }, }; } @@ -37,7 +37,7 @@ export function regex(r) { message() { return `should match ${this.expected()}`; - } + }, }; } @@ -67,7 +67,7 @@ export function classes(expected) { message() { return `should match ${this.expected()}`; - } + }, }; } @@ -103,7 +103,7 @@ export function styles(expected) { message() { return `should match ${this.expected()}`; - } + }, }; } @@ -112,7 +112,7 @@ export function equalsElement(assert, element, tagName, attributes, content) { result: element.tagName === tagName.toUpperCase(), actual: element.tagName.toLowerCase(), expected: tagName, - message: `expect tagName to be ${tagName}` + message: `expect tagName to be ${tagName}`, }); let expectedAttrs = {}; @@ -132,7 +132,7 @@ export function equalsElement(assert, element, tagName, attributes, content) { result: expectedAttrs[name].match(element.getAttribute(name)), actual: element.getAttribute(name), expected: matcher.expected(), - message: `Element's ${name} attribute ${matcher.message()}` + message: `Element's ${name} attribute ${matcher.message()}`, }); } @@ -145,14 +145,14 @@ export function equalsElement(assert, element, tagName, attributes, content) { if (!(element instanceof HTMLElement)) { assert.pushResult({ result: element instanceof HTMLElement, - message: 'Element must be an HTML Element, not an SVG Element' + message: 'Element must be an HTML Element, not an SVG Element', }); } else { assert.pushResult({ result: element.attributes.length === expectedCount || !attributes, actual: element.attributes.length, expected: expectedCount, - message: `Expected ${expectedCount} attributes; got ${element.outerHTML}` + message: `Expected ${expectedCount} attributes; got ${element.outerHTML}`, }); if (content !== null) { @@ -160,7 +160,7 @@ export function equalsElement(assert, element, tagName, attributes, content) { result: element.innerHTML === content, actual: element.innerHTML, expected: content, - message: `The element had '${content}' as its content` + message: `The element had '${content}' as its content`, }); } } diff --git a/packages/internal-test-helpers/lib/module-for.js b/packages/internal-test-helpers/lib/module-for.js index 652aee55aa0..89c99e205d5 100644 --- a/packages/internal-test-helpers/lib/module-for.js +++ b/packages/internal-test-helpers/lib/module-for.js @@ -36,7 +36,7 @@ export default function moduleFor(description, TestClass, ...mixins) { if (filteredPromises.length > 0) { return all(filteredPromises); } - } + }, }); if (mixins.length > 0) { @@ -72,9 +72,7 @@ export default function moduleFor(description, TestClass, ...mixins) { let features = match[1].replace(/ /g, '').split(','); if (shouldTest(features)) { - QUnit.test(name.slice(match[0].length), assert => - context[name](assert) - ); + QUnit.test(name.slice(match[0].length), assert => context[name](assert)); } } } diff --git a/packages/internal-test-helpers/lib/system/synthetic-events.js b/packages/internal-test-helpers/lib/system/synthetic-events.js index 0f5d10bdf2b..b8f7dafbcf2 100644 --- a/packages/internal-test-helpers/lib/system/synthetic-events.js +++ b/packages/internal-test-helpers/lib/system/synthetic-events.js @@ -13,7 +13,7 @@ const MOUSE_EVENT_TYPES = [ 'mouseleave', 'mousemove', 'mouseout', - 'mouseover' + 'mouseover', ]; export const elMatches = @@ -109,7 +109,7 @@ export function fireEvent(element, type, options = {}) { screenX: x + 5, screenY: y + 95, clientX: x, - clientY: y + clientY: y, }; event = buildMouseEvent(type, merge(simulatedCoordinates, options)); } else { diff --git a/packages/internal-test-helpers/lib/test-cases/abstract-application.js b/packages/internal-test-helpers/lib/test-cases/abstract-application.js index 6dd99393a0c..ac93f136ec8 100644 --- a/packages/internal-test-helpers/lib/test-cases/abstract-application.js +++ b/packages/internal-test-helpers/lib/test-cases/abstract-application.js @@ -9,13 +9,13 @@ export default class AbstractApplicationTestCase extends AbstractTestCase { return this._applicationInstancePromise; } - return (this._applicationInstancePromise = this.runTask(() => - this.application.boot() - ).then(app => { - this.applicationInstance = app.buildInstance(); + return (this._applicationInstancePromise = this.runTask(() => this.application.boot()).then( + app => { + this.applicationInstance = app.buildInstance(); - return this.applicationInstance.boot(bootOptions); - })); + return this.applicationInstance.boot(bootOptions); + } + )); } visit(url, options) { @@ -23,9 +23,7 @@ export default class AbstractApplicationTestCase extends AbstractTestCase { // the promise returned by `ApplicationInstance.protoype.visit` does **not** // currently guarantee rendering is completed return this.runTask(() => { - return this._ensureInstance(options).then(instance => - instance.visit(url) - ); + return this._ensureInstance(options).then(instance => instance.visit(url)); }); } @@ -33,9 +31,7 @@ export default class AbstractApplicationTestCase extends AbstractTestCase { if (this._element) { return this._element; } else if (ENV._APPLICATION_TEMPLATE_WRAPPER) { - return (this._element = document.querySelector( - '#qunit-fixture > div.ember-view' - )); + return (this._element = document.querySelector('#qunit-fixture > div.ember-view')); } else { return (this._element = document.querySelector('#qunit-fixture')); } @@ -54,13 +50,13 @@ export default class AbstractApplicationTestCase extends AbstractTestCase { get applicationOptions() { return { - rootElement: '#qunit-fixture' + rootElement: '#qunit-fixture', }; } get routerOptions() { return { - location: 'none' + location: 'none', }; } diff --git a/packages/internal-test-helpers/lib/test-cases/abstract-rendering.js b/packages/internal-test-helpers/lib/test-cases/abstract-rendering.js index 0d6c839f19e..73737059ecc 100644 --- a/packages/internal-test-helpers/lib/test-cases/abstract-rendering.js +++ b/packages/internal-test-helpers/lib/test-cases/abstract-rendering.js @@ -18,7 +18,7 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { let owner = (this.owner = buildOwner({ ownerOptions: this.getOwnerOptions(), resolver: this.getResolver(), - bootOptions + bootOptions, })); this.renderer = this.owner.lookup('renderer:-dom'); @@ -26,15 +26,9 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { this.component = null; owner.register('event_dispatcher:main', EventDispatcher); - owner.inject( - 'event_dispatcher:main', - '_viewRegistry', - '-view-registry:main' - ); + owner.inject('event_dispatcher:main', '_viewRegistry', '-view-registry:main'); if (!bootOptions || bootOptions.isInteractive !== false) { - owner - .lookup('event_dispatcher:main') - .setup(this.getCustomDispatcherEvents(), this.element); + owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); } } @@ -66,14 +60,14 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { this.resolver.add( `template:${templateName}`, this.compile(templateString, { - moduleName: templateName + moduleName: templateName, }) ); } else { this.resolver.add( templateName, this.compile(templateString, { - moduleName: templateName.moduleName + moduleName: templateName.moduleName, }) ); } @@ -88,7 +82,7 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { this.resolver.add( `template:components/${name}`, this.compile(template, { - moduleName: `components/${name}` + moduleName: `components/${name}`, }) ); } @@ -117,13 +111,13 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { owner.register( 'template:-top-level', this.compile(templateStr, { - moduleName: '-top-level' + moduleName: '-top-level', }) ); let attrs = assign({}, context, { tagName: '', - layoutName: '-top-level' + layoutName: '-top-level', }); owner.register('component:-top-level', Component.extend(attrs)); @@ -170,7 +164,7 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { owner.register( `template:components/${name}`, this.compile(template, { - moduleName: `my-app/templates/components/${name}.hbs` + moduleName: `my-app/templates/components/${name}.hbs`, }) ); } @@ -182,7 +176,7 @@ export default class AbstractRenderingTestCase extends AbstractTestCase { owner.register( `template:${name}`, this.compile(template, { - moduleName: `my-app/templates/${name}.hbs` + moduleName: `my-app/templates/${name}.hbs`, }) ); } else { diff --git a/packages/internal-test-helpers/lib/test-cases/abstract.js b/packages/internal-test-helpers/lib/test-cases/abstract.js index f82009793ba..4854892f255 100644 --- a/packages/internal-test-helpers/lib/test-cases/abstract.js +++ b/packages/internal-test-helpers/lib/test-cases/abstract.js @@ -176,17 +176,10 @@ export default class AbstractTestCase { } assertHTML(html) { - equalTokens( - this.element, - html, - `#qunit-fixture content should be: \`${html}\`` - ); + equalTokens(this.element, html, `#qunit-fixture content should be: \`${html}\``); } - assertElement( - node, - { ElementType = HTMLElement, tagName, attrs = null, content = null } - ) { + assertElement(node, { ElementType = HTMLElement, tagName, attrs = null, content = null }) { if (!(node instanceof ElementType)) { throw new Error(`Expecting a ${ElementType.name}, but got ${node}`); } @@ -198,11 +191,7 @@ export default class AbstractTestCase { node, { ElementType = HTMLElement, tagName = 'div', attrs = null, content = null } ) { - attrs = assign( - {}, - { id: regex(/^ember\d*$/), class: classes('ember-view') }, - attrs || {} - ); + attrs = assign({}, { id: regex(/^ember\d*$/), class: classes('ember-view') }, attrs || {}); this.assertElement(node, { ElementType, tagName, attrs, content }); } @@ -214,11 +203,7 @@ export default class AbstractTestCase { oldSnapshot = oldSnapshot || this.snapshot; newSnapshot = newSnapshot || this.takeSnapshot(); - this.assert.strictEqual( - newSnapshot.length, - oldSnapshot.length, - 'Same number of nodes' - ); + this.assert.strictEqual(newSnapshot.length, oldSnapshot.length, 'Same number of nodes'); for (let i = 0; i < oldSnapshot.length; i++) { this.assertSameNode(newSnapshot[i], oldSnapshot[i]); diff --git a/packages/internal-test-helpers/lib/test-cases/application.js b/packages/internal-test-helpers/lib/test-cases/application.js index c14a53c8676..3d69334ec42 100644 --- a/packages/internal-test-helpers/lib/test-cases/application.js +++ b/packages/internal-test-helpers/lib/test-cases/application.js @@ -8,9 +8,7 @@ export default class ApplicationTestCase extends TestResolverApplicationTestCase super(); let { applicationOptions } = this; - this.application = this.runTask(() => - this.createApplication(applicationOptions) - ); + this.application = this.runTask(() => this.createApplication(applicationOptions)); this.resolver = applicationOptions.Resolver.lastInstance; @@ -25,7 +23,7 @@ export default class ApplicationTestCase extends TestResolverApplicationTestCase get applicationOptions() { return assign(super.applicationOptions, { - autoboot: false + autoboot: false, }); } diff --git a/packages/internal-test-helpers/lib/test-cases/default-resolver-application.js b/packages/internal-test-helpers/lib/test-cases/default-resolver-application.js index 53382558a04..733d19f8356 100644 --- a/packages/internal-test-helpers/lib/test-cases/default-resolver-application.js +++ b/packages/internal-test-helpers/lib/test-cases/default-resolver-application.js @@ -7,9 +7,7 @@ import { Router } from 'ember-routing'; export default class ApplicationTestCase extends AbstractApplicationTestCase { createApplication() { - let application = (this.application = Application.create( - this.applicationOptions - )); + let application = (this.application = Application.create(this.applicationOptions)); application.Router = Router.extend(this.routerOptions); return application; } @@ -17,7 +15,7 @@ export default class ApplicationTestCase extends AbstractApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { autoboot: false, - Resolver: DefaultResolver + Resolver: DefaultResolver, }); } diff --git a/packages/internal-test-helpers/lib/test-cases/node-query.js b/packages/internal-test-helpers/lib/test-cases/node-query.js index c54c2d6405f..2ac42629469 100644 --- a/packages/internal-test-helpers/lib/test-cases/node-query.js +++ b/packages/internal-test-helpers/lib/test-cases/node-query.js @@ -5,10 +5,7 @@ import { fireEvent, focus, matches } from '../system/synthetic-events'; export default class NodeQuery { static query(selector, context = document) { - assert( - `Invalid second parameter to NodeQuery.query`, - context && context instanceof Node - ); + assert(`Invalid second parameter to NodeQuery.query`, context && context instanceof Node); return new NodeQuery(toArray(context.querySelectorAll(selector))); } @@ -17,10 +14,7 @@ export default class NodeQuery { } constructor(nodes) { - assert( - 'NodeQuery must be initialized with a literal array', - Array.isArray(nodes) - ); + assert('NodeQuery must be initialized with a literal array', Array.isArray(nodes)); this.nodes = nodes; for (let i = 0; i < nodes.length; i++) { @@ -110,9 +104,7 @@ export default class NodeQuery { function assertSingle(nodeQuery) { if (nodeQuery.length !== 1) { throw new Error( - `attr(name) called on a NodeQuery with ${ - this.nodes.length - } elements. Expected one element.` + `attr(name) called on a NodeQuery with ${this.nodes.length} elements. Expected one element.` ); } } diff --git a/packages/internal-test-helpers/lib/test-cases/query-param.js b/packages/internal-test-helpers/lib/test-cases/query-param.js index a0b63595ecc..2e4340529d0 100644 --- a/packages/internal-test-helpers/lib/test-cases/query-param.js +++ b/packages/internal-test-helpers/lib/test-cases/query-param.js @@ -16,18 +16,11 @@ export default class QueryParamTestCase extends ApplicationTestCase { NoneLocation.extend({ setURL(path) { if (testCase.expectedReplaceURL) { - testCase.assert.ok( - false, - 'pushState occurred but a replaceState was expected' - ); + testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); } if (testCase.expectedPushURL) { - testCase.assert.equal( - path, - testCase.expectedPushURL, - 'an expected pushState occurred' - ); + testCase.assert.equal(path, testCase.expectedPushURL, 'an expected pushState occurred'); testCase.expectedPushURL = null; } @@ -36,10 +29,7 @@ export default class QueryParamTestCase extends ApplicationTestCase { replaceURL(path) { if (testCase.expectedPushURL) { - testCase.assert.ok( - false, - 'replaceState occurred but a pushState was expected' - ); + testCase.assert.ok(false, 'replaceState occurred but a pushState was expected'); } if (testCase.expectedReplaceURL) { @@ -52,7 +42,7 @@ export default class QueryParamTestCase extends ApplicationTestCase { } this.set('path', path); - } + }, }) ); } @@ -73,7 +63,7 @@ export default class QueryParamTestCase extends ApplicationTestCase { get routerOptions() { return { - location: 'test' + location: 'test', }; } @@ -92,18 +82,13 @@ export default class QueryParamTestCase extends ApplicationTestCase { @public @method setSingleQPController */ - setSingleQPController( - routeName, - param = 'foo', - defaultValue = 'bar', - options = {} - ) { + setSingleQPController(routeName, param = 'foo', defaultValue = 'bar', options = {}) { this.add( `controller:${routeName}`, Controller.extend( { queryParams: [param], - [param]: defaultValue + [param]: defaultValue, }, options ) @@ -128,9 +113,9 @@ export default class QueryParamTestCase extends ApplicationTestCase { Controller.extend( { queryParams: { - [prop]: urlKey + [prop]: urlKey, }, - [prop]: defaultValue + [prop]: defaultValue, }, options ) diff --git a/packages/internal-test-helpers/lib/test-cases/router.js b/packages/internal-test-helpers/lib/test-cases/router.js index 4fc8488e4aa..46377fd5bdf 100644 --- a/packages/internal-test-helpers/lib/test-cases/router.js +++ b/packages/internal-test-helpers/lib/test-cases/router.js @@ -20,7 +20,7 @@ export default class RouterTestCase extends ApplicationTestCase { buildQueryParams(queryParams) { return { - queryParams + queryParams, }; } } diff --git a/packages/internal-test-helpers/lib/test-cases/test-resolver-application.js b/packages/internal-test-helpers/lib/test-cases/test-resolver-application.js index 10a1bd98c80..2ec48927439 100644 --- a/packages/internal-test-helpers/lib/test-cases/test-resolver-application.js +++ b/packages/internal-test-helpers/lib/test-cases/test-resolver-application.js @@ -6,7 +6,7 @@ import { assign } from 'ember-utils'; export default class TestResolverApplicationTestCase extends AbstractApplicationTestCase { get applicationOptions() { return assign(super.applicationOptions, { - Resolver: ModuleBasedResolver + Resolver: ModuleBasedResolver, }); } @@ -18,7 +18,7 @@ export default class TestResolverApplicationTestCase extends AbstractApplication this.resolver.add( `template:${templateName}`, this.compile(templateString, { - moduleName: `my-app/templates/${templateName}.hbs` + moduleName: `my-app/templates/${templateName}.hbs`, }) ); } @@ -32,7 +32,7 @@ export default class TestResolverApplicationTestCase extends AbstractApplication this.resolver.add( `template:components/${name}`, this.compile(template, { - moduleName: `my-app/templates/components/${name}.hbs` + moduleName: `my-app/templates/components/${name}.hbs`, }) ); } diff --git a/packages/internal-test-helpers/lib/test-groups.js b/packages/internal-test-helpers/lib/test-groups.js index 2be080f3a79..43a184ceedf 100644 --- a/packages/internal-test-helpers/lib/test-groups.js +++ b/packages/internal-test-helpers/lib/test-groups.js @@ -2,7 +2,7 @@ import { ENV } from 'ember-environment'; import { get as getFromEmberMetal, getWithDefault as getWithDefaultFromEmberMetal, - set as setFromEmberMetal + set as setFromEmberMetal, } from 'ember-metal'; // used by unit tests to test both accessor mode and non-accessor mode diff --git a/packages/internal-test-helpers/lib/test-resolver.js b/packages/internal-test-helpers/lib/test-resolver.js index c65771565ca..ef5d1af1bb8 100644 --- a/packages/internal-test-helpers/lib/test-resolver.js +++ b/packages/internal-test-helpers/lib/test-resolver.js @@ -7,7 +7,7 @@ function serializeKey(specifier, source, namespace) { return `${type}://${[ name, namespace ? '[source invalid due to namespace]' : source, - namespace + namespace, ].join(DELIMITER)}`; } @@ -17,9 +17,7 @@ class Resolver { this.constructor.lastInstance = this; } resolve(specifier) { - return ( - this._registered[specifier] || this._registered[serializeKey(specifier)] - ); + return this._registered[specifier] || this._registered[serializeKey(specifier)]; } expandLocalLookup(specifier, source, namespace) { if (specifier.indexOf('://') !== -1) { @@ -45,9 +43,7 @@ class Resolver { switch (typeof lookup) { case 'string': if (lookup.indexOf(':') === -1) { - throw new Error( - 'Specifiers added to the resolver must be in the format of type:name' - ); + throw new Error('Specifiers added to the resolver must be in the format of type:name'); } key = serializeKey(lookup); break; @@ -67,10 +63,8 @@ class Resolver { `You called addTemplate for "${templateName}" with a template argument of type of '${templateType}'. addTemplate expects an argument of an uncompiled template as a string.` ); } - return (this._registered[ - serializeKey(`template:${templateName}`) - ] = compile(template, { - moduleName: `my-app/templates/${templateName}.hbs` + return (this._registered[serializeKey(`template:${templateName}`)] = compile(template, { + moduleName: `my-app/templates/${templateName}.hbs`, })); } static create() { diff --git a/packages/internal-test-helpers/tests/index-test.js b/packages/internal-test-helpers/tests/index-test.js index 166e9a1e561..bdf2f1bbd70 100644 --- a/packages/internal-test-helpers/tests/index-test.js +++ b/packages/internal-test-helpers/tests/index-test.js @@ -4,10 +4,7 @@ moduleFor( 'internal-test-helpers', class extends AbstractTestCase { ['@test module present'](assert) { - assert.ok( - true, - 'each package needs at least one test to be able to run through `npm test`' - ); + assert.ok(true, 'each package needs at least one test to be able to run through `npm test`'); } } ); diff --git a/packages/loader/lib/index.js b/packages/loader/lib/index.js index a9bf821ce6f..fc21f324e9a 100644 --- a/packages/loader/lib/index.js +++ b/packages/loader/lib/index.js @@ -7,9 +7,7 @@ mainContext = this; // eslint-disable-line no-undef (function() { function missingModule(name, referrerName) { if (referrerName) { - throw new Error( - 'Could not find module ' + name + ' required by: ' + referrerName - ); + throw new Error('Could not find module ' + name + ' required by: ' + referrerName); } else { throw new Error('Could not find module ' + name); } @@ -102,7 +100,7 @@ mainContext = this; // eslint-disable-line no-undef Ember.__loader = { define: enifed, require: requireModule, - registry: registry + registry: registry, }; } else { enifed = Ember.__loader.define; diff --git a/packages/node-module/lib/node-module.js b/packages/node-module/lib/node-module.js index 829b33eb40b..4f9e9e790f2 100644 --- a/packages/node-module/lib/node-module.js +++ b/packages/node-module/lib/node-module.js @@ -1,7 +1,6 @@ /*global enifed, module */ enifed('node-module', ['exports'], function(_exports) { - var IS_NODE = - typeof module === 'object' && typeof module.require === 'function'; + var IS_NODE = typeof module === 'object' && typeof module.require === 'function'; if (IS_NODE) { _exports.require = module.require; _exports.module = module; diff --git a/rollup.config.js b/rollup.config.js index 83bb735077d..3f4797db18c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,8 +11,8 @@ module.exports = { format: 'iife', name: '__Ember', named: true, - sourcemap: true - } + sourcemap: true, + }, }; function emberPackage() { @@ -21,7 +21,7 @@ function emberPackage() { if (importee[0] === '.' || importee[0] === '/') return; let resolved = [ path.resolve('dist', `es/${importee}.js`), - path.resolve('dist', `es/${importee}/index.js`) + path.resolve('dist', `es/${importee}/index.js`), ].find(fs.existsSync); if (resolved) { // console.log('resolved ' + resolved); @@ -30,6 +30,6 @@ function emberPackage() { // eslint-disable-next-line no-console console.log('could not resolve ' + importee + ' from ' + importer); } - } + }, }; } diff --git a/testem.dist.js b/testem.dist.js index 0350573cffc..6f03ccc5714 100644 --- a/testem.dist.js +++ b/testem.dist.js @@ -5,9 +5,7 @@ function FailureOnlyPerBrowserReporter() { this._resultsByBrowser = {}; } -FailureOnlyPerBrowserReporter.prototype = Object.create( - FailureOnlyReporter.prototype -); +FailureOnlyPerBrowserReporter.prototype = Object.create(FailureOnlyReporter.prototype); FailureOnlyPerBrowserReporter.prototype.constructor = FailureOnlyPerBrowserReporter; FailureOnlyPerBrowserReporter.prototype.report = function(prefix, data) { @@ -15,7 +13,7 @@ FailureOnlyPerBrowserReporter.prototype.report = function(prefix, data) { this._resultsByBrowser[prefix] = { total: 0, pass: 0, - skipped: 0 + skipped: 0, }; } @@ -30,10 +28,7 @@ FailureOnlyPerBrowserReporter.prototype.report = function(prefix, data) { }; FailureOnlyPerBrowserReporter.prototype.summaryDisplay = function() { - var originalSummary = FailureOnlyReporter.prototype.summaryDisplay.apply( - this, - arguments - ); + var originalSummary = FailureOnlyReporter.prototype.summaryDisplay.apply(this, arguments); var lines = []; var resultsByBrowser = this._resultsByBrowser; Object.keys(resultsByBrowser).forEach(function(browser) { @@ -73,9 +68,9 @@ module.exports = { '-t', '1200', '--u', - '' + '', ], - protocol: 'browser' + protocol: 'browser', }, BS_Firefox_Current: { exe: 'node_modules/.bin/browserstack-launch', @@ -91,9 +86,9 @@ module.exports = { '-t', '1200', '--u', - '' + '', ], - protocol: 'browser' + protocol: 'browser', }, BS_Safari_Current: { exe: 'node_modules/.bin/browserstack-launch', @@ -109,9 +104,9 @@ module.exports = { '-t', '1200', '--u', - '' + '', ], - protocol: 'browser' + protocol: 'browser', }, BS_Safari_Last: { exe: 'node_modules/.bin/browserstack-launch', @@ -127,9 +122,9 @@ module.exports = { '-t', '1200', '--u', - '' + '', ], - protocol: 'browser' + protocol: 'browser', }, BS_MS_Edge: { exe: 'node_modules/.bin/browserstack-launch', @@ -145,9 +140,9 @@ module.exports = { '-t', '1200', '--u', - '' + '', ], - protocol: 'browser' + protocol: 'browser', }, BS_IE_11: { exe: 'node_modules/.bin/browserstack-launch', @@ -163,11 +158,11 @@ module.exports = { '-t', '1500', '--u', - '' + '', ], - protocol: 'browser' - } + protocol: 'browser', + }, }, launch_in_dev: [], - launch_in_ci: ['BS_Safari_Current', 'BS_MS_Edge', 'BS_IE_11'] + launch_in_ci: ['BS_Safari_Current', 'BS_MS_Edge', 'BS_IE_11'], }; diff --git a/testem.travis-browsers.js b/testem.travis-browsers.js index f6631e3f474..ea7a29a8da5 100644 --- a/testem.travis-browsers.js +++ b/testem.travis-browsers.js @@ -8,5 +8,5 @@ module.exports = { disable_watching: true, launch_in_dev: ['Firefox'], launch_in_ci: ['Firefox'], - reporter: FailureOnlyReporter + reporter: FailureOnlyReporter, }; diff --git a/tests/node/app-boot-test.js b/tests/node/app-boot-test.js index 35f2558dc17..4ee9f992d1c 100644 --- a/tests/node/app-boot-test.js +++ b/tests/node/app-boot-test.js @@ -22,15 +22,12 @@ QUnit.test('nested {{component}}', function(assert) { this.component('root-component', { location: 'World', - hasExistence: true + hasExistence: true, }); - this.template( - 'components/foo-bar', - '\ + this.template('components/foo-bar', '\

The files are *inside* the computer?!

\ -' - ); +'); return this.renderToHTML('/').then(function(html) { assertHTMLMatches( @@ -42,10 +39,7 @@ QUnit.test('nested {{component}}', function(assert) { }); QUnit.test('{{link-to}}', function(assert) { - this.template( - 'application', - "

{{#link-to 'photos'}}Go to photos{{/link-to}}

" - ); + this.template('application', "

{{#link-to 'photos'}}Go to photos{{/link-to}}

"); this.routes(function() { this.route('photos'); }); @@ -66,7 +60,7 @@ QUnit.test('non-escaped content', function(assert) { this.template('application', '

{{{title}}}

'); this.controller('application', { - title: 'Hello world' + title: 'Hello world', }); return this.renderToHTML('/').then(function(html) { @@ -131,15 +125,13 @@ QUnit.test('lifecycle hooks disabled', function(assert) { }, didInsertElement() { assert.ok(false, 'should not trigger didInsertElement hook'); - } + }, }); return this.renderToHTML('/'); }); -QUnit.test('Should not attempt to render element modifiers GH#14220', function( - assert -) { +QUnit.test('Should not attempt to render element modifiers GH#14220', function(assert) { assert.expect(1); this.template('application', "
"); diff --git a/tests/node/component-rendering-test.js b/tests/node/component-rendering-test.js index e67031972e3..0ecb397f7fc 100644 --- a/tests/node/component-rendering-test.js +++ b/tests/node/component-rendering-test.js @@ -16,20 +16,19 @@ QUnit.test('Component with dynamic value', function(assert) { assert.ok(html.match(/

Hello World<\/h1>/)); }); -QUnit.test( - 'Ensure undefined attributes requiring protocol sanitization do not error', - function(assert) { - this.owner.register( - 'component:fake-link', - this.Ember.Component.extend({ - tagName: 'link', - attributeBindings: ['href', 'rel'], - rel: 'canonical' - }) - ); - - var html = this.render('{{fake-link}}'); - - assert.ok(html.match(/rel="canonical"/)); - } -); +QUnit.test('Ensure undefined attributes requiring protocol sanitization do not error', function( + assert +) { + this.owner.register( + 'component:fake-link', + this.Ember.Component.extend({ + tagName: 'link', + attributeBindings: ['href', 'rel'], + rel: 'canonical', + }) + ); + + var html = this.render('{{fake-link}}'); + + assert.ok(html.match(/rel="canonical"/)); +}); diff --git a/tests/node/helpers/app-module.js b/tests/node/helpers/app-module.js index 3714180f91a..14a5be88400 100644 --- a/tests/node/helpers/app-module.js +++ b/tests/node/helpers/app-module.js @@ -97,7 +97,7 @@ module.exports = function(moduleName) { // clear the previously cached version of this module delete require.cache[emberPath + '.js']; delete require.cache[templateCompilerPath + '.js']; - } + }, }); }; @@ -105,11 +105,11 @@ function createApplication() { if (this.app) return this.app; var app = this.Ember.Application.extend().create({ - autoboot: false + autoboot: false, }); app.Router = this.Ember.Router.extend({ - location: 'none' + location: 'none', }); if (this.routesCallback) { @@ -137,7 +137,7 @@ function visit(url) { return this.run(app, 'visit', url, { isBrowser: false, document: dom, - rootElement: dom.body + rootElement: dom.body, }).catch(function(error) { console.error(error.stack); }); @@ -151,7 +151,7 @@ function renderToHTML(url) { return this.run(app, 'visit', url, { isBrowser: false, document: dom, - rootElement: root + rootElement: root, }).then(function() { var serializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); return serializer.serialize(root); @@ -165,7 +165,7 @@ function registerApplicationClasses(app, registry) { for (var key in registry) { app.register(key, registry[key]); } - } + }, }); } diff --git a/tests/node/helpers/assert-html-matches.js b/tests/node/helpers/assert-html-matches.js index 509dcef2247..a5686aa3bf2 100644 --- a/tests/node/helpers/assert-html-matches.js +++ b/tests/node/helpers/assert-html-matches.js @@ -1,6 +1,6 @@ var diffOptions = { ignoreAttributes: ['id'], - ignoreWhitespaces: true + ignoreWhitespaces: true, }; var HtmlDiffer = require('html-differ').HtmlDiffer; var htmlDiffer = new HtmlDiffer(diffOptions); @@ -18,7 +18,7 @@ function assertHTMLMatches(assert, actual, expected, message) { result: isEqual, actual, expected, - message + message, }); } diff --git a/tests/node/helpers/build-owner.js b/tests/node/helpers/build-owner.js index ebebe592a25..3b85085b8e7 100644 --- a/tests/node/helpers/build-owner.js +++ b/tests/node/helpers/build-owner.js @@ -1,27 +1,24 @@ module.exports = function buildOwner(Ember, resolver) { - var Owner = Ember.Object.extend( - Ember._RegistryProxyMixin, - Ember._ContainerProxyMixin - ); + var Owner = Ember.Object.extend(Ember._RegistryProxyMixin, Ember._ContainerProxyMixin); var namespace = Ember.Object.create({ Resolver: { create: function() { return resolver; - } - } + }, + }, }); var fallbackRegistry = Ember.Application.buildRegistry(namespace); var registry = new Ember.Registry({ - fallback: fallbackRegistry + fallback: fallbackRegistry, }); Ember.ApplicationInstance.setupRegistry(registry); var owner = Owner.create({ __registry__: registry, - __container__: null + __container__: null, }); var container = registry.container({ owner: owner }); diff --git a/tests/node/helpers/component-module.js b/tests/node/helpers/component-module.js index e5f44f39fce..2685e29775d 100644 --- a/tests/node/helpers/component-module.js +++ b/tests/node/helpers/component-module.js @@ -53,7 +53,7 @@ module.exports = function(moduleName) { this.Ember = null; clearEmber(); - } + }, }); }; @@ -63,7 +63,7 @@ function setupComponentTest() { module.element = new SimpleDOM.Document(); module.owner = buildOwner(this.Ember, { resolve: function() {} }); module.owner.register('service:-document', new SimpleDOM.Document(), { - instantiate: false + instantiate: false, }); this._hasRendered = false; @@ -77,10 +77,10 @@ function setupComponentTest() { outlet: 'main', name: 'application', controller: module, - template: OutletTemplate + template: OutletTemplate, }, - outlets: {} + outlets: {}, }; templateId = 0; @@ -110,7 +110,7 @@ function render(_template) { outlet: 'main', name: 'index', controller: this, - template: this.owner.lookup(templateFullName) + template: this.owner.lookup(templateFullName), }; stateToRender.name = 'index'; diff --git a/tests/node/template-compiler-test.js b/tests/node/template-compiler-test.js index 5773a4bdb83..74d5cdf7dd9 100644 --- a/tests/node/template-compiler-test.js +++ b/tests/node/template-compiler-test.js @@ -16,58 +16,30 @@ module('ember-template-compiler.js', { afterEach: function() { // clear the previously cached version of this module delete require.cache[templateCompilerPath + '.js']; - } + }, }); test('can be required', function(assert) { - assert.ok( - typeof templateCompiler.precompile === 'function', - 'precompile function is present' - ); - assert.ok( - typeof templateCompiler.compile === 'function', - 'compile function is present' - ); + assert.ok(typeof templateCompiler.precompile === 'function', 'precompile function is present'); + assert.ok(typeof templateCompiler.compile === 'function', 'compile function is present'); }); test('can access _Ember.ENV (private API used by ember-cli-htmlbars)', function(assert) { - assert.equal( - typeof templateCompiler._Ember.ENV, - 'object', - '_Ember.ENV is present' - ); - assert.notEqual( - typeof templateCompiler._Ember.ENV, - null, - '_Ember.ENV is not null' - ); + assert.equal(typeof templateCompiler._Ember.ENV, 'object', '_Ember.ENV is present'); + assert.notEqual(typeof templateCompiler._Ember.ENV, null, '_Ember.ENV is not null'); }); test('can access _Ember.FEATURES (private API used by ember-cli-htmlbars)', function(assert) { - assert.equal( - typeof templateCompiler._Ember.FEATURES, - 'object', - '_Ember.FEATURES is present' - ); - assert.notEqual( - typeof templateCompiler._Ember.FEATURES, - null, - '_Ember.FEATURES is not null' - ); + assert.equal(typeof templateCompiler._Ember.FEATURES, 'object', '_Ember.FEATURES is present'); + assert.notEqual(typeof templateCompiler._Ember.FEATURES, null, '_Ember.FEATURES is not null'); }); test('can access _Ember.VERSION (private API used by ember-cli-htmlbars)', function(assert) { - assert.equal( - typeof templateCompiler._Ember.VERSION, - 'string', - '_Ember.VERSION is present' - ); + assert.equal(typeof templateCompiler._Ember.VERSION, 'string', '_Ember.VERSION is present'); }); test('can generate a template with a server side generated `id`', function(assert) { - var TemplateJSON = JSON.parse( - templateCompiler.precompile('
simple text
') - ); + var TemplateJSON = JSON.parse(templateCompiler.precompile('
simple text
')); assert.ok(TemplateJSON.id, 'an `id` was generated'); }); diff --git a/tests/node/visit-test.js b/tests/node/visit-test.js index 1d271becb93..8dd52c5c255 100644 --- a/tests/node/visit-test.js +++ b/tests/node/visit-test.js @@ -3,10 +3,7 @@ var SimpleDOM = require('simple-dom'); var appModule = require('./helpers/app-module'); function assertHTMLMatches(assert, actualHTML, expectedHTML) { - assert.ok( - actualHTML.match(expectedHTML), - actualHTML + ' matches ' + expectedHTML - ); + assert.ok(actualHTML.match(expectedHTML), actualHTML + ' matches ' + expectedHTML); } function handleError(assert) { @@ -28,7 +25,7 @@ function fastbootVisit(App, url) { return { url: instance.getURL(), title: doc.title, - body: HTMLSerializer.serialize(rootElement) + body: HTMLSerializer.serialize(rootElement), }; } finally { instance.destroy(); @@ -67,7 +64,7 @@ QUnit.test('FastBoot: basic', function(assert) { }, didInsertElement: function() { didInsertElementCalled = true; - } + }, }); var App = this.createApplication(); @@ -77,24 +74,20 @@ QUnit.test('FastBoot: basic', function(assert) { assertFastbootResult(assert, { url: '/a', body: - '

Hello world

\n

Welcome to Page A

' + '

Hello world

\n

Welcome to Page A

', }), handleError(assert) ), fastbootVisit(App, '/b').then( assertFastbootResult(assert, { url: '/b', - body: - '

Hello world

\n

Page B

' + body: '

Hello world

\n

Page B

', }), handleError - ) + ), ]).then(function() { assert.ok(initCalled, 'Component#init should be called'); - assert.ok( - !didInsertElementCalled, - 'Component#didInsertElement should not be called' - ); + assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); }); }); @@ -112,13 +105,13 @@ QUnit.test('FastBoot: redirect', function(assert) { this.route('a', { beforeModel: function() { this.replaceWith('b'); - } + }, }); this.route('b', { afterModel: function() { this.transitionTo('c'); - } + }, }); var App = this.createApplication(); @@ -127,17 +120,17 @@ QUnit.test('FastBoot: redirect', function(assert) { fastbootVisit(App, '/a').then( assertFastbootResult(assert, { url: '/c', - body: '

Hello from C

' + body: '

Hello from C

', }), handleError(assert) ), fastbootVisit(App, '/b').then( assertFastbootResult(assert, { url: '/c', - body: '

Hello from C

' + body: '

Hello from C

', }), handleError(assert) - ) + ), ]); }); @@ -146,7 +139,7 @@ QUnit.test('FastBoot: attributes are sanitized', function(assert) { this.controller('application', { /*jshint scripturl:true*/ - test: 'javascript:alert("hello")' + test: 'javascript:alert("hello")', }); var App = this.createApplication(); @@ -155,10 +148,10 @@ QUnit.test('FastBoot: attributes are sanitized', function(assert) { fastbootVisit(App, '/').then( assertFastbootResult(assert, { url: '/', - body: '' + body: '', }), handleError(assert) - ) + ), ]); }); @@ -174,13 +167,13 @@ QUnit.test('FastBoot: route error', function(assert) { this.route('a', { beforeModel: function() { throw new Error('Error from A'); - } + }, }); this.route('b', { afterModel: function() { throw new Error('Error from B'); - } + }, }); var App = this.createApplication(); @@ -203,7 +196,7 @@ QUnit.test('FastBoot: route error', function(assert) { function(error) { assert.equal(error.message, 'Error from B'); } - ) + ), ]); }); @@ -218,7 +211,7 @@ QUnit.test('FastBoot: route error template', function(assert) { this.route('a', { model: function() { throw new Error('Error from A'); - } + }, }); var App = this.createApplication(); @@ -227,10 +220,10 @@ QUnit.test('FastBoot: route error template', function(assert) { fastbootVisit(App, '/a').then( assertFastbootResult(assert, { url: '/a', - body: '

Error template rendered!

' + body: '

Error template rendered!

', }), handleError(assert) - ) + ), ]); }); @@ -243,7 +236,7 @@ QUnit.test('Resource-discovery setup', function(assert) { fetch: function(url) { this.get('requests').push(url); return RSVP.resolve(); - } + }, }); this.routes(function() { @@ -260,7 +253,7 @@ QUnit.test('Resource-discovery setup', function(assert) { }, afterModel: function() { this.replaceWith('b'); - } + }, }); this.route('b', { @@ -269,13 +262,13 @@ QUnit.test('Resource-discovery setup', function(assert) { }, afterModel: function() { this.replaceWith('c'); - } + }, }); this.route('c', { model: function() { return this.network.fetch('/c'); - } + }, }); this.route('d', { @@ -284,13 +277,13 @@ QUnit.test('Resource-discovery setup', function(assert) { }, afterModel: function() { this.replaceWith('e'); - } + }, }); this.route('e', { model: function() { return this.network.fetch('/e'); - } + }, }); this.template('a', '{{x-foo}}'); @@ -305,7 +298,7 @@ QUnit.test('Resource-discovery setup', function(assert) { init: function() { this._super(); xFooInstances++; - } + }, }); var App = this.createApplication(); @@ -313,24 +306,17 @@ QUnit.test('Resource-discovery setup', function(assert) { App.inject('route', 'network', 'service:network'); function assertResources(url, resources) { - return App.visit(url, { isBrowser: false, shouldRender: false }).then( - function(instance) { - try { - var viewRegistry = instance.lookup('-view-registry:main'); - assert.strictEqual( - Object.keys(viewRegistry).length, - 0, - 'did not create any views' - ); - - var networkService = instance.lookup('service:network'); - assert.deepEqual(networkService.get('requests'), resources); - } finally { - instance.destroy(); - } - }, - handleError(assert) - ); + return App.visit(url, { isBrowser: false, shouldRender: false }).then(function(instance) { + try { + var viewRegistry = instance.lookup('-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + + var networkService = instance.lookup('service:network'); + assert.deepEqual(networkService.get('requests'), resources); + } finally { + instance.destroy(); + } + }, handleError(assert)); } return RSVP.all([ @@ -338,21 +324,14 @@ QUnit.test('Resource-discovery setup', function(assert) { assertResources('/b', ['/b', '/c']), assertResources('/c', ['/c']), assertResources('/d', ['/d', '/e']), - assertResources('/e', ['/e']) + assertResources('/e', ['/e']), ]).then(function() { - assert.strictEqual( - xFooInstances, - 0, - 'it should not create any x-foo components' - ); + assert.strictEqual(xFooInstances, 0, 'it should not create any x-foo components'); }); }); QUnit.test('FastBoot: tagless components can render', function(assert) { - this.template( - 'application', - "
{{my-component}}
" - ); + this.template('application', "
{{my-component}}
"); this.component('my-component', { tagName: '' }); this.template('components/my-component', '

hello world

'); @@ -362,9 +341,9 @@ QUnit.test('FastBoot: tagless components can render', function(assert) { fastbootVisit(App, '/').then( assertFastbootResult(assert, { url: '/', - body: /

hello world<\/h1><\/div>/ + body: /

hello world<\/h1><\/div>/, }), handleError(assert) - ) + ), ]); });