Created
June 2, 2017 13:20
-
-
Save cibernox/4abf7fb32fd4e28796893c0e667947d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$ ember-native-dom-helpers-codemod --type=integration tests/integration | |
Processing 5 files... | |
Spawning 5 workers... | |
Sending 1 files to free worker... | |
Sending 1 files to free worker... | |
Sending 1 files to free worker... | |
Sending 1 files to free worker... | |
Sending 1 files to free worker... | |
All done. | |
Results: | |
0 errors | |
0 unmodified | |
0 skipped | |
5 ok | |
Time elapsed: 2.586seconds | |
~/code/dockyard/ember-one-way-controls [master|± 5] | |
$ git diff | |
diff --git a/tests/integration/components/one-way-checkbox-test.js b/tests/integration/components/one-way-checkbox-test.js | |
index b53ffdc..ac1458e 100644 | |
--- a/tests/integration/components/one-way-checkbox-test.js | |
+++ b/tests/integration/components/one-way-checkbox-test.js | |
@@ -1,3 +1,4 @@ | |
+import { find, findAll, triggerEvent } from 'ember-native-dom-helpers'; | |
import Ember from 'ember'; | |
import { moduleForComponent, test } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
@@ -10,84 +11,84 @@ moduleForComponent('one-way-checkbox', 'Integration | Component | {{one-way-chec | |
test('It renders a checkbox', function(assert) { | |
this.render(hbs`{{one-way-checkbox}}`); | |
- assert.equal(this.$('input[type="checkbox"]').length, 1, 'Checkbox is rendered'); | |
+ assert.equal(findAll('input[type="checkbox"]').length, 1, 'Checkbox is rendered'); | |
}); | |
test('It sets the checked value', function(assert) { | |
this.render(hbs`{{one-way-checkbox}}`); | |
- assert.equal(this.$('input:checked').length, 0, 'Checkbox is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Checkbox is not checked'); | |
this.render(hbs`{{one-way-checkbox checked=true}}`); | |
- assert.equal(this.$('input:checked').length, 1, 'Checkbox is checked'); | |
+ assert.equal(findAll('input:checked').length, 1, 'Checkbox is checked'); | |
this.render(hbs`{{one-way-checkbox checked=false}}`); | |
- assert.equal(this.$('input:checked').length, 0, 'Checkbox is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Checkbox is not checked'); | |
}); | |
test('The first positional param is checked', function(assert) { | |
this.render(hbs`{{one-way-checkbox true}}`); | |
- assert.equal(this.$('input:checked').length, 1, 'Checkbox is checked'); | |
+ assert.equal(findAll('input:checked').length, 1, 'Checkbox is checked'); | |
}); | |
test('Setting the value property', function(assert) { | |
this.render(hbs`{{one-way-checkbox value="Affirmative"}}`); | |
- assert.equal(this.$('input').val(), 'Affirmative', 'Checkbox value is set'); | |
+ assert.equal(find('input').value, 'Affirmative', 'Checkbox value is set'); | |
}); | |
-test('Clicking the checkbox triggers the update action', function(assert) { | |
+test('Clicking the checkbox triggers the update action', async function(assert) { | |
this.render(hbs`{{one-way-checkbox update=(action (mut value))}}`); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
assert.equal(this.get('value'), true); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
assert.equal(this.get('value'), false); | |
}); | |
-test('It can accept an outside toggle of checked', function(assert) { | |
+test('It can accept an outside toggle of checked', async function(assert) { | |
this.render(hbs`{{one-way-checkbox checked=checked update=(action (mut checked))}}`); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
this.set('checked', false); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
assert.strictEqual(this.get('checked'), true); | |
}); | |
-test('It can accept an outside toggle of checked - using positional param', function(assert) { | |
+test('It can accept an outside toggle of checked - using positional param', async function(assert) { | |
this.render(hbs`{{one-way-checkbox checked update=(action (mut checked))}}`); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
this.set('checked', false); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
assert.strictEqual(this.get('checked'), true); | |
}); | |
test('I can add a class attribute', function(assert) { | |
this.render(hbs`{{one-way-checkbox class="testing"}}`); | |
- assert.equal(true, this.$('input').hasClass('testing')); | |
+ assert.equal(true, find('input').classList.contains('testing')); | |
}); | |
test('Outside value of null', function(assert) { | |
this.set('checked', true); | |
this.render(hbs`{{one-way-checkbox checked}}`); | |
this.set('checked', null); | |
- assert.equal(this.$('input:checked').length, 0, 'Checkbox is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Checkbox is not checked'); | |
}); | |
test('Outside value of undefined', function(assert) { | |
this.set('checked', true); | |
this.render(hbs`{{one-way-checkbox checked}}`); | |
this.set('checked', undefined); | |
- assert.equal(this.$('input:checked').length, 0, 'Checkbox is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Checkbox is not checked'); | |
}); | |
test('classNames is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-checkbox classNames="testing"}}`); | |
- assert.equal(this.$('input').attr('classnames'), undefined); | |
+ assert.equal(find('input').getAttribute('classnames'), undefined); | |
}); | |
-test('the click event can be intercepted in the action', function(assert) { | |
+test('the click event can be intercepted in the action', async function(assert) { | |
assert.expect(1); | |
this.on('divClick', function() { | |
@@ -106,7 +107,7 @@ test('the click event can be intercepted in the action', function(assert) { | |
</div> | |
`); | |
- this.$('input').trigger('click'); | |
+ await click('input'); | |
assert.equal(this.get('checked'), true); | |
}); | |
diff --git a/tests/integration/components/one-way-input-test.js b/tests/integration/components/one-way-input-test.js | |
index 7679c99..72c7de6 100644 | |
--- a/tests/integration/components/one-way-input-test.js | |
+++ b/tests/integration/components/one-way-input-test.js | |
@@ -1,3 +1,4 @@ | |
+import { find, findAll, fillIn } from 'ember-native-dom-helpers'; | |
import Ember from 'ember'; | |
import { skip } from 'qunit'; | |
import { moduleForComponent, test } from 'ember-qunit'; | |
@@ -12,17 +13,17 @@ moduleForComponent('one-way-input', 'Integration | Component | {{one-way-input}} | |
test('It renders an input', function(assert) { | |
this.render(hbs`{{one-way-input}}`); | |
- assert.equal(this.$('input').length, 1, 'Input is rendered'); | |
+ assert.equal(findAll('input').length, 1, 'Input is rendered'); | |
}); | |
test('The default type of the input is "text"', function(assert) { | |
this.render(hbs`{{one-way-input}}`); | |
- assert.equal(this.$('input[type="text"]').length, 1, 'Input type is text'); | |
+ assert.equal(findAll('input[type="text"]').length, 1, 'Input type is text'); | |
}); | |
test('The type param changes the type of the input', function(assert) { | |
this.render(hbs`{{one-way-input type="password"}}`); | |
- assert.equal(this.$('input[type="password"]').length, 1, 'Input type is password'); | |
+ assert.equal(findAll('input[type="password"]').length, 1, 'Input type is password'); | |
}); | |
test('Raises AssertionError when type is "checkbox"', function(assert) { | |
@@ -51,54 +52,54 @@ test('Raises AssertionError when type is "radio"', function(assert) { | |
test('It puts the value into the input', function(assert) { | |
this.render(hbs`{{one-way-input value="test"}}`); | |
- assert.equal(this.$('input').val(), 'test', 'input\'s value is \'test\''); | |
+ assert.equal(find('input').value, 'test', 'input\'s value is \'test\''); | |
}); | |
test('Changing the value updates the input', function(assert) { | |
this.set('value', 'foo'); | |
this.render(hbs`{{one-way-input value=value}}`); | |
- assert.equal(this.$('input').val(), 'foo', 'Input\'s value is \'foo\''); | |
+ assert.equal(find('input').value, 'foo', 'Input\'s value is \'foo\''); | |
this.set('value', 'bar'); | |
- assert.equal(this.$('input').val(), 'bar', 'Input\'s value is \'bar\''); | |
+ assert.equal(find('input').value, 'bar', 'Input\'s value is \'bar\''); | |
}); | |
test('Value can be the first positional param', function(assert) { | |
this.render(hbs`{{one-way-input "test"}}`); | |
- assert.equal(this.$('input').val(), 'test', 'input\'s value is \'test\''); | |
+ assert.equal(find('input').value, 'test', 'input\'s value is \'test\''); | |
}); | |
test('Outside positional param value of null', function(assert) { | |
this.set('value', 'hello world'); | |
this.render(hbs`{{one-way-input value}}`); | |
this.set('value', null); | |
- assert.equal(this.$('input').val(), ''); | |
+ assert.equal(find('input').value, ''); | |
}); | |
test('Outside positional param value of undefined', function(assert) { | |
this.set('value', 'hello world'); | |
this.render(hbs`{{one-way-input value}}`); | |
this.set('value', undefined); | |
- assert.equal(this.$('input').val(), ''); | |
+ assert.equal(find('input').value, ''); | |
}); | |
-test('Typing in the input triggers the update action', function(assert) { | |
+test('Typing in the input triggers the update action', async function(assert) { | |
this.render(hbs`{{one-way-input update=(action (mut value))}}`); | |
- this.$('input').val('foo').trigger('input'); | |
+ await fillIn('input', 'foo'); | |
assert.equal(this.get('value'), 'foo', 'Value is updated to \'foo\''); | |
}); | |
-test('Changing the input value triggers the update action', function(assert) { | |
+test('Changing the input value triggers the update action', async function(assert) { | |
this.render(hbs`{{one-way-input update=(action (mut value))}}`); | |
- this.$('input').val('foo').trigger('change'); | |
+ await fillIn('input', 'foo'); | |
assert.equal(this.get('value'), 'foo', 'Value is updated to \'foo\''); | |
}); | |
-test('It handles the old style of actions', function(assert) { | |
+test('It handles the old style of actions', async function(assert) { | |
assert.expect(1); | |
let fired = false; | |
this.on('update', () => fired = true); | |
this.render(hbs`{{one-way-input update="update"}}`); | |
- this.$('input').val('foo').trigger('input'); | |
+ await fillIn('input', 'foo'); | |
assert.equal(fired, true, 'The update action should have fired'); | |
}); | |
@@ -133,27 +134,27 @@ test('Does not throw an error updating an number input', function(assert) { | |
test('I can add a class attribute', function(assert) { | |
this.render(hbs`{{one-way-input class="testing"}}`); | |
- assert.equal(this.$('input').hasClass('testing'), true, 'The testing class was added'); | |
+ assert.equal(find('input').classList.contains('testing'), true, 'The testing class was added'); | |
}); | |
test('I can bind the placeholder attribute', function(assert) { | |
this.render(hbs`{{one-way-input placeholder="testing"}}`); | |
- assert.equal(this.$('input').attr('placeholder'), 'testing'); | |
+ assert.equal(find('input').getAttribute('placeholder'), 'testing'); | |
}); | |
test('positionalParamValue is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-input "testing"}}`); | |
- assert.equal(this.$('input').attr('positionalparamvalue'), undefined); | |
+ assert.equal(find('input').getAttribute('positionalparamvalue'), undefined); | |
}); | |
test('classNames is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-input classNames="testing"}}`); | |
- assert.equal(this.$('input').attr('classnames'), undefined); | |
+ assert.equal(find('input').getAttribute('classnames'), undefined); | |
}); | |
test('update is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-input update=(action (mut value))}}`); | |
- assert.equal(this.$('input').attr('update'), undefined); | |
+ assert.equal(find('input').getAttribute('update'), undefined); | |
}); | |
test('It responds to the enter keypress', function(assert) { | |
@@ -190,24 +191,24 @@ test('Handles input masking', function(assert) { | |
input.trigger('input'); | |
}); | |
- assert.equal(this.$('input').val(), 'foo', 'Value is still foo'); | |
+ assert.equal(find('input').value, 'foo', 'Value is still foo'); | |
assert.equal(this.$('input').get(0).selectionStart, 2, 'Cursor is still at right position'); | |
}); | |
test('Does not update value when it is destroyed', function(assert) { | |
this.set('value', 'foo'); | |
this.render(hbs`{{one-way-input value update=(action (mut value))}}`); | |
- run(() => { | |
+ run(async () => { | |
this.clearRender(); | |
- this.$('input').val('foo bar').trigger('input'); | |
+ await fillIn('input', 'foo bar'); | |
}); | |
assert.equal(this.get('value'), 'foo', 'Value is still foo'); | |
}); | |
-skip('Works with type="number" and decimals', function(assert) { | |
+skip('Works with type="number" and decimals', async function(assert) { | |
this.render(hbs`{{one-way-input type="number" update=(action (mut value))}}`); | |
- this.$('input').val('1.').trigger('input'); | |
+ await fillIn('input', '1.'); | |
assert.equal(this.get('value'), '1.', 'Value is updated to \'1.1\''); | |
- this.$('input').val('1.1').trigger('input'); | |
+ await fillIn('input', '1.1'); | |
assert.equal(this.get('value'), '1.1', 'Value is updated to \'1.1\''); | |
}); | |
diff --git a/tests/integration/components/one-way-radio-test.js b/tests/integration/components/one-way-radio-test.js | |
index 6fb016e..acd693d 100644 | |
--- a/tests/integration/components/one-way-radio-test.js | |
+++ b/tests/integration/components/one-way-radio-test.js | |
@@ -1,3 +1,4 @@ | |
+import { find, click, findAll } from 'ember-native-dom-helpers'; | |
import { moduleForComponent, test } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
@@ -7,45 +8,45 @@ moduleForComponent('one-way-radio', 'Integration | Component | one way radio', { | |
test('It renders', function(assert) { | |
this.render(hbs`{{one-way-radio}}`); | |
- assert.equal(this.$('input[type="radio"]').length, 1); | |
+ assert.equal(findAll('input[type="radio"]').length, 1); | |
}); | |
test('Is selected when value matches option', function(assert) { | |
this.set('value', 'yes'); | |
this.render(hbs`{{one-way-radio value=value option="yes"}}`); | |
- assert.equal(this.$('input:checked').length, 1); | |
+ assert.equal(findAll('input:checked').length, 1); | |
}); | |
test('Value is set to option', function(assert) { | |
this.render(hbs`{{one-way-radio value=value option="yes"}}`); | |
- assert.equal(this.$('input').val(), 'yes'); | |
+ assert.equal(find('input').value, 'yes'); | |
}); | |
test('Value can be a positional param', function(assert) { | |
this.set('value', 'yes'); | |
this.render(hbs`{{one-way-radio value option="yes"}}`); | |
- assert.equal(this.$('input:checked').length, 1); | |
+ assert.equal(findAll('input:checked').length, 1); | |
}); | |
test('Is not selected when value does not match option', function(assert) { | |
this.set('value', 'no'); | |
this.render(hbs`{{one-way-radio value=value option="yes"}}`); | |
- assert.equal(this.$('input:checked').length, 0); | |
+ assert.equal(findAll('input:checked').length, 0); | |
}); | |
-test('Triggers update action when clicked', function(assert) { | |
+test('Triggers update action when clicked', async function(assert) { | |
assert.expect(1); | |
this.on('update', (value) => assert.equal(value, 'no')); | |
this.render(hbs`{{one-way-radio value=value option="no" update=(action 'update')}}`); | |
- this.$('input').click(); | |
+ await click('input'); | |
}); | |
-test('Triggers update action when clicked in a radio button group', function(assert) { | |
+test('Triggers update action when clicked in a radio button group', async function(assert) { | |
assert.expect(1); | |
this.on('update', (value) => assert.equal(value, 'yes')); | |
this.set('value', 'no'); | |
@@ -54,29 +55,29 @@ test('Triggers update action when clicked in a radio button group', function(ass | |
{{one-way-radio value=value option="no" update=(action 'update') name="x"}} | |
`); | |
- this.$('input[value="yes"]').click(); | |
+ await click('input[value="yes"]'); | |
}); | |
test('I can add a class attribute', function(assert) { | |
this.render(hbs`{{one-way-radio class="testing"}}`); | |
- assert.equal(true, this.$('input').hasClass('testing')); | |
+ assert.equal(true, find('input').classList.contains('testing')); | |
}); | |
test('Outside value of null', function(assert) { | |
this.set('value', 'yes'); | |
this.render(hbs`{{one-way-radio value option="yes"}}`); | |
this.set('value', null); | |
- assert.equal(this.$('input:checked').length, 0, 'Radio is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Radio is not checked'); | |
}); | |
test('Outside value of undefined', function(assert) { | |
this.set('value', 'yes'); | |
this.render(hbs`{{one-way-radio value option="yes"}}`); | |
this.set('value', undefined); | |
- assert.equal(this.$('input:checked').length, 0, 'Radio is not checked'); | |
+ assert.equal(findAll('input:checked').length, 0, 'Radio is not checked'); | |
}); | |
test('classNames is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-radio classNames="testing"}}`); | |
- assert.equal(this.$('input').attr('classnames'), undefined); | |
+ assert.equal(find('input').getAttribute('classnames'), undefined); | |
}); | |
diff --git a/tests/integration/components/one-way-select-test.js b/tests/integration/components/one-way-select-test.js | |
index 44429f7..8c2e38d 100644 | |
--- a/tests/integration/components/one-way-select-test.js | |
+++ b/tests/integration/components/one-way-select-test.js | |
@@ -1,3 +1,4 @@ | |
+import { find, findAll, fillIn, triggerEvent } from 'ember-native-dom-helpers'; | |
import Ember from 'ember'; | |
import { moduleForComponent, test } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
@@ -17,7 +18,7 @@ test('It renders a select box with options', function(assert) { | |
this.render(hbs` | |
{{one-way-select value=value options=options}} | |
`); | |
- assert.equal(this.$('option').length, 3, 'Select has three options'); | |
+ assert.equal(findAll('option').length, 3, 'Select has three options'); | |
}); | |
test('A value is selected', function(assert) { | |
@@ -30,16 +31,16 @@ test('Value can be the first positional param', function(assert) { | |
assert.equal(this.$('option:selected').val(), 'female', 'Female is selected'); | |
}); | |
-test('Selecting a value updates the selected value', function(assert) { | |
+test('Selecting a value updates the selected value', async function(assert) { | |
this.on('update', (value) => this.set('value', value)); | |
this.render(hbs`{{one-way-select value=value options=options update=(action 'update')}}`); | |
- this.$('select').val('male'); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', 'male'); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(this.$('option:selected').val(), 'male', 'Male is selected'); | |
assert.equal(this.get('value'), 'male', 'Value is \'male\''); | |
}); | |
-test('Selecting a value updates the selected value for pre-grouped options', function(assert) { | |
+test('Selecting a value updates the selected value for pre-grouped options', async function(assert) { | |
let groups = [ | |
{ | |
groupName: 'group1', | |
@@ -55,8 +56,8 @@ test('Selecting a value updates the selected value for pre-grouped options', fun | |
this.render(hbs`{{one-way-select value=value options=options update=(action 'update')}}`); | |
- this.$('select').val('value2'); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', 'value2'); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(this.$('option:selected').val(), 'value2', 'value2 is selected'); | |
assert.equal(this.get('value'), 'value2', 'Value is \'value2\''); | |
@@ -64,12 +65,12 @@ test('Selecting a value updates the selected value for pre-grouped options', fun | |
test('Accepts a space seperated string for options', function(assert) { | |
this.render(hbs`{{one-way-select value=value options="male female"}}`); | |
- assert.equal(this.$('option').length, 2, 'There are two options: male, female'); | |
+ assert.equal(findAll('option').length, 2, 'There are two options: male, female'); | |
}); | |
test('Can include a blank value', function(assert) { | |
this.render(hbs`{{one-way-select value=value options=options includeBlank=true}}`); | |
- assert.equal(this.$('option').length, 4, 'There are four options'); | |
+ assert.equal(findAll('option').length, 4, 'There are four options'); | |
}); | |
test('Blank value can be given a text', function(assert) { | |
@@ -89,7 +90,7 @@ test('Prompt can be given as SafeString', function(assert) { | |
assert.equal(this.$('option:eq(0)').text().trim(), 'Select one', 'The blank option has "Select one" as label'); | |
}); | |
-test('With prompt selection still works properly', function(assert) { | |
+test('With prompt selection still works properly', async function(assert) { | |
this.on('update', (value) => this.set('value', value)); | |
this.render(hbs`{{one-way-select | |
value=value | |
@@ -97,8 +98,8 @@ test('With prompt selection still works properly', function(assert) { | |
prompt="Select one" | |
update=(action 'update') | |
}}`); | |
- this.$('select').val('male'); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', 'male'); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(this.$('option:selected').val(), 'male', 'Select options is male'); | |
assert.equal(this.get('value'), 'male', 'Value us \'male\''); | |
}); | |
@@ -121,7 +122,7 @@ test('optionValuePath', function(assert) { | |
this.render(hbs`{{one-way-select | |
value=value options=options optionValuePath="id"}}`); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), '12', 'Options are labeled 1, 2'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), '12', 'Options are labeled 1, 2'); | |
assert.equal(this.$('option:selected').val(), 2, 'Selected option is 2'); | |
}); | |
@@ -133,7 +134,7 @@ test('optionLabelPath', function(assert) { | |
this.render(hbs`{{one-way-select | |
value=value options=options optionValuePath="id" optionLabelPath="value"}}`); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), 'malefemale', 'Options are label male, female'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), 'malefemale', 'Options are label male, female'); | |
}); | |
test('selected based on optionValuePath', function(assert) { | |
@@ -166,7 +167,7 @@ test('optionTargetPath', function(assert) { | |
this.render(hbs`{{one-way-select | |
value=value options=options optionTargetPath="id" update=(action (mut value))}}`); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), '12', 'Options are labeled 1, 2'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), '12', 'Options are labeled 1, 2'); | |
assert.equal(this.$('option:selected').val(), 2, 'Selected option is 2'); | |
run(() => this.$('select').val('1').trigger('change')); | |
@@ -196,7 +197,7 @@ test('groupLabelPath', function(assert) { | |
optionValuePath="id" optionLabelPath="label" groupLabelPath="type"}}`); | |
assert.equal(this.$('optgroup').eq(0).attr('label'), 'Trappist', 'First optgroup label is Trappist'); | |
- assert.equal(this.$('optgroup').length, 3, 'There should be three optgroups'); | |
+ assert.equal(findAll('optgroup').length, 3, 'There should be three optgroups'); | |
}); | |
test('options is pre-grouped', function(assert) { | |
@@ -222,7 +223,7 @@ test('options is pre-grouped', function(assert) { | |
optionValuePath="id" optionLabelPath="label"}}`); | |
assert.equal(this.$('optgroup').eq(0).attr('label'), 'Trappist', 'First optgroup label is Trappist'); | |
- assert.equal(this.$('optgroup').length, 3, 'There should be three optgroups'); | |
+ assert.equal(findAll('optgroup').length, 3, 'There should be three optgroups'); | |
}); | |
test('multiple select', function(assert) { | |
@@ -243,7 +244,7 @@ test('multiple select', function(assert) { | |
assert.equal(this.$('option:selected:eq(1)').val(), 4, 'Saison should be selected'); | |
}); | |
-test('multiple select a value', function(assert) { | |
+test('multiple select a value', async function(assert) { | |
let [dubbel, tripel, ipa, saison] = [ | |
{ id: 1, label: 'Dubbel', type: 'Trappist' }, | |
{ id: 2, label: 'Tripel', type: 'Trappist' }, | |
@@ -259,14 +260,14 @@ test('multiple select a value', function(assert) { | |
update=(action 'update') optionValuePath="id" optionLabelPath="label" | |
groupLabelPath="type"}}`); | |
- this.$('select').val(['1', '3', '4']); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', ['1', '3', '4']); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(this.$('option:selected:eq(0)').val(), 1, 'Dubbel is selected'); | |
assert.deepEqual(this.get('value'), [dubbel, ipa, saison], 'Dubbel, IPA and Saison are selected'); | |
}); | |
-test('de-select all options in multiple select', function(assert) { | |
+test('de-select all options in multiple select', async function(assert) { | |
let [dubbel, tripel, ipa, saison] = [ | |
{ id: 1, label: 'dubbel', type: 'trappist' }, | |
{ id: 2, label: 'tripel', type: 'trappist' }, | |
@@ -282,33 +283,33 @@ test('de-select all options in multiple select', function(assert) { | |
update=(action 'update') optionValuePath="id" optionLabelPath="label" | |
groupLabelPath="type"}}`); | |
- this.$('select').val(['1', '3', '4']); | |
- this.$('select').trigger('change'); | |
- this.$('select').val(''); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', ['1', '3', '4']); | |
+ await triggerEvent('select', 'change'); | |
+ await fillIn('select', ''); | |
+ await triggerEvent('select', 'change'); | |
assert.ok(this.get('value'), 'selects an empty array'); | |
}); | |
-test('It handles the old style of actions', function(assert) { | |
+test('It handles the old style of actions', async function(assert) { | |
assert.expect(1); | |
let fired = false; | |
this.on('update', () => fired = true); | |
this.render(hbs`{{one-way-select value=value options=options update='update'}}`); | |
- this.$('select').val('male'); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', 'male'); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(fired, true, 'The update action should have fired'); | |
}); | |
test('I can add a class attribute', function(assert) { | |
this.render(hbs`{{one-way-select class="testing"}}`); | |
- assert.equal(true, this.$('select').hasClass('testing')); | |
+ assert.equal(true, find('select').classList.contains('testing')); | |
}); | |
test('Handles block expression', function(assert) { | |
this.render(hbs`{{#one-way-select options=options as |option index|}}{{option}}-{{index}}{{/one-way-select}}`); | |
- assert.equal(this.$('option').length, 3, 'Select has three options'); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), 'unknown-0male-1female-2', 'Has labels with indexes'); | |
+ assert.equal(findAll('option').length, 3, 'Select has three options'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), 'unknown-0male-1female-2', 'Has labels with indexes'); | |
}); | |
test('Handles block expression (option groups)', function(assert) { | |
@@ -325,8 +326,8 @@ test('Handles block expression (option groups)', function(assert) { | |
this.set('options', groups); | |
this.render(hbs`{{#one-way-select options=options as |option index groupIndex|}}{{option}}-{{groupIndex}}-{{index}}{{/one-way-select}}`); | |
- assert.equal(this.$('option').length, 3, 'Select has three options'); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), 'value1-0-0value2-1-0value3-1-1', 'Has labels with indexes'); | |
+ assert.equal(findAll('option').length, 3, 'Select has three options'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), 'value1-0-0value2-1-0value3-1-1', 'Has labels with indexes'); | |
}); | |
test('I can pass a component that is rendered as option', function(assert) { | |
@@ -335,8 +336,8 @@ test('I can pass a component that is rendered as option', function(assert) { | |
})); | |
this.render(hbs`{{one-way-select options=options optionComponent="option-component"}}`); | |
- assert.equal(this.$('option').length, 3, 'Select has three options'); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), 'unknown-0male-1female-2', 'Has labels with indexes'); | |
+ assert.equal(findAll('option').length, 3, 'Select has three options'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), 'unknown-0male-1female-2', 'Has labels with indexes'); | |
}); | |
test('I can pass a component that is rendered as option (option groups)', function(assert) { | |
@@ -357,8 +358,8 @@ test('I can pass a component that is rendered as option (option groups)', functi | |
this.set('options', groups); | |
this.render(hbs`{{one-way-select options=options optionComponent="option-component"}}`); | |
- assert.equal(this.$('option').length, 3, 'Select has three options'); | |
- assert.equal(this.$('option').text().replace(/\s/g, ''), 'value1-0-0value2-1-0value3-1-1', 'Has labels with indexes'); | |
+ assert.equal(findAll('option').length, 3, 'Select has three options'); | |
+ assert.equal(find('option').textContent.replace(/\s/g, ''), 'value1-0-0value2-1-0value3-1-1', 'Has labels with indexes'); | |
}); | |
test('Setting the selection to null/undefined from outside', function(assert) { | |
@@ -369,10 +370,10 @@ test('Setting the selection to null/undefined from outside', function(assert) { | |
test('classNames is not passed as an html attribute', function(assert) { | |
this.render(hbs`{{one-way-select classNames="testing"}}`); | |
- assert.equal(this.$('select').attr('classnames'), undefined); | |
+ assert.equal(find('select').getAttribute('classnames'), undefined); | |
}); | |
-test('allows to select blank without throwing', function(assert) { | |
+test('allows to select blank without throwing', async function(assert) { | |
let updates = []; | |
this.on('update', (newValue) => updates.push(newValue)); | |
@@ -385,11 +386,11 @@ test('allows to select blank without throwing', function(assert) { | |
prompt='myDefaultPrompt' value=value promptIsSelectable=true options=options optionTargetPath='value' optionValuePath='value' optionLabelPath='text' | |
update=(action 'update')}}`); | |
- this.$('select').val('one'); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', 'one'); | |
+ await triggerEvent('select', 'change'); | |
- this.$('select').val(''); | |
- this.$('select').trigger('change'); | |
+ await fillIn('select', ''); | |
+ await triggerEvent('select', 'change'); | |
assert.equal(this.$('option:selected').text().trim(), 'myDefaultPrompt'); | |
assert.deepEqual(updates, ['one', undefined]); | |
diff --git a/tests/integration/components/one-way-textarea-test.js b/tests/integration/components/one-way-textarea-test.js | |
index 26cf935..48fd2b8 100644 | |
--- a/tests/integration/components/one-way-textarea-test.js | |
+++ b/tests/integration/components/one-way-textarea-test.js | |
@@ -1,3 +1,4 @@ | |
+import { find, findAll } from 'ember-native-dom-helpers'; | |
import { moduleForComponent, test } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
@@ -7,10 +8,10 @@ moduleForComponent('one-way-textarea', 'Integration | Component | {{one-way-text | |
test('It renders a textarea', function(assert) { | |
this.render(hbs`{{one-way-textarea}}`); | |
- assert.equal(this.$('textarea').length, 1, 'a textarea was rendered'); | |
+ assert.equal(findAll('textarea').length, 1, 'a textarea was rendered'); | |
}); | |
test('I can add a class attribute', function(assert) { | |
this.render(hbs`{{one-way-textarea class="testing"}}`); | |
- assert.equal(true, this.$('textarea').hasClass('testing')); | |
+ assert.equal(true, find('textarea').classList.contains('testing')); | |
}); | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment