Skip to content
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

Replace with template helper with let #677

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions tests/integration/helpers/changeset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ module('Integration | Helper | changeset', function (hooks) {
this.submit = (changeset) => changeset.validate();
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel this.validate) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validate) as |changesetObj|}}
{{#if changesetObj.isInvalid}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<Input id="last-name" @value={{changesetObj.lastName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'A');
Expand All @@ -70,15 +70,15 @@ module('Integration | Helper | changeset', function (hooks) {
this.submit = (changeset) => changeset.validate();
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#if changesetObj.isInvalid}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<Input id="last-name" @value={{changesetObj.lastName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'A');
Expand Down Expand Up @@ -110,15 +110,15 @@ module('Integration | Helper | changeset', function (hooks) {
this.submit = (changeset) => changeset.validate();
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#if changesetObj.isInvalid}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<Input id="last-name" @value={{changesetObj.lastName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'A');
Expand Down Expand Up @@ -151,15 +151,15 @@ module('Integration | Helper | changeset', function (hooks) {
this.submit = (changeset) => changeset.validate();
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validations) as |changesetObj|}}
{{#if changesetObj.isInvalid}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<Input id="last-name" @value={{changesetObj.lastName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'A');
Expand All @@ -175,10 +175,10 @@ module('Integration | Helper | changeset', function (hooks) {
this.dummyModel = { firstName: 'Jim' };
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel) as |changesetObj|}}
{{#let (changeset this.dummyModel) as |changesetObj|}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

assert.dom('#first-name').hasValue('Jim', 'precondition');
Expand All @@ -193,15 +193,15 @@ module('Integration | Helper | changeset', function (hooks) {
this.submit = (changeset) => changeset.validate();
this.reset = (changeset) => changeset.rollback();
await render(hbs`
{{#with (changeset this.dummyModel) as |changesetObj|}}
{{#let (changeset this.dummyModel) as |changesetObj|}}
{{#if changesetObj.isInvalid}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input @value={{changesetObj.firstName}} />
<Input @value={{changesetObj.lastName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
<button id="reset-btn" {{on "click" (fn this.reset changesetObj)}}>Reset</button>
{{/with}}
{{/let}}
`);

await click('#submit-btn');
Expand All @@ -214,15 +214,15 @@ module('Integration | Helper | changeset', function (hooks) {
changeset.firstName = evt.target.value;
};
await render(hbs`
{{#with (changeset this.dummyModel) as |changesetObj|}}
{{#let (changeset this.dummyModel) as |changesetObj|}}
<h1>{{changesetObj.firstName}} {{changesetObj.lastName}}</h1>
<input
id="first-name"
type="text"
value={{changesetObj.firstName}}
{{on "change" (fn this.updateFirstName changesetObj)}}>
<Input id="last-name" @value={{changesetObj.lastName}} />
{{/with}}
{{/let}}
`);

assert.dom('h1').hasText('Jim Bob', 'precondition');
Expand All @@ -238,15 +238,15 @@ module('Integration | Helper | changeset', function (hooks) {
changeset.firstName = evt.target.value;
};
await render(hbs`
{{#with (changeset this.dummyModel this.this.validate) as |changesetObj|}}
{{#let (changeset this.dummyModel this.this.validate) as |changesetObj|}}
<h1>{{changesetObj.firstName}} {{changesetObj.lastName}}</h1>
<input
id="first-name"
type="text"
value={{changesetObj.firstName}}
{{on "change" (fn this.updateFirstName changesetObj)}}>
<Input id="last-name" @value={{changesetObj.lastName}} />
{{/with}}
{{/let}}
`);

assert.dom('h1').hasText('Jim Bob', 'precondition');
Expand Down Expand Up @@ -550,9 +550,9 @@ module('Integration | Helper | changeset', function (hooks) {
let momentInstance = new Moment(d);
this.dummyModel = { startDate: momentInstance };
await render(hbs`
{{#with (changeset this.dummyModel) as |changesetObj|}}
{{#let (changeset this.dummyModel) as |changesetObj|}}
<h1>{{changesetObj.startDate.date}}</h1>
{{/with}}
{{/let}}
`);

assert.dom('h1').hasText(d.toString(), 'should update observable value');
Expand All @@ -562,9 +562,9 @@ module('Integration | Helper | changeset', function (hooks) {
let d = new Date('2015');
this.d = d;
await render(hbs`
{{#with (changeset (hash date=this.d)) as |changesetObj|}}
{{#let (changeset (hash date=this.d)) as |changesetObj|}}
<h1>{{changesetObj.date}}</h1>
{{/with}}
{{/let}}
`);

assert.dom('h1').hasText(d.toString(), 'should update observable value');
Expand All @@ -573,7 +573,7 @@ module('Integration | Helper | changeset', function (hooks) {
test('it handles models that are promises', async function (assert) {
this.dummyModel = Promise.resolve({ firstName: 'Jim', lastName: 'Bob' });
await render(hbs`
{{#with (changeset this.dummyModel) as |changesetObj|}}
{{#let (changeset this.dummyModel) as |changesetObj|}}
<h1>{{changesetObj.firstName}} {{changesetObj.lastName}}</h1>
<input
id="first-name"
Expand All @@ -582,7 +582,7 @@ module('Integration | Helper | changeset', function (hooks) {
onchange={{action (mut changesetObj.firstName) value="target.value"}}>

<Input id="last-name" @value={{changesetObj.lastName}} />
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'foo');
Expand All @@ -596,14 +596,14 @@ module('Integration | Helper | changeset', function (hooks) {
this.dummyModel = { firstName: 'Jim', lastName: 'Bob' };
this.validate = () => false;
await render(hbs`
{{#with (changeset this.dummyModel this.validate skipValidate=true) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validate skipValidate=true) as |changesetObj|}}
<h1>{{changesetObj.firstName}} {{changesetObj.lastName}}</h1>
<Input id="first-name" @value={{changesetObj.firstName}} />
<Input id="last-name" @value={{changesetObj.lastName}} />
{{#if changesetObj.isInvalid}}
<p id="error-paragraph">There were one or more errors in your form.</p>
{{/if}}
{{/with}}
{{/let}}
`);

assert.dom('h1').hasText('Jim Bob', 'precondition');
Expand Down Expand Up @@ -633,13 +633,13 @@ module('Integration | Helper | changeset', function (hooks) {
this.reset = (changeset) => changeset.rollback();
this.changesetKeys = ['lastName'];
await render(hbs`
{{#with (changeset this.dummyModel this.validate changesetKeys=this.changesetKeys) as |changesetObj|}}
{{#let (changeset this.dummyModel this.validate changesetKeys=this.changesetKeys) as |changesetObj|}}
{{#if changesetObj.isDirty}}
<p id="errors-paragraph">There were one or more errors in your form.</p>
{{/if}}
<Input id="first-name" @value={{changesetObj.firstName}} />
<button id="submit-btn" {{on "click" (fn this.submit changesetObj)}}>Submit</button>
{{/with}}
{{/let}}
`);

await fillIn('#first-name', 'A');
Expand Down
Loading