From 6441021de50bc99291e24a8858621bd3dad53c00 Mon Sep 17 00:00:00 2001 From: Markus Sanin Date: Fri, 17 Nov 2023 16:10:01 +0100 Subject: [PATCH] Fix lint --- .eslintrc.js | 3 + compile-css.js | 2 +- .../components/basic-dropdown-test.js | 98 +++++++++---------- tests/integration/components/content-test.js | 22 ++--- tests/integration/components/trigger-test.js | 56 +++++------ tests/unit/utils/scroll-helpers-test.js | 4 +- 6 files changed, 94 insertions(+), 91 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9101ddcd..aedae4d6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -61,6 +61,9 @@ module.exports = { // test files files: ['tests/**/*-test.{js,ts}'], extends: ['plugin:qunit/recommended'], + rules: { + 'qunit/require-expect': 'off', + }, }, ], }; diff --git a/compile-css.js b/compile-css.js index 17c69409..256a739d 100644 --- a/compile-css.js +++ b/compile-css.js @@ -6,7 +6,7 @@ var inputFile = path.join( __dirname, 'app', 'styles', - 'ember-basic-dropdown.scss' + 'ember-basic-dropdown.scss', ); var outputFile = path.join(__dirname, 'vendor', 'ember-basic-dropdown.css'); var buf = fs.readFileSync(inputFile, 'utf8'); diff --git a/tests/integration/components/basic-dropdown-test.js b/tests/integration/components/basic-dropdown-test.js index e517eab8..c9157b47 100644 --- a/tests/integration/components/basic-dropdown-test.js +++ b/tests/integration/components/basic-dropdown-test.js @@ -108,11 +108,11 @@ module('Integration | Component | basic-dropdown', function (hooks) { this.willOpen = function (dropdown, e) { assert.false( dropdown.isOpen, - 'The received dropdown has a `isOpen` property that is still false' + 'The received dropdown has a `isOpen` property that is still false', ); assert.ok( Object.prototype.hasOwnProperty.call(dropdown, 'actions'), - 'The received dropdown has a `actions` property' + 'The received dropdown has a `actions` property', ); assert.ok(!!e, 'Receives an argument as second argument'); assert.ok(true, 'onOpen action was invoked'); @@ -157,11 +157,11 @@ module('Integration | Component | basic-dropdown', function (hooks) { this.willClose = function (dropdown, e) { assert.true( dropdown.isOpen, - 'The received dropdown has a `isOpen` property and its value is `true`' + 'The received dropdown has a `isOpen` property and its value is `true`', ); assert.ok( Object.prototype.hasOwnProperty.call(dropdown, 'actions'), - 'The received dropdown has a `actions` property' + 'The received dropdown has a `actions` property', ); assert.ok(!!e, 'Receives an argument as second argument'); assert.ok(true, 'onClose action was invoked'); @@ -281,13 +281,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--right', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -306,13 +306,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--center', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--center', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -331,13 +331,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--right', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -356,13 +356,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--above', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--above', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -397,13 +397,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--in-place', - 'The trigger has a special `--in-place` class' + 'The trigger has a special `--in-place` class', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--in-place', - 'The content has a special `--in-place` class' + 'The content has a special `--in-place` class', ); }); @@ -422,7 +422,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--below', - 'The content has a class indicating that it was placed below the trigger' + 'The content has a class indicating that it was placed below the trigger', ); await render(hbs` @@ -437,7 +437,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--above', - 'The content has a class indicating that it was placed above the trigger' + 'The content has a class indicating that it was placed above the trigger', ); }); @@ -457,7 +457,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--in-place', - 'The trigger has a special `--in-place` class' + 'The trigger has a special `--in-place` class', ); }); @@ -476,13 +476,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--right', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -501,13 +501,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-trigger') .hasClass( 'ember-basic-dropdown-trigger--right', - 'The proper class has been added' + 'The proper class has been added', ); assert .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The proper class has been added' + 'The proper class has been added', ); }); @@ -615,12 +615,12 @@ module('Integration | Component | basic-dropdown', function (hooks) { assert .dom( - this.element.querySelector('.ember-basic-dropdown-content').parentNode + this.element.querySelector('.ember-basic-dropdown-content').parentNode, ) .hasAttribute( 'id', 'id-of-elmnt', - 'The content has been rendered in an alternative destination' + 'The content has been rendered in an alternative destination', ); }); @@ -641,7 +641,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .hasAttribute( 'aria-controls', content.id, - 'The trigger controls the content' + 'The trigger controls the content', ); }); @@ -658,7 +658,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom(trigger.parentNode) .doesNotHaveAttribute( 'aria-owns', - 'Closed dropdown parent does not have aria-owns' + 'Closed dropdown parent does not have aria-owns', ); await click('.ember-basic-dropdown-trigger'); let content = this.element.querySelector('.ember-basic-dropdown-content'); @@ -667,7 +667,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .hasAttribute( 'aria-owns', content.id, - 'The trigger parent owns the content' + 'The trigger parent owns the content', ); }); @@ -703,7 +703,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { triggerElement, dropdownElement, destinationElement, - { dropdown } + { dropdown }, ) { assert.ok(dropdown, 'dropdown should be passed to the component'); return { @@ -732,14 +732,14 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The dropdown is in the right' + 'The dropdown is in the right', ); assert .dom('.ember-basic-dropdown-content') .hasAttribute( 'style', 'top: 111px; width: 100px; height: 110px;', - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); }); @@ -749,7 +749,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { triggerElement, dropdownElement, destinationElement, - { dropdown, renderInPlace } + { dropdown, renderInPlace }, ) { assert.ok(dropdown, 'dropdown should be passed to the component'); if (renderInPlace) { @@ -788,13 +788,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasClass( 'ember-basic-dropdown-content--right', - 'The dropdown is in the right' + 'The dropdown is in the right', ); assert .dom('.ember-basic-dropdown-content') .hasStyle( { top: '111px', right: '222px' }, - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); }); @@ -849,7 +849,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { assert.strictEqual( apis.length, 3, - 'There have been 3 changes in the state of the public API' + 'There have been 3 changes in the state of the public API', ); assert.false(apis[0].isOpen, 'The component was closed'); assert.true(apis[1].isOpen, 'Then it opened'); @@ -949,7 +949,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { assert .dom('.body-grandchild') .doesNotExist( - 'grandchild dropdown should not exist becuase we clicked in child' + 'grandchild dropdown should not exist becuase we clicked in child', ); assert .dom('.body-child') @@ -963,12 +963,12 @@ module('Integration | Component | basic-dropdown', function (hooks) { assert .dom('.body-grandchild') .doesNotExist( - 'grandchild dropdown should not exist becuase we clicked in parent' + 'grandchild dropdown should not exist becuase we clicked in parent', ); assert .dom('.body-child') .doesNotExist( - 'child dropdown should not exist becuase we clicked in parent' + 'child dropdown should not exist becuase we clicked in parent', ); assert .dom('.body-parent') @@ -1058,7 +1058,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .ember-basic-dropdown--transitioning-in{animation: grow-out 1s ease-out;} .ember-basic-dropdown--transitioning-out{animation: drop-fade-below 1s reverse;} - ` + `, ); await render(hbs` @@ -1074,13 +1074,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom(`.${basicDropdownContentClass}`) .hasClass( transitioningInClass, - `The dropdown content has .${transitioningInClass} class` + `The dropdown content has .${transitioningInClass} class`, ); await waitUntil(() => find('.ember-basic-dropdown-content').classList.contains( - transitionedInClass - ) + transitionedInClass, + ), ); await click('.ember-basic-dropdown-trigger'); @@ -1089,7 +1089,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom(`.${basicDropdownContentClass}`) .hasClass( transitioningOutClass, - `The dropdown content has .${transitioningOutClass} class` + `The dropdown content has .${transitioningOutClass} class`, ); await click('.ember-basic-dropdown-trigger'); @@ -1098,13 +1098,13 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom(`.${basicDropdownContentClass}`) .hasClass( transitioningInClass, - `After closing dropdown, the dropdown content has .${transitioningInClass} class again as initial value` + `After closing dropdown, the dropdown content has .${transitioningInClass} class again as initial value`, ); await waitUntil(() => find('.ember-basic-dropdown-content').classList.contains( - transitionedInClass - ) + transitionedInClass, + ), ); await click('.ember-basic-dropdown-trigger'); @@ -1113,7 +1113,7 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom(`.${basicDropdownContentClass}`) .hasClass( transitioningOutClass, - `The dropdown content has .${transitioningOutClass} class` + `The dropdown content has .${transitioningOutClass} class`, ); }); @@ -1161,14 +1161,14 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasStyle( { top: '111px', left: '100px' }, - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); assert .dom('.ember-basic-dropdown-content') .doesNotHaveStyle( { right: '100px' }, - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); run(() => { @@ -1179,14 +1179,14 @@ module('Integration | Component | basic-dropdown', function (hooks) { .dom('.ember-basic-dropdown-content') .hasStyle( { top: '111px', right: '100px' }, - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); assert .dom('.ember-basic-dropdown-content') .doesNotHaveStyle( { left: '100px' }, - 'The style attribute is the expected one' + 'The style attribute is the expected one', ); }); }); diff --git a/tests/integration/components/content-test.js b/tests/integration/components/content-test.js index a609ceac..ca040bec 100644 --- a/tests/integration/components/content-test.js +++ b/tests/integration/components/content-test.js @@ -95,7 +95,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { .hasAttribute( 'id', 'ember-basic-dropdown-content-e123', - 'contains the expected ID' + 'contains the expected ID', ); }); @@ -426,7 +426,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { run(() => innerScrollable.dispatchEvent(innerScrollableEvent)); assert.false( innerScrollableEvent.defaultPrevented, - 'The inner scrollable does not cancel wheel events.' + 'The inner scrollable does not cancel wheel events.', ); innerScrollable.scrollTop = 4; @@ -438,12 +438,12 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { run(() => innerScrollable.dispatchEvent(innerScrollableCanceledEvent)); assert.true( innerScrollableCanceledEvent.defaultPrevented, - 'The inner scrollable cancels out of bound wheel events.' + 'The inner scrollable cancels out of bound wheel events.', ); assert.strictEqual( innerScrollable.scrollTop, 0, - 'The innerScrollable was scrolled anyway.' + 'The innerScrollable was scrolled anyway.', ); let outerScrollable = this.element.querySelector('#outer-div'); @@ -455,7 +455,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { run(() => outerScrollable.dispatchEvent(outerScrollableEvent)); assert.true( outerScrollableEvent.defaultPrevented, - 'The outer scrollable cancels wheel events.' + 'The outer scrollable cancels wheel events.', ); }); @@ -479,7 +479,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { assert.strictEqual( repositions, 2, - 'The component has been repositioned twice' + 'The component has been repositioned twice', ); }); @@ -503,7 +503,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { assert.strictEqual( repositions, 2, - 'The component has been repositioned twice' + 'The component has been repositioned twice', ); }); @@ -527,7 +527,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { assert.strictEqual( repositions, 2, - 'The component has been repositioned twice' + 'The component has been repositioned twice', ); }); @@ -642,7 +642,7 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { assert.strictEqual( repositions, 2, - 'The component has been repositioned twice' + 'The component has been repositioned twice', ); }); @@ -689,11 +689,11 @@ module('Integration | Component | basic-dropdown-content', function (hooks) { assert.ok( dropdown.uniqueId === this.dropdown.uniqueId, - 'It receives the dropdown argument as the first argument' + 'It receives the dropdown argument as the first argument', ); assert.ok( e instanceof window.Event, - 'It receives the event as second argument' + 'It receives the event as second argument', ); assert.ok(args.length === 2, 'It receives only 2 arguments'); } diff --git a/tests/integration/components/trigger-test.js b/tests/integration/components/trigger-test.js index 0cb0fe73..7ea83d89 100644 --- a/tests/integration/components/trigger-test.js +++ b/tests/integration/components/trigger-test.js @@ -165,7 +165,7 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { `); assert.strictEqual( this.element.querySelector('.ember-basic-dropdown-trigger').tagName, - 'BUTTON' + 'BUTTON', ); assert.dom('.ember-basic-dropdown-trigger').hasAttribute('type', 'button'); }); @@ -199,11 +199,11 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.deepEqual( dropdown, this.dropdown, - 'receives the dropdown as 1st argument' + 'receives the dropdown as 1st argument', ); assert.ok( e instanceof window.Event, - 'It receives the event as second argument' + 'It receives the event as second argument', ); }; await render(hbs` @@ -222,12 +222,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -279,12 +279,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -307,12 +307,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -337,12 +337,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -364,12 +364,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -390,12 +390,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); assert.ok(e.defaultPrevented, 'The event is defaultPrevented'); }, @@ -417,12 +417,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `close()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -467,16 +467,16 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.strictEqual( e.type, 'touchend', - 'The event that toggles the dropdown is the touchend' + 'The event that toggles the dropdown is the touchend', ); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -582,7 +582,7 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { toggle: () => { assert.ok( userActionRanfirst, - 'User-supplied `{{on "mousedown"}}` ran before default `toggle`' + 'User-supplied `{{on "mousedown"}}` ran before default `toggle`', ); }, }, @@ -661,7 +661,7 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { toggle: () => { assert.ok( userActionRanfirst, - 'User-supplied `{{on "touchend"}}` ran before default `toggle`' + 'User-supplied `{{on "touchend"}}` ran before default `toggle`', ); }, }, @@ -691,7 +691,7 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.notEqual( e.type, 'touchend', - 'Default `toggle` action should not run' + 'Default `toggle` action should not run', ); }, }, @@ -720,7 +720,7 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { toggle: () => { assert.ok( userActionRanfirst, - 'User-supplied `{{on "keydown}}` ran before default `toggle`' + 'User-supplied `{{on "keydown}}` ran before default `toggle`', ); }, }, @@ -770,12 +770,12 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok(true, 'The `toggle()` action has been fired'); assert.ok( e instanceof window.Event, - 'It receives the event as first argument' + 'It receives the event as first argument', ); assert.strictEqual( arguments.length, 1, - 'It receives only one argument' + 'It receives only one argument', ); }, }, @@ -800,11 +800,11 @@ module('Integration | Component | basic-dropdown-trigger', function (hooks) { assert.ok( dropdown.uniqueId === this.dropdown.uniqueId, - 'It receives the dropdown argument as the first argument' + 'It receives the dropdown argument as the first argument', ); assert.ok( e instanceof window.Event, - 'It receives the event as second argument' + 'It receives the event as second argument', ); assert.ok(args.length === 2, 'It receives only 2 arguments'); } diff --git a/tests/unit/utils/scroll-helpers-test.js b/tests/unit/utils/scroll-helpers-test.js index c4c58501..484685e7 100644 --- a/tests/unit/utils/scroll-helpers-test.js +++ b/tests/unit/utils/scroll-helpers-test.js @@ -113,11 +113,11 @@ module('Unit | Utility | scroll helpers', function () { }); assert.strictEqual( deltaX, - originalDeltaX * scrollLineHeight * LINES_PER_PAGE + originalDeltaX * scrollLineHeight * LINES_PER_PAGE, ); assert.strictEqual( deltaY, - originalDeltaY * scrollLineHeight * LINES_PER_PAGE + originalDeltaY * scrollLineHeight * LINES_PER_PAGE, ); }); });