mirror of
https://github.com/wassname/cardsforscience.git
synced 2026-06-27 18:42:09 +08:00
Added some tests
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
/* jasmine specs for controllers go here */
|
||||
describe('scienceAlchemy controllers', function () {
|
||||
var $controller;
|
||||
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toEqualData: function(util, customEqualityTesters) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var passed = angular.equals(actual, expected);
|
||||
return {
|
||||
pass: passed,
|
||||
message: 'Expected "' + actual + '"' + (passed ? '' : ' not') + ' to angular.equals "' + expected + '"'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
beforeEach(module('scienceAlchemy'));
|
||||
beforeEach(inject(function (_$controller_) {
|
||||
// The injector unwraps the underscores (_) from around the parameter names when matching
|
||||
$controller = _$controller_;
|
||||
}));
|
||||
|
||||
describe('ElementController', function () {
|
||||
var $scope, controller;
|
||||
|
||||
beforeEach(function () {
|
||||
$scope = {};
|
||||
controller = $controller('ElementController',{$scope:$scope});
|
||||
});
|
||||
|
||||
it('should have elements', function () {
|
||||
expect(controller.elements).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be visible', function () {
|
||||
var item = controller.elements[0];
|
||||
expect(controller.isVisible(item)).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be isAvailable', function () {
|
||||
var item = controller.elements[0];
|
||||
expect(controller.isAvailable(item)).toBeDefined();
|
||||
});
|
||||
|
||||
// onDrop
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/* jasmine specs for directives go here */
|
||||
|
||||
describe('directives', function() {
|
||||
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
/* jasmine specs for filters go here */
|
||||
|
||||
describe('filter', function () {
|
||||
|
||||
beforeEach(
|
||||
module('scienceAlchemy')
|
||||
);
|
||||
|
||||
describe('niceNumber', function () {
|
||||
it('should make numbers human readable',
|
||||
inject(function (niceNumberFilter) {
|
||||
expect(niceNumberFilter(100000000)).toBe("100.0M");
|
||||
expect(niceNumberFilter(10000)).toBe("10.0k");
|
||||
expect(niceNumberFilter(0.000000001)).toBe(1e-9);
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
describe('niceTime', function () {
|
||||
it('should make time human readable',
|
||||
inject(function (niceTimeFilter) {
|
||||
expect(niceTimeFilter(100000000)).toBe("1 day, 3 h, 46 min, 40 s");
|
||||
expect(niceTimeFilter(10000)).toBe("10 s");
|
||||
expect(niceTimeFilter(0.000000001)).toBe("1 s");
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
describe('currency', function () {
|
||||
it('should make currency human readable',
|
||||
inject(function (currencyFilter) {
|
||||
expect(currencyFilter(100000000)).toBe("JTN 100.0M");
|
||||
expect(currencyFilter(10000)).toBe("JTN 10.0k");
|
||||
expect(currencyFilter(0.000000001)).toBe('JTN 1e-9');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('reverse', function () {
|
||||
it('should reverse',
|
||||
inject(function (reverseFilter) {
|
||||
expect(reverseFilter([1,2,3])[0]).toBe(3);
|
||||
expect(reverseFilter([1,2,3])[1]).toBe(2);
|
||||
expect(reverseFilter([1,2,3])[2]).toBe(1);
|
||||
expect(reverseFilter([]).length).toBe(0);
|
||||
expect(reverseFilter([{i:1,2:2},{i:2},{i:3}])[0].i).toBe(3);
|
||||
expect(reverseFilter([{i:1,2:2},{i:2},{i:3}])[1].i).toBe(2);
|
||||
expect(reverseFilter([{i:1,2:2},{i:2},{i:3}])[2].i).toBe(1);
|
||||
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
describe('services', function () {
|
||||
|
||||
//load modules
|
||||
beforeEach(module('scienceAlchemy'));
|
||||
|
||||
// Test service availability
|
||||
describe('game', function () {
|
||||
it('should exist', inject(function (game) {
|
||||
expect(game).toBeDefined();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('detector', function () {
|
||||
it('should exist', inject(function (detector) {
|
||||
expect(detector).toBeDefined();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('lab', function () {
|
||||
it('should exist', inject(function (lab) {
|
||||
expect(lab).toBeDefined();
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user