/
menu-item_type_link.spec.js
78 lines (62 loc) · 2.25 KB
/
menu-item_type_link.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
modules.define(
'spec',
['menu-item', 'link', 'i-bem__dom', 'jquery', 'dom', 'sinon', 'BEMHTML'],
function(provide, MenuItem, Link, BEMDOM, $, dom, sinon, BEMHTML) {
describe('menu-item_type_link', function() {
var menu, menuItem, link;
beforeEach(function() {
menu = BEMDOM
.init($(BEMHTML.apply({
block : 'menu',
content : [{
block : 'menu-item',
mods : { type : 'link' },
content : {
block : 'link',
url : 'http://yandex.ru',
content : 'Link 1'
}
}]
})).appendTo('body'))
.bem('menu');
menuItem = menu.findBlockInside('menu-item');
link = menuItem.findBlockInside('link');
});
afterEach(function() {
BEMDOM.destruct(menu.domElem);
});
describe('hovered', function() {
it('should be hovered on link focus', function() {
menuItem.hasMod('hovered').should.be.false;
link.setMod('focused');
menuItem.hasMod('hovered').should.be.true;
});
it('should set focus to link on hover if lies within a focused menu', function() {
link.hasMod('focused').should.be.false;
menuItem.setMod('hovered');
link.hasMod('focused').should.be.false;
menuItem.delMod('hovered');
menu.setMod('focused');
menuItem.setMod('hovered');
link.hasMod('focused').should.be.true;
});
it('should not remove focus from menu on unhover if it was focused before', function() {
menu.setMod('focused');
menuItem
.setMod('hovered')
.delMod('hovered');
menu.hasMod('focused').should.be.true;
});
});
describe('disabled', function() {
it('should mirror disabled state to link', function() {
link.hasMod('disabled').should.be.false;
menuItem.setMod('disabled');
link.hasMod('disabled').should.be.true;
menuItem.delMod('disabled');
link.hasMod('disabled').should.be.false;
});
});
});
provide();
});