Skip to content

Commit

Permalink
added new tests and fixed licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Meyer committed Jan 21, 2014
1 parent 4c1d357 commit 67944f9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
node_modules
bower_components
.grunt
_SpecRunner.html
1 change: 0 additions & 1 deletion dist/angular.easypiechart.js
Expand Up @@ -32,7 +32,6 @@ if (
options: '='
},
link: function (scope, element, attrs) {

/**
* default easy pie chart options
* @type {Object}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
"url": "http://www.opensource.org/licenses/mit-license.php"
}, {
"type": "GPL",
"url": "http://www.opensource.org/licenses/gpl-license.php) licenses"
"url": "http://www.opensource.org/licenses/gpl-license.php"
}],
"version": "2.1.3",
"author": {
Expand Down
1 change: 0 additions & 1 deletion src/angular.directive.js
Expand Up @@ -12,7 +12,6 @@ if (
options: '='
},
link: function (scope, element, attrs) {

/**
* default easy pie chart options
* @type {Object}
Expand Down
62 changes: 52 additions & 10 deletions test/unit/angular.directive.js
@@ -1,26 +1,68 @@
describe('angular easypiechart directive', function() {
var $compile;
var $rootScope;
var $compile, $rootScope, scope;

beforeEach(module('easypiechart'));

beforeEach(inject(function(_$compile_, _$rootScope_){
beforeEach(inject(function(_$compile_, $rootScope){
scope = $rootScope;
$compile = _$compile_;
$rootScope = _$rootScope_;
}));

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() {
var element = $compile('<div easypiechart></div>')($rootScope);
$rootScope.$digest();
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() {
$rootScope.options = {
scope.percent = 0;
scope.options = {
size: 200
};
var element = $compile('<div easypiechart options="options"></div>')($rootScope);
$rootScope.$digest();
expect(element.html()).toContain('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"');
});
});

0 comments on commit 67944f9

Please sign in to comment.