File size: 2,421 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 63 64 65 66 67 68 69 |
describe('angular easypiechart directive', function() {
var $compile, $rootScope, scope;
beforeEach(module('easypiechart'));
beforeEach(inject(function(_$compile_, $rootScope){
scope = $rootScope;
$compile = _$compile_;
}));
it('should have percentage default value 0', function (done) {
scope.percent = null;
var element = angular.element('<div easypiechart percent="percent" options="options"></div>');
$compile(element)(scope);
scope.$digest();
expect(element.isolateScope().percent).toBe(0);
});
it('inserts the element with a canvas element', function() {
scope.percent = -45;
scope.options = {};
var element = angular.element('<div easypiechart percent="percent" options="options"></div>');
$compile(element)(scope);
scope.$digest();
expect(element.html()).toContain('canvas');
});
it('gets the options right', function (done) {
scope.percent = 0;
scope.options = {
animate:{
duration:0,
enabled:false
},
barColor:'#2C3E50',
scaleColor:false,
lineWidth:20,
lineCap:'circle'
};
var element = angular.element('<div easypiechart percent="percent" options="options"></div>');
$compile(element)(scope);
scope.$digest();
expect(element.isolateScope().options.animate.duration).toBe(0);
expect(element.isolateScope().options.lineCap).toBe('circle');
});
it('has its own default options', function (done) {
scope.percent = 0;
scope.options = {};
var element = angular.element('<div easypiechart percent="percent" options="options"></div>');
$compile(element)(scope);
scope.$digest();
expect(element.isolateScope().options.size).toBe(110);
expect(element.isolateScope().options.animate.enabled).toBe(true);
});
it('takes size option the right way', function() {
scope.percent = 0;
scope.options = {
size: 200
};
var element = angular.element('<div easypiechart percent="percent" options="options"></div>');
$compile(element)(scope);
scope.$digest();
expect(element.html()).toContain('height="200"');
expect(element.html()).toContain('width="200"');
});
});
|