-
Notifications
You must be signed in to change notification settings - Fork 89
/
radio.spec.js
56 lines (46 loc) · 1.63 KB
/
radio.spec.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
modules.define(
'spec',
['radio', 'i-bem__dom', 'jquery', 'dom', 'BEMHTML', 'chai'],
function(provide, Radio, BEMDOM, $, dom, BEMHTML, chai) {
describe('radio', function() {
var radioOption;
function buildRadio() {
return BEMDOM.init($(BEMHTML.apply({
block : 'radio',
name : 'name',
val : 'val',
label : 'label'
}))
.appendTo('body'))
.bem('radio');
}
beforeEach(function() {
radioOption = buildRadio();
});
afterEach(function() {
BEMDOM.destruct(radioOption.domElem);
});
describe('checked', function() {
it('should properly update "control" elem "checked" attr', function() {
radioOption
.setMod('checked')
.elem('control').prop('checked').should.be.true;
radioOption.elem('control').attr('checked').should.be.equal('checked');
radioOption
.delMod('checked')
.elem('control').prop('checked').should.be.false;
chai.expect(radioOption.elem('control').attr('checked')).to.be.undefined;
});
it('should set "checked" mod on "change" event', function() {
radioOption.domElem.trigger('change');
radioOption.hasMod('checked').should.be.true;
});
it('should not set "checked" mod on "change" event if disabled', function() {
radioOption.setMod('disabled');
radioOption.domElem.trigger('change');
radioOption.hasMod('checked').should.be.false;
});
});
});
provide();
});