-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Glimmer2] Mark glimmer2 tests on context.isTruthy to be @htmlbars only #13441
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,8 @@ export class BasicConditionalsTest extends AbstractConditionalsTest { | |
| // Testing behaviors related to objects, object proxies, `{ isTruthy: (true|false) }`, etc | ||
| export const ObjectTestCases = { | ||
|
|
||
| ['@test it tests for `isTruthy` if available']() { | ||
| // Marking as @htmlbars since POJOs can no longer masquerade as Proxies in glimmer2. See proxy tests below. | ||
| ['@htmlbars it tests for `isTruthy` if available']() { | ||
| this.renderValues({ isTruthy: this.truthyValue }, { isTruthy: this.falsyValue }); | ||
|
|
||
| this.assertText('T1F2'); | ||
|
|
@@ -283,7 +284,8 @@ export const ObjectTestCases = { | |
| this.assertText('T1F2'); | ||
| }, | ||
|
|
||
| ['@test it tests for `isTruthy` on Ember objects if available']() { | ||
| // Marking as @htmlbars since POJOs can no longer masquerade as Proxies in glimmer2. See proxy tests below. | ||
| ['@htmlbars it tests for `isTruthy` on Ember objects if available']() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is not supported behavior (and that is basically what we are saying), we should just remove this test.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not problematic to remove code coverage for legacy behaviour though? |
||
| this.renderValues( | ||
| EmberObject.create({ isTruthy: this.truthyValue }), | ||
| EmberObject.create({ isTruthy: this.falsyValue }) | ||
|
|
@@ -348,6 +350,59 @@ export const ObjectTestCases = { | |
| set(this.context, 'cond3', ObjectProxy.create({ content: null })); | ||
| }); | ||
|
|
||
| this.assertText('T1T2F3'); | ||
| }, | ||
|
|
||
| ['@test setting the isTruthy property of an object proxy overrides its truthiness regardless of its content']() { | ||
| this.renderValues( | ||
| ObjectProxy.create({ content: {} }), | ||
| EmberObject.create({ content: false, isTruthy: true }), | ||
|
||
| ObjectProxy.create({ content: null }) | ||
| ); | ||
|
|
||
| this.assertText('T1T2F3'); | ||
|
|
||
| this.runTask(() => this.rerender()); | ||
|
|
||
| this.assertText('T1T2F3'); | ||
|
|
||
| this.runTask(() => { | ||
| set(this.context, 'cond1.isTruthy', false); | ||
| set(this.context, 'cond2.isTruthy', false); | ||
|
||
| }); | ||
|
|
||
| this.assertText('F1F2F3'); | ||
|
|
||
| this.runTask(() => { | ||
| set(this.context, 'cond1.content', 1); | ||
| set(this.context, 'cond2.content', 1); | ||
| set(this.context, 'cond3.content', 1); | ||
| }); | ||
|
|
||
| this.assertText('F1F2T3'); | ||
|
|
||
|
|
||
| this.runTask(() => { | ||
| set(this.context, 'cond1.isTruthy', true); | ||
|
||
| set(this.context, 'cond2.isTruthy', true); | ||
| }); | ||
|
|
||
| this.assertText('T1T2T3'); | ||
|
|
||
| this.runTask(() => { | ||
| set(this.context, 'cond1.content', null); | ||
| set(this.context, 'cond2.content', null); | ||
| set(this.context, 'cond3.content', null); | ||
| }); | ||
|
|
||
| this.assertText('T1T2F3'); | ||
|
|
||
| this.runTask(() => { | ||
| set(this.context, 'cond1', ObjectProxy.create({ content: {} })); | ||
| set(this.context, 'cond2', EmberObject.create({ content: true, isTruthy: true })); | ||
| set(this.context, 'cond3', ObjectProxy.create({ content: null })); | ||
| }); | ||
|
|
||
| this.assertText('T1T2F3'); | ||
| } | ||
|
|
||
|
|
@@ -474,7 +529,7 @@ applyMixins(TogglingConditionalsTest, | |
| { foo: 'bar' }, | ||
| EmberObject.create(), | ||
| EmberObject.create({ foo: 'bar' }), | ||
| EmberObject.create({ isTruthy: true }), | ||
| ObjectProxy.create({ content: true }), | ||
| /*jshint -W053 */ | ||
| new String('hello'), | ||
| new String(''), | ||
|
|
@@ -492,7 +547,7 @@ applyMixins(TogglingConditionalsTest, | |
| 0, | ||
| [], | ||
| emberA(), | ||
| EmberObject.create({ isTruthy: false }) | ||
| ObjectProxy.create({ content: undefined }) | ||
| ]), | ||
|
|
||
| new IsTruthyGenerator([ | ||
|
|
@@ -505,11 +560,14 @@ applyMixins(TogglingConditionalsTest, | |
| 1, | ||
| ['hello'], | ||
| emberA(['hello']), | ||
| ArrayProxy.create({ content: ['hello'] }), | ||
| ArrayProxy.create({ content: [] }), | ||
| {}, | ||
| { foo: 'bar' }, | ||
| EmberObject.create(), | ||
| EmberObject.create({ foo: 'bar' }), | ||
| EmberObject.create({ isTruthy: true }), | ||
| ObjectProxy.create({ content: true }), | ||
| ObjectProxy.create({ content: undefined }), | ||
| /*jshint -W053 */ | ||
| new String('hello'), | ||
| new String(''), | ||
|
|
@@ -523,8 +581,7 @@ applyMixins(TogglingConditionalsTest, | |
| '', | ||
| 0, | ||
| [], | ||
| emberA(), | ||
| EmberObject.create({ isTruthy: false }) | ||
| emberA() | ||
| ]), | ||
|
|
||
| ObjectTestCases, | ||
|
|
@@ -585,7 +642,8 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest { | |
| this.assertText('T1F2'); | ||
| } | ||
|
|
||
| ['@test it tests for `isTruthy` on the context if available']() { | ||
| // This no longer makes sense for glimmer since `this` refers to the component, which cannot be a proxy | ||
| ['@htmlbars it tests for `isTruthy` on the context if available']() { | ||
|
||
| let template = this.wrappedTemplateFor({ cond: 'this', truthy: '"T1"', falsy: '"F1"' }); | ||
|
|
||
| this.render(template, { isTruthy: this.truthyValue }); | ||
|
|
@@ -715,7 +773,8 @@ export class TogglingSyntaxConditionalsTest extends TogglingConditionalsTest { | |
| this.assertText('T1F2'); | ||
| } | ||
|
|
||
| ['@test it tests for `isTruthy` on the context if available']() { | ||
| // Marking as @htmlbars since this no longer relevant for glimmer as `this` refers to the component, which is never a proxy | ||
| ['@htmlbars it tests for `isTruthy` on the context if available']() { | ||
|
||
| let template = this.wrappedTemplateFor({ cond: 'this', truthy: 'T1', falsy: 'F1' }); | ||
|
|
||
| this.render(template, { isTruthy: this.truthyValue }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change line 170 to set
proxyThing.content? We should not be settingisTruthydirectly (and I guess line 174 doesn't make sense anymore)