Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint-plugin-qunit per latest addon blueprint #516

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
],
env: {
browser: true
Expand Down Expand Up @@ -52,6 +52,11 @@ module.exports = {
},
plugins: ['node'],
extends: ['plugin:node/recommended']
},
{
// Test files:
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
}
]
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
"eslint": "^7.27.0",
"eslint-plugin-ember": "^10.4.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-qunit": "^7.0.0",
"highlightjs": "^9.16.2",
"loader.js": "^4.7.0",
"marked": "^4.0.4",
"npm-run-all": "^4.1.5",
"qunit": "^2.15.0",
"qunit": "^2.17.2",
"qunit-dom": "^1.6.0",
"release-it": "^14.7.0",
"release-it-lerna-changelog": "^3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/fastboot/rendering-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module('FastBoot | rendering test', function(hooks) {
setup(hooks);

test('renders', async function(assert) {
let res = await visit('/test-scenario');
assert.equal(res.statusCode, 200);
const res = await visit('/test-scenario');
assert.strictEqual(res.statusCode, 200);
});
});
24 changes: 12 additions & 12 deletions tests/integration/decorators/decorators-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module('Integration | decorators', function(hooks) {
test('does not trigger if helper is not rendered', async function(assert) {
await this.renderWithConditional();
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is rendered', async function(assert) {
await this.renderWithConditional();
Expand All @@ -45,7 +45,7 @@ module('Integration | decorators', function(hooks) {
await this.renderWithConditional();
this.set('shouldRenderOnKeyHelper', false);
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});
test('with an event specified', async function(assert) {
Expand All @@ -56,10 +56,10 @@ module('Integration | decorators', function(hooks) {
await render(hbs`<DecoratorExample1 @onTrigger={{this.onTrigger}} />`);

await keyUp('shift+c');
assert.ok(!onTriggerCalledWith, 'not called in keyup if event is not specified');
assert.notOk(onTriggerCalledWith, 'not called in keyup if event is not specified');

await keyDown('ctrl+alt+KeyE');
assert.ok(!onTriggerCalledWith, 'not called in keydown if keyup is specified');
assert.notOk(onTriggerCalledWith, 'not called in keydown if keyup is specified');

await keyUp('ctrl+alt+KeyE');
assert.ok(onTriggerCalledWith instanceof KeyboardEvent);
Expand Down Expand Up @@ -144,7 +144,7 @@ module('Integration | decorators', function(hooks) {
test('does not trigger if helper is not activated', async function(assert) {
await this.renderWithActivated();
await keyDown('Digit2');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is activated', async function(assert) {
await this.renderWithActivated();
Expand All @@ -157,7 +157,7 @@ module('Integration | decorators', function(hooks) {
await this.renderWithActivated();
this.set('isActivated', false);
await keyDown('Digit2');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});
});
Expand All @@ -178,7 +178,7 @@ module('Integration | decorators', function(hooks) {
test('does not trigger if helper is not rendered', async function(assert) {
await this.renderWithConditional();
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is rendered', async function(assert) {
await this.renderWithConditional();
Expand All @@ -191,7 +191,7 @@ module('Integration | decorators', function(hooks) {
await this.renderWithConditional();
this.set('shouldRenderOnKeyHelper', false);
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});
test('with an event specified', async function(assert) {
Expand All @@ -202,10 +202,10 @@ module('Integration | decorators', function(hooks) {
await render(hbs`<DecoratorExample3 @onTrigger={{this.onTrigger}} />`);

await keyUp('shift+c');
assert.ok(!onTriggerCalledWith, 'not called in keyup if event is not specified');
assert.notOk(onTriggerCalledWith, 'not called in keyup if event is not specified');

await keyDown('ctrl+alt+KeyE');
assert.ok(!onTriggerCalledWith, 'not called in keydown if keyup is specified');
assert.notOk(onTriggerCalledWith, 'not called in keydown if keyup is specified');

await keyUp('ctrl+alt+KeyE');
assert.ok(onTriggerCalledWith instanceof KeyboardEvent);
Expand Down Expand Up @@ -290,7 +290,7 @@ module('Integration | decorators', function(hooks) {
test('does not trigger if helper is not activated', async function(assert) {
await this.renderWithActivated();
await keyDown('Digit2');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is activated', async function(assert) {
await this.renderWithActivated();
Expand All @@ -303,7 +303,7 @@ module('Integration | decorators', function(hooks) {
await this.renderWithActivated();
this.set('isActivated', false);
await keyDown('Digit2');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});
});
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/helpers/if-key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { hbs } from 'ember-cli-htmlbars';

module('Integration | Helper | if-key', function(hooks) {
setupRenderingTest(hooks);

module('error cases', function(hooks) {
hooks.afterEach(() => resetOnerror());

Expand All @@ -18,11 +18,11 @@ module('Integration | Helper | if-key', function(hooks) {
"Assertion Failed: ember-keyboard: The if-key helper must be provided a function as its second argument",
'error is thrown'
);
});
});
await render(hbs`{{on-document "keydown" (if-key "alt+c" this.unknownEvent)}}`);
await triggerEvent(document.body, 'keydown', { altKey: true, key: 'c' });
});

// This doesn't work. I wish it did, but can't figure out why not.
skip('warns if called without a keyboard event', async function(assert) {
assert.expect(1);
Expand All @@ -32,10 +32,10 @@ module('Integration | Helper | if-key', function(hooks) {
"Assertion Failed: ember-keyboard: The if-key helper expects to be invoked with a KeyboardEvent",
'error is thrown'
);
});
});
await render(hbs`<button {{on 'click' (if-key "alt+c" this.onTrigger)}}>Press me</button>`);
await click('button');
});
});
});

test('called with event', async function(assert) {
Expand All @@ -55,6 +55,6 @@ module('Integration | Helper | if-key', function(hooks) {
});
await render(hbs`{{on-document "keydown" (if-key "alt+c" this.onTrigger)}}`);
await triggerEvent(document.body, 'keydown', { shiftKey: true, key: 'z' });
assert.ok(!onTriggerCalledWith, 'trigger is on invoked if key does not match');
assert.notOk(onTriggerCalledWith, 'trigger is on invoked if key does not match');
});
});
24 changes: 12 additions & 12 deletions tests/integration/helpers/on-key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module('Integration | Helper | on-key', function(hooks) {
test('does not trigger if helper is not rendered', async function(assert) {
await this.renderWithConditional();
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is rendered', async function(assert) {
await this.renderWithConditional();
Expand All @@ -43,7 +43,7 @@ module('Integration | Helper | on-key', function(hooks) {
await this.renderWithConditional();
await this.set('shouldRenderOnKeyHelper', false);
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand Down Expand Up @@ -122,10 +122,10 @@ module('Integration | Helper | on-key', function(hooks) {

test('does not trigger on keyup or keypress', async function(assert) {
await keyUp('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');

await keyPress('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand All @@ -140,10 +140,10 @@ module('Integration | Helper | on-key', function(hooks) {

test('does not trigger on keyup or keypress', async function(assert) {
await keyUp('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');

await keyPress('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand All @@ -158,10 +158,10 @@ module('Integration | Helper | on-key', function(hooks) {

test('does not trigger on keydown or keypress', async function(assert) {
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');

await keyPress('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand All @@ -176,10 +176,10 @@ module('Integration | Helper | on-key', function(hooks) {

test('does not trigger on keydown or keyup', async function(assert) {
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');

await keyUp('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand All @@ -193,7 +193,7 @@ module('Integration | Helper | on-key', function(hooks) {
test('does not trigger if helper is not activated', async function(assert) {
await this.renderWithActivated();
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
test('triggers if helper is activated', async function(assert) {
await this.renderWithActivated();
Expand All @@ -206,7 +206,7 @@ module('Integration | Helper | on-key', function(hooks) {
await this.renderWithActivated();
await this.set('isActivated', false);
await keyDown('shift+c');
assert.ok(!onTriggerCalled, 'does not trigger action');
assert.notOk(onTriggerCalled, 'does not trigger action');
});
});

Expand Down
Loading