Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/easy-pie-chart/test/unit/jquery.js
1293 views
1
describe('Unit testing jQuery version of easy pie chart', function() {
2
var $el;
3
4
var createInstance = function(options, el) {
5
options = options || {};
6
el = el || '<span class="chart"></span>';
7
return function() {
8
$el = $(el);
9
$('body').append($el);
10
$el.easyPieChart(options);
11
};
12
};
13
14
describe('initialize plugin', function() {
15
beforeEach(createInstance());
16
17
it('should insert a canvas element', function() {
18
expect($el.html()).toContain('canvas');
19
});
20
});
21
22
23
describe('takes size option and', function() {
24
var $canvas;
25
beforeEach(createInstance({
26
size: 200
27
}));
28
29
beforeEach(function() {
30
$canvas = $el.find('canvas');
31
});
32
33
it('set correct width', function() {
34
expect($canvas.width()).toBe(200);
35
});
36
37
it('set correct height', function() {
38
expect($canvas.height()).toBe(200);
39
});
40
});
41
42
describe('options should be overwritable by data attributes', function() {
43
var $canvas;
44
beforeEach(createInstance({
45
size: 200
46
}, '<span class="chart" data-size="400"></span>'));
47
48
beforeEach(function() {
49
$canvas = $el.find('canvas');
50
});
51
52
it('overwrite width', function() {
53
expect($canvas.width()).toBe(400);
54
});
55
56
it('overwrite height', function() {
57
expect($canvas.height()).toBe(400);
58
});
59
});
60
61
});
62
63