diff --git a/.eslintrc.js b/.eslintrc.js index ade61fb..4aea94e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,7 +22,16 @@ module.exports = { env: { browser: true, }, - rules: {}, + rules: { + 'ember/no-controller-access-in-routes': 1, + 'ember/no-computed-properties-in-native-classes': 1, + 'ember/no-classic-classes': 1, + 'ember/avoid-leaking-state-in-ember-objects': 1, + 'n/no-missing-require': 1, + 'ember/no-new-mixins': 1, + 'ember/no-arrow-function-computed-properties': 1, + 'ember/no-actions-hash': 1, + }, overrides: [ // node files { @@ -46,11 +55,16 @@ module.exports = { node: true, }, extends: ['plugin:n/recommended'], + rules: {}, }, { // test files files: ['tests/**/*-test.{js,ts}'], extends: ['plugin:qunit/recommended'], + rules: { + 'qunit/no-assert-equal': 1, + 'qunit/require-expect': 1, + }, }, ], }; diff --git a/addon/-private/parachute-event.js b/addon/-private/parachute-event.js index 47cb7f6..603abf0 100644 --- a/addon/-private/parachute-event.js +++ b/addon/-private/parachute-event.js @@ -45,7 +45,7 @@ export default class ParachuteEvent { return changedParams; }, {}, - undefined + undefined, ); /** @@ -57,7 +57,7 @@ export default class ParachuteEvent { * Whether or not a model refresh should occur */ this.shouldRefresh = emberArray(keys(this.changed)).any( - key => queryParams[key].refresh + (key) => queryParams[key].refresh, ); /** diff --git a/addon/-private/parachute-meta.js b/addon/-private/parachute-meta.js index 2d77c79..e88260c 100644 --- a/addon/-private/parachute-meta.js +++ b/addon/-private/parachute-meta.js @@ -24,9 +24,9 @@ export default class ParachuteMeta { }, {}); this.queryParamsArray = emberArray( - keys(this.queryParams).map(key => { + keys(this.queryParams).map((key) => { return this.queryParams[key]; - }) + }), ); this.qpMapForController = this.queryParamsArray.reduce( @@ -34,12 +34,12 @@ export default class ParachuteMeta { qps[key] = { as, scope }; return qps; }, - {} + {}, ); // Meta info used by the decorators Object.defineProperty(this.qpMapForController, PARACHUTE_QPS, { - value: true + value: true, }); this.qpMapForRoute = this.queryParamsArray.reduce( @@ -47,7 +47,7 @@ export default class ParachuteMeta { qps[key] = { replace }; return qps; }, - {} + {}, ); this.defaultValues = this.queryParamsArray.reduce( @@ -55,7 +55,7 @@ export default class ParachuteMeta { defaults[key] = defaultValue; return defaults; }, - {} + {}, ); } } diff --git a/addon/-private/query-param.js b/addon/-private/query-param.js index e35e7b1..7d4e138 100644 --- a/addon/-private/query-param.js +++ b/addon/-private/query-param.js @@ -15,7 +15,7 @@ export default class QueryParam { constructor(key, options = {}) { assert( `[ember-parachute] You must specify a key to the QueryParam Class`, - isPresent(key) + isPresent(key), ); this.key = key; diff --git a/addon/-private/state.js b/addon/-private/state.js index a1a21db..7025e05 100644 --- a/addon/-private/state.js +++ b/addon/-private/state.js @@ -19,12 +19,12 @@ function queryParamsState(queryParamsArray, controller) { serializedValue: qp.serializedValue(controller), as: qp.as, defaultValue: qp.defaultValue, - changed: JSON.stringify(value) !== JSON.stringify(qp.defaultValue) + changed: JSON.stringify(value) !== JSON.stringify(qp.defaultValue), }; return state; }, {}, - undefined + undefined, ); } @@ -39,7 +39,7 @@ function queryParamsState(queryParamsArray, controller) { export default function queryParamsStateFor(controller) { assert( '[ember-parachute] Cannot construct query params state object without a controller', - isPresent(controller) + isPresent(controller), ); let { queryParamsArray } = QueryParams.metaFor(controller); return queryParamsState(queryParamsArray, controller); diff --git a/addon/decorators/-private/query-params-for.js b/addon/decorators/-private/query-params-for.js index d1000e9..2010d0d 100644 --- a/addon/decorators/-private/query-params-for.js +++ b/addon/decorators/-private/query-params-for.js @@ -11,6 +11,6 @@ export function getQueryParamsFor(klass) { export function addQueryParamFor(klass, key, definition) { QP_MAP.set( klass, - getQueryParamsFor(klass).extend({ [key]: definition || {} }) + getQueryParamsFor(klass).extend({ [key]: definition || {} }), ); } diff --git a/addon/decorators/query-param.js b/addon/decorators/query-param.js index ed0db88..0921a11 100644 --- a/addon/decorators/query-param.js +++ b/addon/decorators/query-param.js @@ -2,7 +2,7 @@ import { A } from '@ember/array'; import { PARACHUTE_QPS } from 'ember-parachute/-private/symbols'; import { addQueryParamFor, - getQueryParamsFor + getQueryParamsFor, } from './-private/query-params-for'; function createDescriptor(desc, qpDefinition) { @@ -30,7 +30,7 @@ function createDescriptor(desc, qpDefinition) { } return klass; - } + }, }; if (desc.kind === 'field') { @@ -53,5 +53,5 @@ export default function queryParam(qpDefinition) { } // Handle `@queryParam()` usage - return desc => createDescriptor(desc, qpDefinition); + return (desc) => createDescriptor(desc, qpDefinition); } diff --git a/addon/decorators/with-parachute.js b/addon/decorators/with-parachute.js index 331c122..1cd4031 100644 --- a/addon/decorators/with-parachute.js +++ b/addon/decorators/with-parachute.js @@ -7,6 +7,6 @@ export default function withParachute(desc) { klass.reopen(new QueryParams().Mixin); return klass; - } + }, }; } diff --git a/addon/initializers/ember-parachute.js b/addon/initializers/ember-parachute.js index 0cf3f5c..bc580bf 100644 --- a/addon/initializers/ember-parachute.js +++ b/addon/initializers/ember-parachute.js @@ -88,7 +88,7 @@ export function initialize(/* application */) { // Check if routeInfos have already been loaded. // If so, don't return a promise as it will result in // the loading screen/state flashing. - if (routeInfos.every(x => x.isResolved)) { + if (routeInfos.every((x) => x.isResolved)) { return this._super(params, transition); } @@ -97,20 +97,20 @@ export function initialize(/* application */) { // https://github.com/emberjs/ember.js/issues/15291 const _super = this._super.bind(this); - return RSVP.all(routeInfos.map(x => x.routePromise)).then(() => - _super(params, transition) + return RSVP.all(routeInfos.map((x) => x.routePromise)).then(() => + _super(params, transition), ); } else { const { handlerInfos } = transition; - if (!handlerInfos.find(x => !x.handler)) { + if (!handlerInfos.find((x) => !x.handler)) { return this._super(params, transition); } const _super = this._super.bind(this); - return RSVP.all(handlerInfos.map(x => x.handlerPromise)).then(() => - _super(params, transition) + return RSVP.all(handlerInfos.map((x) => x.handlerPromise)).then(() => + _super(params, transition), ); } }, @@ -190,11 +190,15 @@ export function initialize(/* application */) { */ _setupParachuteQueryParamsMap(controller) { if (!this.__hasSetupParachuteQPs) { - let qpMap = this.get('queryParams'); + let qpMap = this.queryParams; let { qpMapForRoute } = QueryParams.metaFor(controller); - keys(qpMapForRoute).forEach(key => { - qpMapForRoute[key] = Object.assign({}, qpMapForRoute[key], qpMap[key]); + keys(qpMapForRoute).forEach((key) => { + qpMapForRoute[key] = Object.assign( + {}, + qpMapForRoute[key], + qpMap[key], + ); }); this.set('queryParams', qpMapForRoute); @@ -219,13 +223,13 @@ export function initialize(/* application */) { this._scheduleParachuteChangeEvent( routeName, controller, - Object.assign({}, changed, removed) + Object.assign({}, changed, removed), ); } return this._super(...arguments); - } - } + }, + }, }); Route.reopenClass({ _didInitializeParachute: true }); @@ -233,5 +237,5 @@ export function initialize(/* application */) { export default { name: 'ember-parachute', - initialize + initialize, }; diff --git a/addon/query-params.js b/addon/query-params.js index bb7d423..b450b0c 100644 --- a/addon/query-params.js +++ b/addon/query-params.js @@ -60,7 +60,7 @@ export default class QueryParams { static metaFor(controller) { assert( `[ember-parachute] The controller '${controller}' is not set up with ember-parachute.`, - this.hasParachute(controller) + this.hasParachute(controller), ); return get(controller, PARACHUTE_META); } @@ -114,7 +114,7 @@ export default class QueryParams { return qps; }, {}, - undefined + undefined, ); } @@ -150,7 +150,7 @@ export default class QueryParams { return defaults; }, {}, - undefined + undefined, ); setProperties(controller, defaults); @@ -171,7 +171,7 @@ export default class QueryParams { let { queryParams } = this.metaFor(controller); assert( `[ember-parachute] The query parameter '${param}' does not exist.`, - queryParams[param] + queryParams[param], ); set(queryParams[param], 'defaultValue', defaultValue); } @@ -195,11 +195,8 @@ export default class QueryParams { * @returns {Ember.Mixin} */ _generateMixin() { - let { - queryParams, - defaultValues, - qpMapForController - } = this._generateMeta(); + let { queryParams, defaultValues, qpMapForController } = + this._generateMeta(); let ControllerMixin = Mixin.create(defaultValues, { /** @@ -230,7 +227,7 @@ export default class QueryParams { * @public * @property {Ember.ComputedProperty} */ - allQueryParams: computed(...keys(queryParams), function() { + allQueryParams: computed(...keys(queryParams), function () { return QueryParams.queryParamsFor(this); }).readOnly(), @@ -243,9 +240,9 @@ export default class QueryParams { queryParamsState: computed( ...keys(queryParams), `${PARACHUTE_META}.queryParamsArray.@each.defaultValue`, - function() { + function () { return QueryParams.stateFor(this); - } + }, ).readOnly(), /** @@ -269,7 +266,7 @@ export default class QueryParams { */ setDefaultQueryParamValue(key, defaultValue) { QueryParams.setDefaultValue(this, key, defaultValue); - } + }, }); return ControllerMixin; diff --git a/addon/utils/lookup-controller.js b/addon/utils/lookup-controller.js index 0df95af..28313b5 100644 --- a/addon/utils/lookup-controller.js +++ b/addon/utils/lookup-controller.js @@ -1,4 +1,3 @@ -import { get } from '@ember/object'; import { getOwner } from '@ember/application'; /** @@ -10,7 +9,7 @@ import { getOwner } from '@ember/application'; * @returns {Ember.Controller} */ export default function lookupController(route, ownerLookupFn = getOwner) { - let controller = get(route, 'controller'); + let controller = route.controller; if (!controller) { /** @@ -19,10 +18,9 @@ export default function lookupController(route, ownerLookupFn = getOwner) { * (especially with authentication) due to the controller being created * prematurely. */ - let controllerName = - get(route, 'controllerName') || get(route, 'routeName'); + let controllerName = route.controllerName || route.routeName; let factory = ownerLookupFn(route).factoryFor( - `controller:${controllerName}` + `controller:${controllerName}`, ); return factory.class.proto(); } diff --git a/app/initializers/ember-parachute.js b/app/initializers/ember-parachute.js index e53a50a..3710aa4 100644 --- a/app/initializers/ember-parachute.js +++ b/app/initializers/ember-parachute.js @@ -1 +1,4 @@ -export { default, initialize } from 'ember-parachute/initializers/ember-parachute'; +export { + default, + initialize, +} from 'ember-parachute/initializers/ember-parachute'; diff --git a/config/changelog.js b/config/changelog.js index 4b19551..5cb8d60 100644 --- a/config/changelog.js +++ b/config/changelog.js @@ -2,7 +2,6 @@ // For details on each option run `ember help release` module.exports = { - // angular style guide: https://github.com/angular/angular.js/blob/v1.4.8/CONTRIBUTING.md#commit // jquery style guide: https://contribute.jquery.org/commits-and-pull-requests/#commit-guidelines // ember style guide: https://github.com/emberjs/ember.js/blob/master/CONTRIBUTING.md#commit-tagging @@ -18,6 +17,5 @@ module.exports = { groupSort: function(commits) { return { commits: commits }; }, format: function(commit) { return commit.title; }, */ - } - + }, }; diff --git a/config/release.js b/config/release.js index a0bfb22..ce3c32b 100644 --- a/config/release.js +++ b/config/release.js @@ -1,18 +1,17 @@ var execSync = require('child_process').execSync; -// eslint-disable-next-line node/no-unpublished-require -var generateChangelog = require('ember-cli-changelog/lib/tasks/release-with-changelog'); +// var generateChangelog = require('ember-cli-changelog/lib/tasks/release-with-changelog'); module.exports = { publish: true, - beforeCommit: generateChangelog, + // beforeCommit: generateChangelog, - afterPublish: function(project, versions) { + afterPublish: function (project, versions) { runCommand( - 'ember github-pages:commit --message "Released ' + versions.next + '"' + 'ember github-pages:commit --message "Released ' + versions.next + '"', ); runCommand('git push origin gh-pages:gh-pages'); - } + }, }; function runCommand(command) { diff --git a/package.json b/package.json index 5d7090f..9f843e1 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "scripts": { "build": "ember build --environment=production", "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", - "lint:css": "stylelint \"**/*.css\"", + "lint:css": "stylelint \"**/*.css\" --allow-empty-input", "lint:css:fix": "concurrently \"npm:lint:css -- --fix\"", "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", "lint:hbs": "ember-template-lint .", diff --git a/tests/dummy/app/controllers/index.js b/tests/dummy/app/controllers/index.js index 078daad..7ddf3e5 100644 --- a/tests/dummy/app/controllers/index.js +++ b/tests/dummy/app/controllers/index.js @@ -13,7 +13,7 @@ export default class IndexController extends Controller { }, deserialize(value) { return value === 'open' ? true : false; - } + }, }) parachuteOpen = true; @@ -28,17 +28,21 @@ export default class IndexController extends Controller { }, deserialize(value = '') { return value.split(','); - } + }, }) tags = ['Ember', 'Parachute']; get queryParamsChanged() { - return this.queryParamsState.page.changed || this.queryParamsState.search.changed || this.queryParamsState.tags.changed + return ( + this.queryParamsState.page.changed || + this.queryParamsState.search.changed || + this.queryParamsState.tags.changed + ); } setup({ queryParams }) { if (queryParams.parachuteOpen) { - this.get('fetchModel').perform(); + this.fetchModel.perform(); } } @@ -50,7 +54,7 @@ export default class IndexController extends Controller { queryParamsDidChange({ shouldRefresh, queryParams }) { if (shouldRefresh && queryParams.parachuteOpen) { - this.get('fetchModel').perform(); + this.fetchModel.perform(); } } @@ -76,8 +80,8 @@ export default class IndexController extends Controller { @action setDefaults() { - ['search', 'page', 'tags'].forEach(key => { - let value = key === 'tags' ? this.get(key).concat() : this.get(key); + ['search', 'page', 'tags'].forEach((key) => { + let value = key === 'tags' ? this[key].concat() : this[key]; this.setDefaultQueryParamValue(key, value); }); } diff --git a/tests/dummy/app/routes/index.js b/tests/dummy/app/routes/index.js index 812aee5..1368a8a 100644 --- a/tests/dummy/app/routes/index.js +++ b/tests/dummy/app/routes/index.js @@ -6,12 +6,12 @@ export default Route.extend({ queryParams: { page: { refreshModel: true }, tags: { refreshModel: true }, - search: { refreshModel: true } + search: { refreshModel: true }, }, model({ parachuteOpen }) { if (!parachuteOpen) { - return new Promise(resolve => later(resolve, 1000)); + return new Promise((resolve) => later(resolve, 1000)); } - } + }, }); diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index c12b05a..57dc933 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -1,4 +1,4 @@ -
+
docs not rendered because ember-paper has been uninstalled as it not Ember-5-compatible {{!-- {{#paper-card class="box" as |card|}} diff --git a/tests/dummy/config/targets.js b/tests/dummy/config/targets.js index 42927b5..1e669fa 100644 --- a/tests/dummy/config/targets.js +++ b/tests/dummy/config/targets.js @@ -1,9 +1,6 @@ 'use strict'; -const browsers = [ - 'last 1 Chrome versions', - 'last 1 Firefox versions' -]; +const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions']; module.exports = { browsers, diff --git a/tests/unit/-private/meta-test.js b/tests/unit/-private/meta-test.js index cf6f7f6..25134a5 100644 --- a/tests/unit/-private/meta-test.js +++ b/tests/unit/-private/meta-test.js @@ -1,20 +1,20 @@ import ParachuteMeta from 'ember-parachute/-private/parachute-meta'; import { module, test } from 'qunit'; -module('Unit | Implementation | meta', function() { +module('Unit | Implementation | meta', function () { const dummyQpMap = { foo: { defaultValue: 'foo', - refresh: true + refresh: true, }, bar: { defaultValue: 1, as: 'BAR', - replace: true - } + replace: true, + }, }; - test('#queryParams', function(assert) { + test('#queryParams', function (assert) { let expectedResult = { bar: { as: 'BAR', @@ -24,7 +24,7 @@ module('Unit | Implementation | meta', function() { refresh: false, replace: true, scope: undefined, - serialize: undefined + serialize: undefined, }, foo: { as: 'foo', @@ -34,15 +34,15 @@ module('Unit | Implementation | meta', function() { refresh: true, replace: false, scope: undefined, - serialize: undefined - } + serialize: undefined, + }, }; let meta = new ParachuteMeta(dummyQpMap); assert.propEqual(meta.queryParams, expectedResult); }); - test('#queryParamsArray', function(assert) { + test('#queryParamsArray', function (assert) { let expectedResult = [ { as: 'foo', @@ -52,7 +52,7 @@ module('Unit | Implementation | meta', function() { refresh: true, replace: false, scope: undefined, - serialize: undefined + serialize: undefined, }, { as: 'BAR', @@ -62,8 +62,8 @@ module('Unit | Implementation | meta', function() { refresh: false, replace: true, scope: undefined, - serialize: undefined - } + serialize: undefined, + }, ]; let { queryParamsArray } = new ParachuteMeta(dummyQpMap); @@ -71,40 +71,40 @@ module('Unit | Implementation | meta', function() { assert.propEqual(queryParamsArray.objectAt(1), expectedResult[1]); }); - test('#qpMapForController', function(assert) { + test('#qpMapForController', function (assert) { let expectedResult = { foo: { as: 'foo', - scope: undefined + scope: undefined, }, bar: { as: 'BAR', - scope: undefined - } + scope: undefined, + }, }; let meta = new ParachuteMeta(dummyQpMap); assert.propEqual(meta.qpMapForController, expectedResult); }); - test('#qpMapForRoute', function(assert) { + test('#qpMapForRoute', function (assert) { let expectedResult = { foo: { - replace: false + replace: false, }, bar: { - replace: true - } + replace: true, + }, }; let meta = new ParachuteMeta(dummyQpMap); assert.propEqual(meta.qpMapForRoute, expectedResult); }); - test('#defaultValues', function(assert) { + test('#defaultValues', function (assert) { let expectedResult = { foo: 'foo', - bar: 1 + bar: 1, }; let meta = new ParachuteMeta(dummyQpMap); diff --git a/tests/unit/decorators-test.js b/tests/unit/decorators-test.js index b2cb305..9bd1215 100644 --- a/tests/unit/decorators-test.js +++ b/tests/unit/decorators-test.js @@ -9,7 +9,7 @@ class WithParachuteController extends EmberObject {} class QPController extends EmberObject { @queryParam({ as: 'dir', - refresh: true + refresh: true, }) direction = 'asc'; @@ -18,37 +18,37 @@ class QPController extends EmberObject { @queryParam({ refresh: true, serialize() {}, - deserialize() {} + deserialize() {}, }) color = []; } -module('Unit | Decorators', function() { +module('Unit | Decorators', function () { let controller; - module('withParachute', function(hooks) { - hooks.beforeEach(function() { + module('withParachute', function (hooks) { + hooks.beforeEach(function () { controller = WithParachuteController.create(); }); - test('it works', function(assert) { + test('it works', function (assert) { assert.ok(QueryParams.metaFor(controller)); }); }); - module('queryParam', function(hooks) { - hooks.beforeEach(function() { + module('queryParam', function (hooks) { + hooks.beforeEach(function () { controller = QPController.create(); }); - test('it works', function(assert) { + test('it works', function (assert) { const { queryParams, queryParamsArray } = QueryParams.metaFor(controller); assert.equal(queryParamsArray.length, 3); assert.deepEqual(Object.keys(queryParams), [ 'direction', 'page', - 'color' + 'color', ]); assert.equal(queryParams.direction.as, 'dir'); assert.equal(queryParams.page.defaultValue, 1); diff --git a/tests/unit/query-params-test.js b/tests/unit/query-params-test.js index eb9613d..e8916c6 100644 --- a/tests/unit/query-params-test.js +++ b/tests/unit/query-params-test.js @@ -8,15 +8,15 @@ const queryParams = new QueryParams({ direction: { as: 'dir', defaultValue: 'asc', - refresh: true + refresh: true, }, page: { defaultValue: 1, - refresh: true + refresh: true, }, search: { defaultValue: '', - refresh: true + refresh: true, }, colors: { defaultValue: [], @@ -28,15 +28,15 @@ const queryParams = new QueryParams({ deserialize(value = '', controller) { assertController(controller); return value.split(','); - } - } + }, + }, }); const defaultValues = { direction: 'asc', page: 1, search: '', - colors: [] + colors: [], }; const Controller = EmberObject.extend(queryParams.Mixin); @@ -45,17 +45,17 @@ let controller; function assertController(controller) { if (!(controller instanceof Controller)) { throw new Error( - 'Expected the controller to be passed as the second parameter to serialize / deserialize.' + 'Expected the controller to be passed as the second parameter to serialize / deserialize.', ); } } -module('Unit | QueryParams', function(hooks) { - hooks.beforeEach(function() { +module('Unit | QueryParams', function (hooks) { + hooks.beforeEach(function () { controller = Controller.create(); }); - test('create', function(assert) { + test('create', function (assert) { assert.expect(2); let QP, controller, queryParams; @@ -63,7 +63,7 @@ module('Unit | QueryParams', function(hooks) { QP = new QueryParams( { foo: { defaultValue: 1 } }, { bar: { defaultValue: 1 } }, - { baz: { defaultValue: 1 } } + { baz: { defaultValue: 1 } }, ); controller = EmberObject.extend(QP.Mixin).create(); queryParams = QueryParams.metaFor(controller).queryParams; @@ -73,7 +73,7 @@ module('Unit | QueryParams', function(hooks) { QP = new QueryParams( { foo: { defaultValue: 1 } }, { bar: { defaultValue: 1 } }, - { bar: { defaultValue: undefined } } + { bar: { defaultValue: undefined } }, ); controller = EmberObject.extend(QP.Mixin).create(); queryParams = QueryParams.metaFor(controller).queryParams; @@ -81,7 +81,7 @@ module('Unit | QueryParams', function(hooks) { assert.deepEqual(keys(queryParams), ['foo', 'bar']); }); - test('extend', function(assert) { + test('extend', function (assert) { assert.expect(1); let QP = new QueryParams({ foo: { defaultValue: 1 } }); @@ -90,12 +90,12 @@ module('Unit | QueryParams', function(hooks) { assert.deepEqual(keys(QP.queryParams), ['foo', 'bar', 'baz']); }); - test('QP Normalization', function(assert) { + test('QP Normalization', function (assert) { assert.expect(5); let QP = new QueryParams({ foo: { defaultValue: 1 }, - bar: { defaultValue: 1, as: '_bar_' } + bar: { defaultValue: 1, as: '_bar_' }, }); controller = EmberObject.extend(QP.Mixin).create(); @@ -109,7 +109,7 @@ module('Unit | QueryParams', function(hooks) { assert.equal(queryParams.bar.as, '_bar_'); }); - test('setDefaultQueryParamValue + resetQueryParams', function(assert) { + test('setDefaultQueryParamValue + resetQueryParams', function (assert) { assert.expect(4); assert.equal(controller.get('page'), 1); @@ -124,7 +124,7 @@ module('Unit | QueryParams', function(hooks) { assert.equal(controller.get('page'), 2); }); - test('resetQueryParams - all', function(assert) { + test('resetQueryParams - all', function (assert) { assert.expect(2); let changes = { page: 2, direction: 'desc' }; @@ -132,14 +132,14 @@ module('Unit | QueryParams', function(hooks) { controller.setProperties(changes); assert.deepEqual( controller.get('allQueryParams'), - Object.assign({}, defaultValues, changes) + Object.assign({}, defaultValues, changes), ); controller.resetQueryParams(); assert.deepEqual(controller.get('allQueryParams'), defaultValues); }); - test('resetQueryParams - individual', function(assert) { + test('resetQueryParams - individual', function (assert) { assert.expect(2); let changes = { page: 2, direction: 'desc', search: 'date' }; @@ -147,24 +147,24 @@ module('Unit | QueryParams', function(hooks) { controller.setProperties(changes); assert.deepEqual( controller.get('allQueryParams'), - Object.assign({}, defaultValues, changes) + Object.assign({}, defaultValues, changes), ); controller.resetQueryParams(['search', 'page']); assert.deepEqual( controller.get('allQueryParams'), - Object.assign(defaultValues, { direction: 'desc' }) + Object.assign(defaultValues, { direction: 'desc' }), ); }); - test('CP - allQueryParams', function(assert) { + test('CP - allQueryParams', function (assert) { assert.expect(2); assert.deepEqual(controller.get('allQueryParams'), { direction: 'asc', page: 1, search: '', - colors: [] + colors: [], }); controller.set('page', 2); @@ -173,11 +173,11 @@ module('Unit | QueryParams', function(hooks) { direction: 'asc', page: 2, search: '', - colors: [] + colors: [], }); }); - test('CP - queryParamsState', function(assert) { + test('CP - queryParamsState', function (assert) { assert.expect(4); assert.deepEqual(controller.get('queryParamsState.page'), { @@ -185,7 +185,7 @@ module('Unit | QueryParams', function(hooks) { defaultValue: 1, changed: false, as: 'page', - serializedValue: 1 + serializedValue: 1, }); controller.set('page', 2); @@ -195,7 +195,7 @@ module('Unit | QueryParams', function(hooks) { defaultValue: 1, changed: true, as: 'page', - serializedValue: 2 + serializedValue: 2, }); controller.setDefaultQueryParamValue('page', 2); @@ -205,7 +205,7 @@ module('Unit | QueryParams', function(hooks) { defaultValue: 2, changed: false, as: 'page', - serializedValue: 2 + serializedValue: 2, }); controller.set('colors', ['red', 'blue']); @@ -215,7 +215,7 @@ module('Unit | QueryParams', function(hooks) { serializedValue: 'red,blue', defaultValue: [], changed: true, - as: 'colors' + as: 'colors', }); }); }); diff --git a/tests/unit/routes/route-test.js b/tests/unit/routes/route-test.js index c25ee41..c024cab 100644 --- a/tests/unit/routes/route-test.js +++ b/tests/unit/routes/route-test.js @@ -11,33 +11,33 @@ const queryParams = new QueryParams({ direction: { as: 'dir', defaultValue: 'asc', - refresh: true + refresh: true, }, page: { defaultValue: 1, refresh: true, - replace: true + replace: true, }, search: { defaultValue: '', - refresh: true - } + refresh: true, + }, }); const QPController = Controller.extend(queryParams.Mixin); let route; -module('Unit | Route', function(hooks) { +module('Unit | Route', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { run(() => { this.owner.register('route:foo', Route.extend()); route = this.owner.lookup('route:foo'); }); }); - test('#setup', function(assert) { + test('#setup', function (assert) { assert.expect(2); let controller = QPController.extend({ @@ -45,15 +45,15 @@ module('Unit | Route', function(hooks) { assert.ok(event instanceof ParachuteEvent); }, - onSetup: on('setup', function(event) { + onSetup: on('setup', function (event) { assert.ok(event instanceof ParachuteEvent); - }) + }), }).create(); route.setupController(controller); }); - test('#reset', function(assert) { + test('#reset', function (assert) { assert.expect(4); let controller = QPController.extend({ @@ -62,16 +62,16 @@ module('Unit | Route', function(hooks) { assert.equal(typeof isExiting, 'boolean'); }, - onReset: on('reset', function(event, isExiting) { + onReset: on('reset', function (event, isExiting) { assert.ok(event instanceof ParachuteEvent); assert.equal(typeof isExiting, 'boolean'); - }) + }), }).create(); route.resetController(controller, true); }); - test('#queryParamsDidChange', function(assert) { + test('#queryParamsDidChange', function (assert) { assert.expect(2); let controller = QPController.extend({ @@ -79,14 +79,14 @@ module('Unit | Route', function(hooks) { assert.ok(event instanceof ParachuteEvent); }, - onReset: on('queryParamsDidChange', function(event) { + onReset: on('queryParamsDidChange', function (event) { assert.ok(event instanceof ParachuteEvent); - }) + }), }).create(); route.setProperties({ routeName: 'foo', - controller + controller, }); run(() => { @@ -94,13 +94,13 @@ module('Unit | Route', function(hooks) { }); }); - test('route queryParams map', function(assert) { + test('route queryParams map', function (assert) { assert.expect(1); let controller = QPController.create(); route.set('queryParams', { - search: { refreshModel: true } + search: { refreshModel: true }, }); route.setupController(controller); @@ -108,7 +108,7 @@ module('Unit | Route', function(hooks) { assert.propEqual(route.get('queryParams'), { direction: { replace: false }, page: { replace: true }, - search: { replace: false, refreshModel: true } + search: { replace: false, refreshModel: true }, }); }); }); diff --git a/tests/unit/utils/lookup-controller-test.js b/tests/unit/utils/lookup-controller-test.js index 5ae983b..5d2362c 100644 --- a/tests/unit/utils/lookup-controller-test.js +++ b/tests/unit/utils/lookup-controller-test.js @@ -2,13 +2,13 @@ import EmberController from '@ember/controller'; import lookupController from 'ember-parachute/utils/lookup-controller'; import { module, test } from 'qunit'; -module('Unit | Utility | lookup controller', function() { +module('Unit | Utility | lookup controller', function () { const Controller = EmberController.extend({ - parachuteController: true + parachuteController: true, }); const dummyRoute = { - controller: Controller.create() + controller: Controller.create(), }; function dummyLookup() { @@ -16,25 +16,25 @@ module('Unit | Utility | lookup controller', function() { factoryFor() { return { create: () => Controller.create(), - class: Controller + class: Controller, }; - } + }, }; } - test('it looks up the controller from a route', function(assert) { + test('it looks up the controller from a route', function (assert) { let result = lookupController(dummyRoute); assert.ok(result.parachuteController); }); - test('it looks up the controller from a route owner if route controller is not defined', function(assert) { + test('it looks up the controller from a route owner if route controller is not defined', function (assert) { let result = lookupController({}, dummyLookup); assert.ok(result.parachuteController); }); - test('it looks up the controller from a route when it has controllerName set', function(assert) { + test('it looks up the controller from a route when it has controllerName set', function (assert) { let dummyRouteWithControllerName = { - controllerName: 'something.else' + controllerName: 'something.else', }; let result = lookupController(dummyRouteWithControllerName, dummyLookup);