-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into upgrade-glimmer
- Loading branch information
Showing
18 changed files
with
716 additions
and
626 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
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
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
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
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
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
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
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
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
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
18 changes: 16 additions & 2 deletions
18
packages/ember-glimmer/tests/integration/application/rendering-test.js
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
72 changes: 72 additions & 0 deletions
72
packages/ember-glimmer/tests/integration/components/error-handling-test.js
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,72 @@ | ||
import { set } from 'ember-metal'; | ||
import { Component } from '../../utils/helpers'; | ||
import { moduleFor, RenderingTest } from '../../utils/test-case'; | ||
|
||
moduleFor('Errors thrown during render', class extends RenderingTest { | ||
['@test it can recover resets the transaction when an error is thrown during initial render'](assert) { | ||
let shouldThrow = true; | ||
let FooBarComponent = Component.extend({ | ||
init() { | ||
this._super(...arguments); | ||
if (shouldThrow) { | ||
throw new Error('silly mistake in init!'); | ||
} | ||
} | ||
}); | ||
|
||
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); | ||
|
||
assert.throws(() => { | ||
this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); | ||
}, /silly mistake in init/); | ||
|
||
assert.equal(this.env.inTransaction, false, 'should not be in a transaction even though an error was thrown'); | ||
|
||
this.assertText(''); | ||
|
||
this.runTask(() => set(this.context, 'switch', false)); | ||
|
||
shouldThrow = false; | ||
|
||
this.runTask(() => set(this.context, 'switch', true)); | ||
|
||
this.assertText('hello'); | ||
} | ||
|
||
['@test it can recover resets the transaction when an error is thrown during rerender'](assert) { | ||
let shouldThrow = false; | ||
let FooBarComponent = Component.extend({ | ||
init() { | ||
this._super(...arguments); | ||
if (shouldThrow) { | ||
throw new Error('silly mistake in init!'); | ||
} | ||
} | ||
}); | ||
|
||
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); | ||
|
||
this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); | ||
|
||
this.assertText('hello'); | ||
|
||
this.runTask(() => set(this.context, 'switch', false)); | ||
|
||
shouldThrow = true; | ||
|
||
assert.throws(() => { | ||
this.runTask(() => set(this.context, 'switch', true)); | ||
}, /silly mistake in init/); | ||
|
||
assert.equal(this.env.inTransaction, false, 'should not be in a transaction even though an error was thrown'); | ||
|
||
this.assertText(''); | ||
|
||
this.runTask(() => set(this.context, 'switch', false)); | ||
shouldThrow = false; | ||
|
||
this.runTask(() => set(this.context, 'switch', true)); | ||
|
||
this.assertText('hello'); | ||
} | ||
}); |
Oops, something went wrong.