File size: 1,273 Bytes
3f268e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
describe('Unit testing jQuery version of easy pie chart', function() {
	var $el;

	var createInstance = function(options, el) {
		options = options || {};
		el = el || '<span class="chart"></span>';
		return function() {
			$el = $(el);
			$('body').append($el);
			$el.easyPieChart(options);
		};
	};

	describe('initialize plugin', function() {
		beforeEach(createInstance());

		it('should insert a canvas element', function() {
			expect($el.html()).toContain('canvas');
		});
	});


	describe('takes size option and', function() {
		var $canvas;
		beforeEach(createInstance({
			size: 200
		}));

		beforeEach(function() {
			$canvas = $el.find('canvas');
		});

		it('set correct width', function() {
			expect($canvas.width()).toBe(200);
		});

		it('set correct height', function() {
			expect($canvas.height()).toBe(200);
		});
	});

	describe('options should be overwritable by data attributes', function() {
		var $canvas;
		beforeEach(createInstance({
			size: 200
		}, '<span class="chart" data-size="400"></span>'));

		beforeEach(function() {
			$canvas = $el.find('canvas');
		});

		it('overwrite width', function() {
			expect($canvas.width()).toBe(400);
		});

		it('overwrite height', function() {
			expect($canvas.height()).toBe(400);
		});
	});

});