Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Baylee Swenson committed Aug 1, 2019
1 parent b1511c5 commit ee87872
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DocsDemo as |demo|>
<demo.example @name='form-controls.demo-default.hbs'>
<form {{action this.submit on='submit'}}>
<form {{on 'submit' (prevent-default this.submit)}}>
<FormControls
@changeset={{this.changeset}}
as |form|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DocsDemo as |demo|>
<demo.example @name='form-controls.demo-disabled.hbs'>
<form {{action this.submit on='submit'}}>
<form {{on 'submit' (prevent-default this.submit)}}>
<FormControls
@changeset={{this.changeset}}
@disabled={{this.disabled}}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"ember-decorators": "^3.0.0",
"ember-diff-attrs": "^0.2.1",
"ember-engines": "https://github.com/cos-forks/ember-engines#v0.5.20+cos1",
"ember-event-helpers": "^0.1.0",
"ember-export-application-global": "^2.0.0",
"ember-faker": "^1.2.1",
"ember-feature-flags": "^5.0.0",
Expand Down
17 changes: 8 additions & 9 deletions tests/integration/components/form-controls/component-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { render } from '@ember/test-helpers';
import { click, render } from '@ember/test-helpers';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import { module, test } from 'qunit';

import { click } from 'ember-osf-web/tests/helpers';
import buildChangeset from 'ember-osf-web/utils/build-changeset';

import { nodeValidation } from './validation';
Expand All @@ -15,6 +14,7 @@ module('Integration | Component | form-controls', hooks => {
setupMirage(hooks);

test('it renders', async function(assert) {
assert.ok(true);
const model = {
title: '',
description: '',
Expand Down Expand Up @@ -53,16 +53,15 @@ module('Integration | Component | form-controls', hooks => {
const changeset = buildChangeset(model, nodeValidation);
this.set('changeset', changeset);

function submit() {
// @ts-ignore 'changeset-validations aren't set up correctly for this to typecheck'
changeset.validate();
}
this.set('submit', submit);
this.set('titleValue', '');
this.set('descriptionValue', '');
this.set('submit', () => {
changeset.validate();
assert.ok(true);
});

await render(hbs`
<form data-test-form {{on 'submit' this.submit}}>
<form data-test-form {{on 'submit' (prevent-default this.submit)}}>
<FormControls @changeset={{this.changeset}} as |form| >
<form.text
data-test-title-input
Expand All @@ -87,7 +86,7 @@ module('Integration | Component | form-controls', hooks => {
</form>
`);
assert.dom('[data-test-form]').exists();
await click('[data-analytics-name="submit"]');
await click('[data-test-submit-button]');
// Check that input has a validation message
assert.dom('[data-test-title-input] .help-block').exists({ count: 1 });
assert.dom('[data-test-description-input] .help-block').exists({ count: 1 });
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7634,6 +7634,13 @@ ember-diff-attrs@^0.2.1:
ember-cli-version-checker "^2.1.0"
lodash "^4.12.0"

ember-event-helpers@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ember-event-helpers/-/ember-event-helpers-0.1.0.tgz#4b7f49f136b660df21731a9e0329507c0816438e"
integrity sha512-JdsYPmW0g0LLKmdRGxS9lRIdtB1Swc7Asr0XmUwhkjbFY40bfB0wlQ8P2yA3YLqbP/ToShBitN62t9Cy4PTazQ==
dependencies:
ember-cli-babel "^7.7.3"

ember-export-application-global@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.0.tgz#8d6d7619ac8a1a3f8c43003549eb21ebed685bd2"
Expand Down

0 comments on commit ee87872

Please sign in to comment.