-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathx-select-multiple-test.js
70 lines (56 loc) · 2.25 KB
/
x-select-multiple-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import xSelectInteractor from 'emberx-select/test-support/interactor';
import pageInteractor from 'dummy/tests/interactors/test-page';
import { expect } from 'chai';
import { visit } from '@ember/test-helpers';
import { beforeEach, describe, it } from 'mocha';
import { setupApplicationTest } from 'ember-mocha';
describe('XSelect: Multiple Selection', function() {
let xselect = new xSelectInteractor('.x-select');
let page = new pageInteractor();
setupApplicationTest();
beforeEach(async () => {
await visit('test-bed/multiple');
});
it('marks all selected values initially', async () => {
await page.when(() => {
expect(xselect.options(1).text).to.equal('Bastion');
expect(xselect.options(2).text).to.equal('Stanley');
expect(xselect.options(1).isSelected).to.equal(true);
expect(xselect.options(2).isSelected).to.equal(true);
expect(page.multiselectValues(0).text).to.equal('Bastion');
expect(page.multiselectValues(1).text).to.equal('Stanley');
});
});
describe('deselecting', function() {
beforeEach(async () => {
await xselect.select('Stanley');
});
it('properly deselects the right option', async () => {
await xselect.when(() => {
expect(xselect.options(1).text).to.equal('Bastion');
expect(xselect.options(2).text).to.equal('Stanley');
expect(xselect.options(1).isSelected).to.equal(true);
expect(xselect.options(2).isSelected).to.equal(false);
});
});
it('updates the page values', async () => {
await xselect.when(() => expect(page.multiselectValues(0).text).to.equal('Bastion'));
});
});
describe('when no option is selected', function() {
beforeEach(async () => {
await xselect.select(['Bastion', 'Stanley']);
});
it('updates the select values', async () => {
await xselect.when(() => {
expect(xselect.options(1).isSelected).to.equal(false);
expect(xselect.options(1).text).to.equal('Bastion');
expect(xselect.options(2).isSelected).to.equal(false);
expect(xselect.options(2).text).to.equal('Stanley');
});
});
it('updates the page values', async () => {
await xselect.when(() => expect(page.multiselectValues(0).text).to.equal('None'));
});
});
});