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

Demonstrate dirty change tracking failure #660

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
25 changes: 25 additions & 0 deletions tests/integration/components/validated-form-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, find, fillIn, render } from '@ember/test-helpers';
import { helper } from '@ember/component/helper';
import hbs from 'htmlbars-inline-precompile';
import { ValidatedChangeset } from 'ember-changeset';

module('Integration | Component | validated-form', function (hooks) {
setupRenderingTest(hooks);

test(`changing one property does not dirty other properties`, async function (assert) {
let data = { foo: 'FOO', bar: 'BAR' };
let changeset = new ValidatedChangeset(data);
this.setProperties({
changeset,
changeFoo: () => (changeset.foo = 'FOO-changed'),
checkFoo: helper(([foo]) => assert.step(`checkFoo: ${foo}`)),
checkBar: helper(([bar]) => assert.step(`checkBar: ${bar}`)),
});

await render(hbs`
<input id="foo" {{on 'input' this.changeFoo}} />
{{this.checkFoo this.changeset.foo}}
{{this.checkBar this.changeset.bar}}
`);

assert.verifySteps(['checkFoo: FOO', 'checkBar: BAR'], 'expected check helpers called on inial render');

await fillIn('#foo', 'test-foo');

assert.verifySteps(['checkFoo: FOO-changed'], 'expected only checkFoo to be called');
});

test('it renders form', async function (assert) {
await render(hbs`<ValidatedForm />`);

Expand Down