discourse/plugins/poll/test/javascripts/widgets/discourse-poll-option-test.js.es6

65 lines
1.3 KiB
Plaintext
Raw Normal View History

import { moduleForWidget, widgetTest } from 'helpers/widget-test';
moduleForWidget('discourse-poll-option');
const template = `{{mount-widget
widget="discourse-poll-option"
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
widgetTest('single, not selected', {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.set('option', { id: 'opt-id' });
this.set('vote', []);
},
test(assert) {
2017-11-24 01:15:37 +08:00
assert.ok(find('li .d-icon-circle-o:eq(0)').length === 1);
}
});
widgetTest('single, selected', {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.set('option', { id: 'opt-id' });
this.set('vote', ['opt-id']);
},
test(assert) {
2017-11-24 01:15:37 +08:00
assert.ok(find('li .d-icon-dot-circle-o:eq(0)').length === 1);
}
});
widgetTest('multi, not selected', {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.setProperties({
option: { id: 'opt-id' },
isMultiple: true,
vote: []
});
},
test(assert) {
2017-11-24 01:15:37 +08:00
assert.ok(find('li .d-icon-square-o:eq(0)').length === 1);
}
});
widgetTest('multi, selected', {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.setProperties({
option: { id: 'opt-id' },
isMultiple: true,
vote: ['opt-id']
});
},
test(assert) {
2017-11-24 01:15:37 +08:00
assert.ok(find('li .d-icon-check-square-o:eq(0)').length === 1);
}
});