commit
f3abbeadfd
@ -1,4 +1,5 @@
|
|||||||
.sass-cache/
|
.sass-cache/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
coverage/
|
||||||
.project
|
.project
|
||||||
_site/
|
_site/
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
module.exports = function(config) {
|
||||||
|
config.set({
|
||||||
|
basePath: '',
|
||||||
|
frameworks: ['mocha', 'requirejs', 'chai', 'sinon', 'sinon-chai'],
|
||||||
|
files: [
|
||||||
|
'test-main.js',
|
||||||
|
'src/vendor/glMatrix.js',
|
||||||
|
'src/typedefs.js',
|
||||||
|
{pattern: 'src/*.js', included: false},
|
||||||
|
{pattern: 'spec/**/*.js', included: false},
|
||||||
|
],
|
||||||
|
exclude: [
|
||||||
|
],
|
||||||
|
preprocessors: {
|
||||||
|
'src/*.js': ['coverage']
|
||||||
|
},
|
||||||
|
reporters: ['progress', 'coverage'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['PhantomJS'],
|
||||||
|
singleRun: false,
|
||||||
|
coverageReporter: {
|
||||||
|
type : 'html',
|
||||||
|
dir : 'coverage/'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,53 @@
|
|||||||
|
define(['array_helper'], function(ArrayHelper){
|
||||||
|
describe('init', function() {
|
||||||
|
it('initializes an array with the given value', function() {
|
||||||
|
var input = [0, 0, 0];
|
||||||
|
ArrayHelper.init(input, 5);
|
||||||
|
expect(input).to.deep.equal([5, 5, 5]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('shuffle', function() {
|
||||||
|
before(function() {
|
||||||
|
sinon.stub(Math, 'random').returns(0.5);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() {
|
||||||
|
sinon.restore(Math);
|
||||||
|
});
|
||||||
|
it('shuffles the content of an array', function() {
|
||||||
|
var input = [1, 2, 3];
|
||||||
|
expect(ArrayHelper.shuffle(input)).to.deep.equal([3, 1, 2]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('toPointList', function() {
|
||||||
|
it('converts an Array to a List of poitns', function() {
|
||||||
|
var input = [[1, 2], [2, 2], [3, 2]];
|
||||||
|
expect(ArrayHelper.toPointList(input)).to.equal("[[1,2],\r\n[2,2],\r\n[3,2]]");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('threshold', function() {
|
||||||
|
it('returns all elements above the given threshold', function() {
|
||||||
|
var input = [1, 2, 3];
|
||||||
|
expect(ArrayHelper.threshold(input, 2, function(score) {
|
||||||
|
return score * 1.5;
|
||||||
|
})).to.deep.equal([2, 3]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('maxIndex', function() {
|
||||||
|
it('gets the index of the biggest element in the array', function() {
|
||||||
|
var input = [1, 2, 3];
|
||||||
|
expect(ArrayHelper.maxIndex(input)).to.equal(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('max', function() {
|
||||||
|
it('gets the biggest element in the array', function() {
|
||||||
|
var input = [1, 3, 2];
|
||||||
|
expect(ArrayHelper.max(input)).to.equal(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
define(['cv_utils'], function(CVUtils){
|
||||||
|
describe('imageRef', function() {
|
||||||
|
it('gets the image Reference for a coordinate', function() {
|
||||||
|
var res = CVUtils.imageRef(1, 2);
|
||||||
|
expect(res.x).to.equal(1);
|
||||||
|
expect(res.y).to.equal(2);
|
||||||
|
expect(res.toVec2()[0]).to.equal(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,26 @@
|
|||||||
|
var allTestFiles = [];
|
||||||
|
var TEST_REGEXP = /(spec|test)\.js$/i;
|
||||||
|
|
||||||
|
var pathToModule = function(path) {
|
||||||
|
return path.replace(/^\/base\//, '').replace(/\.js$/, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(window.__karma__.files).forEach(function(file) {
|
||||||
|
if (TEST_REGEXP.test(file)) {
|
||||||
|
allTestFiles.push(pathToModule(file));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
require.config({
|
||||||
|
baseUrl: '/base',
|
||||||
|
|
||||||
|
paths: {
|
||||||
|
'array_helper': 'src/array_helper',
|
||||||
|
'cv_utils': 'src/cv_utils',
|
||||||
|
'typedefs': 'src/typedefs',
|
||||||
|
'glMatrixAddon': 'src/glMatrixAddon',
|
||||||
|
'cluster': 'src/cluster'
|
||||||
|
},
|
||||||
|
deps: allTestFiles,
|
||||||
|
callback: window.__karma__.start
|
||||||
|
});
|
Loading…
Reference in New Issue