forked from ecomfe/esui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.js
51 lines (42 loc) · 1.73 KB
/
Button.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
define(function (require) {
var Button = require('esui/Button');
var container = document.getElementById('container');
describe('Button', function () {
it('should be a constructor', function () {
expect(Button).toBeOfType('function');
});
it('should be instantiable', function () {
expect(new Button()).toBeOfType('object');
});
describe('create via script', function () {
it('should create a `<div>` element as its main element', function () {
var button = new Button();
button.appendTo(container);
expect(container.getElementsByTagName('div').length).toBeGreaterThan(0);
});
});
describe('created via HTML', function () {
var button;
beforeEach(function () {
var html = '<div data-ui="type: Button;id: test;">Button</div>';
container.innerHTML = html;
esui.init(container);
button = esui.getViewContext().get('test');
});
it('should be able to create from HTML', function () {
expect(button).toBeDefined();
});
it('should read `tagName` from HTML element', function () {
expect(button.get('tagName')).toBe('div');
});
});
describe('generally', function () {
it('should change the lable of button via `setContent`', function () {
var button = new Button();
button.appendTo(container);
button.setContent('New Button');
expect(button.main.firstChild.nextSibling.innerHTML).toBe('New Button');
});
});
});
});