Skip to content

Commit 9e75a84

Browse files
ci(tests/integration/components): adds tests to check against disabling and validation rules.
1 parent 419f824 commit 9e75a84

File tree

1 file changed

+58
-12
lines changed

1 file changed

+58
-12
lines changed

tests/integration/components/paper-select-test.js

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
/* eslint-disable prettier/prettier */
21
import { module, test } from 'qunit';
32
import { setupRenderingTest } from 'ember-qunit';
4-
import { render, fillIn, waitUntil, find } from '@ember/test-helpers';
3+
import { click, render, fillIn, waitUntil, find } from '@ember/test-helpers';
54
import hbs from 'htmlbars-inline-precompile';
6-
import { clickTrigger, selectChoose } from 'ember-power-select/test-support/helpers';
5+
import {
6+
clickTrigger,
7+
selectChoose,
8+
} from 'ember-power-select/test-support/helpers';
79

8-
module('Integration | Component | paper-select', function(hooks) {
10+
module('Integration | Component | paper-select', function (hooks) {
911
setupRenderingTest(hooks);
1012

11-
hooks.beforeEach(function() {
12-
this.set('sizes', ['small (12-inch)', 'medium (14-inch)', 'large (16-inch)', 'insane (42-inch)']);
13+
hooks.beforeEach(function () {
14+
this.set('sizes', [
15+
'small (12-inch)',
16+
'medium (14-inch)',
17+
'large (16-inch)',
18+
'insane (42-inch)',
19+
]);
1320
});
1421

15-
test('opens on click', async function(assert) {
22+
test('opens on click', async function (assert) {
1623
await render(hbs`{{#paper-select
1724
disabled=disableSelect
1825
placeholder="Size"
@@ -29,7 +36,7 @@ module('Integration | Component | paper-select', function(hooks) {
2936
assert.dom('md-select-menu').exists();
3037
});
3138

32-
test('backdrop removed if select closed', async function(assert) {
39+
test('backdrop removed if select closed', async function (assert) {
3340
await render(hbs`{{#paper-select
3441
disabled=disableSelect
3542
placeholder="Size"
@@ -54,7 +61,7 @@ module('Integration | Component | paper-select', function(hooks) {
5461
assert.dom('md-backdrop').doesNotExist();
5562
});
5663

57-
test('it can select an option', async function(assert) {
64+
test('it can select an option', async function (assert) {
5865
await render(hbs`{{#paper-select
5966
disabled=disableSelect
6067
placeholder="Size"
@@ -73,7 +80,46 @@ module('Integration | Component | paper-select', function(hooks) {
7380
assert.equal(this.selectedSize, 'large (16-inch)');
7481
});
7582

76-
test('header is rendered above content', async function(assert) {
83+
test('it can be disabled', async function (assert) {
84+
await render(hbs`{{#paper-select
85+
disabled=true
86+
placeholder="Size"
87+
options=sizes
88+
selected=selectedSize
89+
onChange=(action (mut selectedSize))
90+
as |size|
91+
}}
92+
{{size}}
93+
{{/paper-select}}`);
94+
95+
assert.dom('md-select').exists();
96+
assert.dom('md-select').hasProperty('disabled', undefined);
97+
});
98+
99+
test('it can be validated', async function (assert) {
100+
await render(hbs`{{#paper-select
101+
required=true
102+
placeholder="Size"
103+
options=sizes
104+
selected=selectedSize
105+
onChange=(action (mut selectedSize))
106+
as |size|}}
107+
{{size}}
108+
{{/paper-select}}
109+
<div id="not-paper-select"></div>`);
110+
111+
assert.dom('md-select').exists();
112+
assert.dom('md-select').doesNotHaveClass('ng-dirty');
113+
assert.dom('md-select').doesNotHaveClass('ng-invalid');
114+
115+
await clickTrigger('md-input-container');
116+
await click('#not-paper-select');
117+
118+
assert.dom('md-select').hasClass('ng-dirty');
119+
assert.dom('md-select').hasClass('ng-invalid');
120+
});
121+
122+
test('header is rendered above content', async function (assert) {
77123
await render(hbs`{{#paper-select
78124
disabled=disableSelect
79125
placeholder="Size"
@@ -92,7 +138,7 @@ module('Integration | Component | paper-select', function(hooks) {
92138
assert.dom('md-select-menu > md-content').exists();
93139
});
94140

95-
test('it can search a value', async function(assert) {
141+
test('it can search a value', async function (assert) {
96142
await render(hbs`{{#paper-select
97143
disabled=disableSelect
98144
placeholder="Size"
@@ -116,7 +162,7 @@ module('Integration | Component | paper-select', function(hooks) {
116162
assert.dom('md-select-menu md-option').hasText('small (12-inch)');
117163
});
118164

119-
test('it shows search message before entering search string', async function(assert) {
165+
test('it shows search message before entering search string', async function (assert) {
120166
this.search = (value) => this.sizes.filter((size) => size.includes(value));
121167

122168
await render(hbs`{{#paper-select

0 commit comments

Comments
 (0)