Skip to content

Commit 1919593

Browse files
committed
Add failing tests
1 parent 90b4cbe commit 1919593

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

tests/integration/components/ui-checkbox-test.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,25 @@ test('setting readonly ignores click', function(assert) {
9090
this.$('.ui.checkbox').click();
9191
assert.equal(true, this.get('checked'));
9292
assert.equal(count, 1, 'onChange should have only been called once');
93-
});
93+
});
94+
95+
test('setting readonly to null allows click', function(assert) {
96+
assert.expect(3);
97+
98+
let count = 0;
99+
this.set('changed', (value) => {
100+
this.set('checked', value);
101+
count++;
102+
});
103+
104+
this.set('checked', false);
105+
this.set('readonly', null);
106+
this.render(hbs`
107+
{{ui-checkbox label="Make my profile visible" checked=checked readonly=readonly onChange=(action changed)}}
108+
`);
109+
110+
assert.equal(this.$('.ui.checkbox').length, 1);
111+
this.$('.ui.checkbox').click();
112+
assert.equal(true, this.get('checked'));
113+
assert.equal(count, 1, 'onChange should have only been called once');
114+
});

tests/integration/components/ui-radio-test.js

+36
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,42 @@ test('setting readonly ignores click', function(assert) {
216216
assert.equal(count, 1, 'onChange should have been called only once');
217217
});
218218

219+
test('setting readonly to null allows click', function(assert) {
220+
assert.expect(4);
221+
222+
let count = 0;
223+
this.set('changed', (value) => {
224+
this.set('frequency', value);
225+
count++;
226+
});
227+
228+
this.set('checked', false);
229+
this.set('readonly', null);
230+
this.set('frequency', 'weekly');
231+
this.render(hbs`
232+
<div class="ui form">
233+
<div class="grouped inline fields">
234+
<div class="field">
235+
{{ui-radio name="frequency" label="Once a week" value='weekly' current=frequency onChange=(action changed)}}
236+
</div>
237+
<div class="field">
238+
{{ui-radio name="frequency" label="2-3 times a week" value='biweekly' current=frequency readonly=readonly onChange=(action changed)}}
239+
</div>
240+
<div class="field">
241+
{{ui-radio name="frequency" label="Once a day" value='daily' current=frequency onChange=(action changed)}}
242+
</div>
243+
</div>
244+
</div>
245+
`);
246+
247+
assert.equal(this.$('.ui.radio').length, 3);
248+
this.$('.ui.radio')[1].click();
249+
250+
assert.equal('biweekly', this.get('frequency'));
251+
assert.ok(this.$(this.$('.ui.radio')[1]).hasClass('checked'));
252+
assert.equal(count, 1, 'onChange should have been called only once');
253+
});
254+
219255
test('setting binded value updates to current', function(assert) {
220256
assert.expect(7);
221257

0 commit comments

Comments
 (0)