-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add basic coverage for document and window
- Loading branch information
1 parent
9ac9430
commit 60d93e1
Showing
2 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import { render, click, resetOnerror } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Helper | on-document', function(hooks) { | ||
setupRenderingTest(hooks); | ||
hooks.afterEach(() => resetOnerror()); | ||
|
||
// Replace this with your real tests. | ||
test('it renders', async function(assert) { | ||
this.set('inputValue', '1234'); | ||
test('it basically works', async function(assert) { | ||
assert.expect(6); | ||
|
||
await render(hbs`{{on-document inputValue}}`); | ||
this.someMethod = function(event) { | ||
assert.ok(this instanceof HTMLDocument, 'this context is the document'); | ||
assert.ok( | ||
event instanceof MouseEvent, | ||
'first argument is a `MouseEvent`' | ||
); | ||
assert.strictEqual( | ||
event.target.tagName, | ||
'BUTTON', | ||
'correct element tagName' | ||
); | ||
assert.dom(event.target).hasAttribute('data-foo', 'test-element'); | ||
}; | ||
|
||
assert.equal(this.element.textContent.trim(), '1234'); | ||
await render(hbs` | ||
{{on-document "click" this.someMethod}} | ||
<button type="button" data-foo="test-element"></button> | ||
`); | ||
|
||
assert.counts({ adds: 1, removes: 0 }); | ||
|
||
await click('button'); | ||
|
||
assert.counts({ adds: 1, removes: 0 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import { render, click, resetOnerror } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Helper | on-window', function(hooks) { | ||
setupRenderingTest(hooks); | ||
hooks.afterEach(() => resetOnerror()); | ||
|
||
// Replace this with your real tests. | ||
test('it renders', async function(assert) { | ||
this.set('inputValue', '1234'); | ||
test('it basically works', async function(assert) { | ||
assert.expect(6); | ||
|
||
await render(hbs`{{on-window inputValue}}`); | ||
this.someMethod = function(event) { | ||
assert.ok(this instanceof Window, 'this context is the window'); | ||
assert.ok( | ||
event instanceof MouseEvent, | ||
'first argument is a `MouseEvent`' | ||
); | ||
assert.strictEqual( | ||
event.target.tagName, | ||
'BUTTON', | ||
'correct element tagName' | ||
); | ||
assert.dom(event.target).hasAttribute('data-foo', 'test-element'); | ||
}; | ||
|
||
assert.equal(this.element.textContent.trim(), '1234'); | ||
await render(hbs` | ||
{{on-window "click" this.someMethod}} | ||
<button type="button" data-foo="test-element"></button> | ||
`); | ||
|
||
assert.counts({ adds: 1, removes: 0 }); | ||
|
||
await click('button'); | ||
|
||
assert.counts({ adds: 1, removes: 0 }); | ||
}); | ||
}); |