-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
86 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<button type="button" {{on "click" this.check}}> | ||
check | ||
</button> |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class MyComponent extends Component { | ||
@action | ||
check() { | ||
if (true) { // Some condition | ||
throw new Error('check failed'); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{{yield}} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Component from '@glimmer/component'; | ||
|
||
export default class MyOtherComponent extends Component { | ||
constructor() { | ||
super(...arguments); | ||
|
||
if (true) { // Some condition | ||
throw new Error('check failed'); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render, click, setupOnerror, resetOnerror } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | my-component', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
setupOnerror((error) => { | ||
if (error.message.match('check failed')) { | ||
assert.step('asserts correct usage of component'); | ||
return; | ||
} | ||
|
||
throw error; | ||
}); | ||
}); | ||
|
||
hooks.afterEach(function () { | ||
resetOnerror(); | ||
}); | ||
|
||
test('it throws an error if check fails', async function (assert) { | ||
await render(hbs`<MyComponent />`); | ||
|
||
await click('button'); | ||
|
||
assert.verifySteps(['asserts correct usage of component']); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render, setupOnerror, resetOnerror } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | my-other-component', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
setupOnerror((error) => { | ||
if (error.message.match('check failed')) { | ||
assert.step('asserts correct usage of component'); | ||
return; | ||
} | ||
|
||
throw error; | ||
}); | ||
}); | ||
|
||
hooks.afterEach(function () { | ||
resetOnerror(); | ||
}); | ||
|
||
test('it throws an error if check fails', async function (assert) { | ||
await render(hbs`<MyOtherComponent />`); | ||
|
||
assert.verifySteps(['asserts correct usage of component']); | ||
}); | ||
}); |