/
menu_mode.spec.js
52 lines (41 loc) · 1.21 KB
/
menu_mode.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
modules.define(
'spec',
['menu', 'i-bem-dom', 'jquery', 'sinon', 'BEMHTML'],
function(provide, Menu, bemDom, $, sinon, BEMHTML) {
describe('menu_mode', function() {
var menu, menuVal;
beforeEach(function() {
menuVal = 'bla';
Menu.declMod({ modName : 'mode', modVal : 'bla' }, {
_getVal : function() {
return menuVal;
}
});
menu = buildMenu({
block : 'menu',
mods : { mode : 'bla' }
});
});
afterEach(function() {
bemDom.destruct(menu.domElem);
});
describe('content change', function() {
it('should update value after content was changed', function() {
menu.setContent('');
menuVal = 'blabla';
menu.getVal().should.be.equal('blabla');
});
it('should emit change event after content was changed', function() {
var spy = sinon.spy();
menu._events().on('change', spy);
menu.setContent('');
spy.should.have.been.called;
});
});
});
provide();
function buildMenu(bemjson) {
return bemDom.init($(BEMHTML.apply(bemjson)).appendTo('body'))
.bem(Menu);
}
});