Commit a97d836f authored by Eduardo L. Buratti's avatar Eduardo L. Buratti

Add test framework

parent d2be408e
......@@ -32,5 +32,9 @@
"mongodb": "^2.2.5",
"osprey": "^0.3.2",
"raml2html": "^2.4.0"
},
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.0.2"
}
}
/*
* Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana
*
* This file is part of blendb.
*
* blendb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* blendb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with blendb. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
process.env.NODE_ENV = 'test';
global.expect = require('chai').expect;
// Add the ./src directory to require's search path to facilitate import
// modules later on (avoiding the require('../../../../module') problem).
require('app-module-path').addPath(__dirname + '/../src');
--require ./test/global.js
--reporter spec
--ui bdd
--recursive
--colors
--timeout 60000
--slow 300
--check-leaks
--globals expect
/*
* Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana
*
* This file is part of blendb.
*
* blendb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* blendb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with blendb. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
/* globals expect */
/* jshint -W024 */
/* jshint expr:true, maxlen:false */
/* jscs:disable maximumLineLength */
const hash = require('util/hash');
describe('hash utility library', () => {
it('should generate a sha1 hash for a collection of objects', () => {
let h = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
expect(h).to.be.a('string');
expect(h).to.not.be.empty;
});
it('should generate the same hash for the same input', () => {
let h1 = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
let h2 = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
expect(h1).to.be.a('string');
expect(h2).to.be.a('string');
expect(h1).to.be.equal(h2);
});
it('should generate the same hash for different order of input', () => {
let h1 = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
let h2 = hash.sha1('test', ['list', 'of', 'things'], { obj: 'test' });
expect(h1).to.be.a('string');
expect(h2).to.be.a('string');
expect(h1).to.be.equal(h2);
});
it('should not generate the same hash for distinct input', () => {
let h1 = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
let h2 = hash.sha1('test', { obj: 'test', x: true },
['list', 'of', 'things']);
expect(h1).to.be.a('string');
expect(h2).to.be.a('string');
expect(h1).to.not.be.equal(h2);
});
it('should not generate the same hash for different order in deep lists', () => {
let h1 = hash.sha1('test', { obj: 'test' }, ['list', 'of', 'things']);
let h2 = hash.sha1('test', { obj: 'test' }, ['of', 'list', 'things']);
expect(h1).to.be.a('string');
expect(h2).to.be.a('string');
expect(h1).to.not.be.equal(h2);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment