-
-
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 pull request #19229 from sanji11/issue-18060
[CLEANUP] Remove the EMBER_GLIMMER_SET_COMPONENT_TEMPLATE flag
- Loading branch information
Showing
6 changed files
with
140 additions
and
167 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
185 changes: 91 additions & 94 deletions
185
packages/@ember/-internals/glimmer/tests/integration/components/component-template-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 |
---|---|---|
@@ -1,138 +1,135 @@ | ||
import { moduleFor, RenderingTestCase, runTask } from 'internal-test-helpers'; | ||
|
||
import { EMBER_GLIMMER_SET_COMPONENT_TEMPLATE } from '@ember/canary-features'; | ||
import { HAS_NATIVE_SYMBOL } from '@ember/-internals/utils'; | ||
|
||
import { Component, compile } from '../../utils/helpers'; | ||
import { setComponentTemplate, getComponentTemplate } from '../../..'; | ||
|
||
if (EMBER_GLIMMER_SET_COMPONENT_TEMPLATE) { | ||
moduleFor( | ||
'Components test: setComponentTemplate', | ||
class extends RenderingTestCase { | ||
'@test it basically works'() { | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), | ||
}); | ||
moduleFor( | ||
'Components test: setComponentTemplate', | ||
class extends RenderingTestCase { | ||
'@test it basically works'() { | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), | ||
}); | ||
|
||
this.render('<FooBar />'); | ||
this.render('<FooBar />'); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
|
||
runTask(() => this.rerender()); | ||
runTask(() => this.rerender()); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
|
||
'@test it takes precedence over resolver'() { | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), | ||
template: 'noooooo!', | ||
}); | ||
'@test it takes precedence over resolver'() { | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), | ||
template: 'noooooo!', | ||
}); | ||
|
||
this.render('<FooBar />'); | ||
this.render('<FooBar />'); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
|
||
runTask(() => this.rerender()); | ||
runTask(() => this.rerender()); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
|
||
'@test calling it with primitives asserts'() { | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), null); | ||
}, /Cannot call `setComponentTemplate` on `null`/); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), undefined); | ||
}, /Cannot call `setComponentTemplate` on `undefined`/); | ||
'@test calling it with primitives asserts'() { | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), null); | ||
}, /Cannot call `setComponentTemplate` on `null`/); | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), true); | ||
}, /Cannot call `setComponentTemplate` on `true`/); | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), undefined); | ||
}, /Cannot call `setComponentTemplate` on `undefined`/); | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), false); | ||
}, /Cannot call `setComponentTemplate` on `false`/); | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), true); | ||
}, /Cannot call `setComponentTemplate` on `true`/); | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), 123); | ||
}, /Cannot call `setComponentTemplate` on `123`/); | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), false); | ||
}, /Cannot call `setComponentTemplate` on `false`/); | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), 'foo'); | ||
}, /Cannot call `setComponentTemplate` on `foo`/); | ||
|
||
if (HAS_NATIVE_SYMBOL) { | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), Symbol('foo')); | ||
}, /Cannot call `setComponentTemplate` on `Symbol\(foo\)`/); | ||
} | ||
} | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), 123); | ||
}, /Cannot call `setComponentTemplate` on `123`/); | ||
|
||
'@test calling it twice on the same object asserts'() { | ||
let Thing = setComponentTemplate( | ||
compile('hello'), | ||
Component.extend().reopenClass({ | ||
toString() { | ||
return 'Thing'; | ||
}, | ||
}) | ||
); | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), 'foo'); | ||
}, /Cannot call `setComponentTemplate` on `foo`/); | ||
|
||
if (HAS_NATIVE_SYMBOL) { | ||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), Thing); | ||
}, /Cannot call `setComponentTemplate` multiple times on the same class \(`Thing`\)/); | ||
setComponentTemplate(compile('foo'), Symbol('foo')); | ||
}, /Cannot call `setComponentTemplate` on `Symbol\(foo\)`/); | ||
} | ||
} | ||
|
||
'@test templates set with setComponentTemplate are inherited (EmberObject.extend())'() { | ||
let Parent = setComponentTemplate(compile('hello'), Component.extend()); | ||
'@test calling it twice on the same object asserts'() { | ||
let Thing = setComponentTemplate( | ||
compile('hello'), | ||
Component.extend().reopenClass({ | ||
toString() { | ||
return 'Thing'; | ||
}, | ||
}) | ||
); | ||
|
||
expectAssertion(() => { | ||
setComponentTemplate(compile('foo'), Thing); | ||
}, /Cannot call `setComponentTemplate` multiple times on the same class \(`Thing`\)/); | ||
} | ||
|
||
this.registerComponent('foo-bar', { | ||
ComponentClass: Parent.extend(), | ||
}); | ||
'@test templates set with setComponentTemplate are inherited (EmberObject.extend())'() { | ||
let Parent = setComponentTemplate(compile('hello'), Component.extend()); | ||
|
||
this.render('<FooBar />'); | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: Parent.extend(), | ||
}); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
this.render('<FooBar />'); | ||
|
||
runTask(() => this.rerender()); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
runTask(() => this.rerender()); | ||
|
||
'@test templates set with setComponentTemplate are inherited (native ES class extends)'() { | ||
let Parent = setComponentTemplate(compile('hello'), Component.extend()); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
|
||
this.registerComponent('foo-bar', { | ||
ComponentClass: class extends Parent {}, | ||
}); | ||
'@test templates set with setComponentTemplate are inherited (native ES class extends)'() { | ||
let Parent = setComponentTemplate(compile('hello'), Component.extend()); | ||
|
||
this.render('<FooBar />'); | ||
this.registerComponent('foo-bar', { | ||
ComponentClass: class extends Parent {}, | ||
}); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
this.render('<FooBar />'); | ||
|
||
runTask(() => this.rerender()); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
|
||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
runTask(() => this.rerender()); | ||
|
||
'@test it can re-assign templates from another class'() { | ||
let Foo = setComponentTemplate(compile('shared'), Component.extend()); | ||
let Bar = setComponentTemplate(getComponentTemplate(Foo), Component.extend()); | ||
this.assertComponentElement(this.firstChild, { content: 'hello' }); | ||
} | ||
|
||
this.registerComponent('foo', { ComponentClass: Foo }); | ||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
'@test it can re-assign templates from another class'() { | ||
let Foo = setComponentTemplate(compile('shared'), Component.extend()); | ||
let Bar = setComponentTemplate(getComponentTemplate(Foo), Component.extend()); | ||
|
||
this.render('<Foo />|<Bar />'); | ||
this.registerComponent('foo', { ComponentClass: Foo }); | ||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
|
||
this.assertText('shared|shared'); | ||
this.render('<Foo />|<Bar />'); | ||
|
||
runTask(() => this.rerender()); | ||
this.assertText('shared|shared'); | ||
|
||
this.assertText('shared|shared'); | ||
} | ||
runTask(() => this.rerender()); | ||
|
||
this.assertText('shared|shared'); | ||
} | ||
); | ||
} | ||
} | ||
); |
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
Oops, something went wrong.