From cdc5dcfa1799b160cdde94d310e54c78e7a05df9 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 28 Feb 2017 15:47:29 -0500 Subject: [PATCH] From mocha to jest --- .istanbul.yml | 9 --- package.json | 22 +++++-- test/FB_TEST_DB.FDB | Bin 1040384 -> 1040384 bytes test/adapters/dblite_test.js | 10 +-- test/adapters/mysql2_test.js | 12 ++-- ...firebird_test.js => node-firebird_test.js} | 8 +-- test/adapters/pg_test.js | 18 +++--- test/adapters/sqlite3_test.js | 10 +-- test/base/adapterPromiseTestRunner.js | 38 +++++------ test/base_test.js | 14 ++-- test/docker_install.sh | 4 +- test/helpers_test.js | 60 +++++++++--------- test/mocha.opts | 3 +- test/query-parser_test.js | 30 ++++----- 14 files changed, 120 insertions(+), 118 deletions(-) delete mode 100644 .istanbul.yml rename test/adapters/{00node-firebird_test.js => node-firebird_test.js} (83%) diff --git a/.istanbul.yml b/.istanbul.yml deleted file mode 100644 index 51f02d4..0000000 --- a/.istanbul.yml +++ /dev/null @@ -1,9 +0,0 @@ -reporting: - print: summary - reports: - - lcov - - lcovonly - - clover - - html - - text - dir: ./coverage \ No newline at end of file diff --git a/package.json b/package.json index 531487a..ccc1e3b 100644 --- a/package.json +++ b/package.json @@ -52,25 +52,37 @@ "eslint": "^3.5.0", "globstar": "^1.0.0", "happiness": "^7.1.2", - "istanbul": "~0.4.2", - "mocha": "^3.0.0", + "jest": "^19.0.2", "npm-run-all": "^3.0.0", "nsp": "^2.2.1" }, "license": "MIT", + "jest": { + "coverageDirectory": "coverage", + "coverageReporters": [ + "html", + "json", + "lcov", + "text-summary" + ], + "testEnvironment": "node", + "testMatch": [ + "**/test/**/*_test.js" + ] + }, "scripts": { "audit": "nsp check", "build": "npm-run-all --parallel lint:src lint:tests docs coverage", - "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha", + "coverage": "jest --coverage", "default": "npm-run-all --parallel audit lint:src lint:tests && npm run test", "predocs": "globstar -- documentation build -f md -o API.md \"lib/*.js\"", "docs": "globstar -- documentation build -f html -o docs \"lib/*.js\"", "happy": "happiness \"lib/**/*.js\" \"test/**/*.js\"", "happy:src": "happiness \"lib/**/*.js\"", "happy:tests": "happiness \"test/**/*.js\"", - "lint": "npm-run-all lint:tests lint:src && happy", + "lint": "npm-run-all lint:tests lint:src happy", "lint:src": "eslint ./lib", "lint:tests": "eslint ./test", - "test": "mocha -R spec" + "test": "jest" } } diff --git a/test/FB_TEST_DB.FDB b/test/FB_TEST_DB.FDB index f68f70ad3367d4cf1fb0321867a34c3ec778b84a..0a7051b295bbb59880c94a78282a0faf5b5f82be 100755 GIT binary patch delta 1822 zcmZXTT}WI<6oAj%{c(54o4u_+Wlhz)rmov;5_B696AD_S38A0}l@>K3CD1}43O*zx zBx?*_leoGu0jH%D3l^G^7n77;A5CBSqw8AeORY2yHIcrgmiD30EauG2z3%R0F87}K z&N*}D%sF#Mm)b^`+ByjwYyNQ%3d5kI9)}(e06cMC0F8XM4)E^LT+`ce>0p3{&!7N; z-zNhPqBrk{ZyDa;8(!)1m_@&!4P@JnnxVDum}!~BGBwNeSf1Bo7%T;)?tD<_*rQR}*v6fHDU(iVlpi^B zt_Nqn=$H0kM+zH$0{$q^a?^*&UaIy$OR^cx4xR3G?Eo7C?D80WHBRyX#;%&k`4B-( z;Z4H&0PDO;Yb*VEp_cw0;Y`@0tX`G+6}z{HdJj4fUoUZ)$KjFgqFoLR2>CA$zIQYN zEe`>G(I*f6uAQ&IjF1Z%@OcuxR%7@-z+2IJ_&f0Vc@%G+y_MA)j}y34oDHsZnaAPJ z1vQeB4f{DmE7-*qJ(4`Hx)e6!dtoICLsX)l{hrmUThEnj4dAle8sL-~w|MIm=El3x z^04Uad4Bej>ax;wyf37Kb>T7iABNJo0{|zK^jsF{_2M=B>9l*U(niVB>>Z<(F_F*@ zs$XeBe$k7%!%1=Z@Zx=s{``XYcmwdvF3Y-v^Pd*tu~ddu$BQnjCH7X*z_WX-d$?Q-XezR6i{|Kb#h}yOREq zbTlJuc&-libez`M8yOlmNX<-lMUVi$Pgoo~x*hr}JYg(Q+gK?7cSmcjxBUxxPucBu z!y;|>y6Xb7!vU{e#l4+D?3dd2^o5#7uo4?WCx5rUcYi0Ri@V(k@ZIWIdsdI9w$Y2P zI>dW|(&d8+A5b`<@P36~S2(V4ljPLyhB3vVQQ_AV-luSb!cm1yh3f_D0G}7?#B$3z z?{US7&O6?>B4|$1mZU^h*haF#W=qCNpeKEO1`ZZ^n;f?4C(=jE-lpWLOn2KZi9aDA8fMW(7 zGvt`z%O;aXC*^&ekJJkT?>8k4xyw@2qSdHPXQKuk#d;7*AdeuwRcFyv=!-g=(sc%n zVBHJFkl)h`+R!YzpvCDV;;3fRey|p-%MptAP?ynB$h0Z_|(12=FLNzGwwidC^w|pS zk$HZK*~*de*Hir8~SyUo^aGEvo*c98&*QQxW-Xp5it_soH<2*gj z%(g_z+jGlZ5-8=q8P+aWhTJWb_9~glu-3;ViMsv&h?93sws=abLPxOEEZZrs3j_Z1 zEK`>zz8W)q> zG?`L(JiHK8T1oz1_p#phr;}w)HnNn}6nRH$PR(ks1SH=|ayhs(5mY9t-+*^jZ%s)C zl`v^43$EHT)_b_9sv*#jaP6jh)46z@%skNd1 z@Wq%}#ke^WX``bUH-iydrvyL{;1)CJDzjITT}=LTr24@=%CE0!PoQ_(3Yy!@D1WEm zg3mX>Ujpo2_bQIByA`<_i1GSsTDAYrToV;B{+R&9O|YxzRty)tipwsTzFE|uy4=lT Hv`POD0Xb)z diff --git a/test/adapters/dblite_test.js b/test/adapters/dblite_test.js index 690fc3e..638866d 100644 --- a/test/adapters/dblite_test.js +++ b/test/adapters/dblite_test.js @@ -15,8 +15,8 @@ const config = testBase.config; let nodeQuery = require('../../lib/NodeQuery')(config.dblite); let qb = nodeQuery.getQuery(); -suite('Dblite adapter tests -', () => { - suiteSetup(done => { +describe('Dblite adapter tests -', () => { + beforeAll(done => { // Set up the sqlite database const createTest = 'CREATE TABLE IF NOT EXISTS "create_test" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);'; const createJoin = 'CREATE TABLE IF NOT EXISTS "create_join" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);'; @@ -29,7 +29,7 @@ suite('Dblite adapter tests -', () => { }); testRunner(qb); - test('Promise - Select with function and argument in WHERE clause', () => { + it('Promise - Select with function and argument in WHERE clause', () => { let promise = qb.select('id') .from('create_test') .where('id', 'ABS(-88)') @@ -37,7 +37,7 @@ suite('Dblite adapter tests -', () => { expect(promise).to.be.fulfilled; }); - test('Promise - Test Insert Batch', () => { + it('Promise - Test Insert Batch', () => { let data = [ { id: 544, @@ -57,7 +57,7 @@ suite('Dblite adapter tests -', () => { let promise = qb.insertBatch('create_test', data); expect(promise).to.be.fulfilled; }); - suiteTeardown(() => { + afterAll(() => { qb.end(); }); }); diff --git a/test/adapters/mysql2_test.js b/test/adapters/mysql2_test.js index ea87a72..323937f 100644 --- a/test/adapters/mysql2_test.js +++ b/test/adapters/mysql2_test.js @@ -16,14 +16,14 @@ const config = testBase.config[adapterName]; let nodeQuery = reload('../../lib/NodeQuery')(config); let qb = nodeQuery.getQuery(); -suite('Mysql2 adapter tests -', () => { - test('nodeQuery.getQuery = nodeQuery.init', () => { +describe('Mysql2 adapter tests -', () => { + it('nodeQuery.getQuery = nodeQuery.init', () => { expect(nodeQuery.getQuery()) .to.be.deep.equal(qb); }); testRunner(qb); - test('Promise - Select with function and argument in WHERE clause', () => { + it('Promise - Select with function and argument in WHERE clause', () => { let promise = qb.select('id') .from('create_test') .where('id', 'CEILING(SQRT(88))') @@ -31,11 +31,11 @@ suite('Mysql2 adapter tests -', () => { return expect(promise).to.be.fulfilled; }); - test('Test Truncate', () => { + it('Test Truncate', () => { let promise = qb.truncate('create_test'); return expect(promise).to.be.fullfilled; }); - test('Test Insert Batch', () => { + it('Test Insert Batch', () => { let data = [ { id: 5442, @@ -55,7 +55,7 @@ suite('Mysql2 adapter tests -', () => { return expect(qb.insertBatch('create_test', data)).to.be.fulfilled; }); - /* suiteTeardown(() => { + /* describeTeardown(() => { qb.end(); }); */ }); diff --git a/test/adapters/00node-firebird_test.js b/test/adapters/node-firebird_test.js similarity index 83% rename from test/adapters/00node-firebird_test.js rename to test/adapters/node-firebird_test.js index 6a87c52..c56db1c 100644 --- a/test/adapters/00node-firebird_test.js +++ b/test/adapters/node-firebird_test.js @@ -18,12 +18,12 @@ if (!(process.env.CI || process.env.TRAVIS)) { let qb = nodeQuery.getQuery(); - suite('Firebird adapter tests -', () => { - test('nodeQuery.getQuery = nodeQuery.init', () => { + describe('Firebird adapter tests -', () => { + it('nodeQuery.getQuery = nodeQuery.init', () => { expect(nodeQuery.getQuery()) .to.be.deep.equal(qb); }); - test('insertBatch throws error', () => { + it('insertBatch throws error', () => { expect(() => { qb.driver.insertBatch('create_test', []); }).to.throw(Error, 'Not Implemented'); @@ -31,7 +31,7 @@ if (!(process.env.CI || process.env.TRAVIS)) { testRunner(qb); - suiteTeardown(() => { + afterAll(() => { qb.end(); }); }); diff --git a/test/adapters/pg_test.js b/test/adapters/pg_test.js index 3a6d3e6..4cfc2fb 100644 --- a/test/adapters/pg_test.js +++ b/test/adapters/pg_test.js @@ -18,21 +18,21 @@ let nodeQuery = reload('../../lib/NodeQuery')(config); let qb = nodeQuery.getQuery(); let qb2 = null; -suite('Pg adapter tests -', () => { - test('nodeQuery.getQuery = nodeQuery.init', () => { +describe('Pg adapter tests -', () => { + it('nodeQuery.getQuery = nodeQuery.init', () => { expect(nodeQuery.getQuery()) .to.be.deep.equal(qb); }); - test('Connecting with an object also works', () => { + it('Connecting with an object also works', () => { let config = allConfig[`${adapterName}-object`]; let nodeQuery = reload('../../lib/NodeQuery')(config); qb2 = nodeQuery.getQuery(); - return expect(qb2).to.be.ok; + expect(qb2).to.be.ok; }); - test('Test Connection Error', done => { + it('Test Connection Error', done => { try { reload('../../lib/NodeQuery')({}); done(true); @@ -44,7 +44,7 @@ suite('Pg adapter tests -', () => { }); testRunner(qb); - test('Promise - Select with function and argument in WHERE clause', () => { + it('Promise - Select with function and argument in WHERE clause', () => { let promise = qb.select('id') .from('create_test') .where('id', 'CEILING(SQRT(88))') @@ -52,11 +52,11 @@ suite('Pg adapter tests -', () => { return expect(promise).to.be.fulfilled; }); - test('Promise - Test Truncate', () => { + it('Promise - Test Truncate', () => { let promise = qb.truncate('create_test'); return expect(promise).to.be.fulfilled; }); - test('Promise - Test Insert Batch', () => { + it('Promise - Test Insert Batch', () => { let data = [ { id: 544, @@ -76,7 +76,7 @@ suite('Pg adapter tests -', () => { let promise = qb.insertBatch('create_test', data); return expect(promise).to.be.fulfilled; }); - suiteTeardown(() => { + afterAll(() => { qb.end(); qb2.end(); }); diff --git a/test/adapters/sqlite3_test.js b/test/adapters/sqlite3_test.js index e86f1fc..05312fd 100644 --- a/test/adapters/sqlite3_test.js +++ b/test/adapters/sqlite3_test.js @@ -15,8 +15,8 @@ const config = testBase.config; let nodeQuery = require('../../lib/NodeQuery')(config.sqlite3); let qb = nodeQuery.getQuery(); -suite('Sqlite3 adapter tests -', () => { - suiteSetup(done => { +describe('Sqlite3 adapter tests -', () => { + beforeAll(done => { // Set up the sqlite database const createTest = 'CREATE TABLE IF NOT EXISTS "create_test" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);'; const createJoin = 'CREATE TABLE IF NOT EXISTS "create_join" ("id" INTEGER PRIMARY KEY, "key" TEXT, "val" TEXT);'; @@ -29,7 +29,7 @@ suite('Sqlite3 adapter tests -', () => { }); testRunner(qb); - test('Promise - Select with function and argument in WHERE clause', () => { + it('Promise - Select with function and argument in WHERE clause', () => { let promise = qb.select('id') .from('create_test') .where('id', 'ABS(-88)') @@ -37,7 +37,7 @@ suite('Sqlite3 adapter tests -', () => { expect(promise).to.be.fulfilled; }); - test('Promise - Test Insert Batch', () => { + it('Promise - Test Insert Batch', () => { let data = [ { id: 544, @@ -57,7 +57,7 @@ suite('Sqlite3 adapter tests -', () => { let promise = qb.insertBatch('create_test', data); expect(promise).to.be.fulfilled; }); - suiteTeardown(() => { + afterAll(() => { qb.end(); }); }); diff --git a/test/base/adapterPromiseTestRunner.js b/test/base/adapterPromiseTestRunner.js index 58c391b..19556c3 100644 --- a/test/base/adapterPromiseTestRunner.js +++ b/test/base/adapterPromiseTestRunner.js @@ -11,11 +11,11 @@ const reload = require('require-reload')(require); const tests = reload('../base/tests'); module.exports = function promiseTestRunner (qb) { - Object.keys(tests).forEach(suiteName => { - suite(suiteName, () => { - let currentSuite = tests[suiteName]; + Object.keys(tests).forEach(describeName => { + describe(describeName, () => { + let currentSuite = tests[describeName]; Object.keys(currentSuite).forEach(testDesc => { - test(testDesc, done => { + it(testDesc, done => { const methodObj = currentSuite[testDesc]; const methodNames = Object.keys(methodObj); let results = []; @@ -45,13 +45,13 @@ module.exports = function promiseTestRunner (qb) { }); }); }); - suite('DB update tests -', () => { - suiteSetup(done => { + describe('DB update tests -', () => { + beforeAll(done => { let sql = qb.driver.truncate('create_test'); qb.query(sql).then(res => done()) .catch(err => done(err)); }); - test('Promise - Test Insert', () => { + it('Promise - Test Insert', () => { let promise = qb.set('id', 98) .set('key', '84') .set('val', Buffer.from('120')) @@ -59,7 +59,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Test Insert Object', () => { + it('Promise - Test Insert Object', () => { let promise = qb.insert('create_test', { id: 587, key: 1, @@ -68,7 +68,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Test Update', () => { + it('Promise - Test Update', () => { let promise = qb.where('id', 7) .update('create_test', { id: 7, @@ -78,7 +78,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Test set Array Update', () => { + it('Promise - Test set Array Update', () => { let object = { id: 22, key: 'gogle', @@ -91,7 +91,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Test where set update', () => { + it('Promise - Test where set update', () => { let promise = qb.where('id', 36) .set('id', 36) .set('key', 'gogle') @@ -100,17 +100,17 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Test delete', () => { + it('Promise - Test delete', () => { let promise = qb.delete('create_test', {id: 5}); return expect(promise).to.be.fulfilled; }); - test('Promise - Delete with where', () => { + it('Promise - Delete with where', () => { let promise = qb.where('id', 5) .delete('create_test'); return expect(promise).to.be.fulfilled; }); - test('Promise - Delete multiple where values', () => { + it('Promise - Delete multiple where values', () => { let promise = qb.delete('create_test', { id: 5, key: 'gogle' @@ -119,8 +119,8 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); }); - suite('Grouping tests -', () => { - test('Promise - Using grouping method', () => { + describe('Grouping tests -', () => { + it('Promise - Using grouping method', () => { let promise = qb.select('id, key as k, val') .from('create_test') .groupStart() @@ -132,7 +132,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Using where first grouping', () => { + it('Promise - Using where first grouping', () => { let promise = qb.select('id, key as k, val') .from('create_test') .where('id !=', 5) @@ -145,7 +145,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Using or grouping method', () => { + it('Promise - Using or grouping method', () => { let promise = qb.select('id, key as k, val') .from('create_test') .groupStart() @@ -160,7 +160,7 @@ module.exports = function promiseTestRunner (qb) { return expect(promise).to.be.fulfilled; }); - test('Promise - Using or not grouping method', () => { + it('Promise - Using or not grouping method', () => { let promise = qb.select('id, key as k, val') .from('create_test') .groupStart() diff --git a/test/base_test.js b/test/base_test.js index bcaab45..bbcd538 100644 --- a/test/base_test.js +++ b/test/base_test.js @@ -7,19 +7,19 @@ const glob = require('glob'); const nodeQuery = reload('../lib/NodeQuery')(); const Adapter = reload('../lib/Adapter'); -suite('Base tests -', () => { - suite('Sanity check', () => { +describe('Base tests -', () => { + describe('Sanity check', () => { let files = glob.sync(`${__dirname}/../lib/**/*.js`); files.forEach(mod => { let obj = require(mod); let shortName = mod.replace(/^\/(.*?)\/lib\/(.*?)\.js$/g, '$2'); - test(`${shortName} module is sane`, () => { + it(`${shortName} module is sane`, () => { expect(obj).to.be.ok; }); }); }); - test('NodeQuery.getQuery with no instance', () => { + it('NodeQuery.getQuery with no instance', () => { // Hack for testing to work around node // module caching let nodeQueryCopy = Object.create(nodeQuery); @@ -29,7 +29,7 @@ suite('Base tests -', () => { }).to.throw(Error, 'No Query Builder instance to return'); }); - test('Invalid driver type', () => { + it('Invalid driver type', () => { expect(() => { reload('../lib/NodeQuery')({ driver: 'Foo' @@ -37,14 +37,14 @@ suite('Base tests -', () => { }).to.throw(Error, 'Selected driver (Foo) does not exist!'); }); - test('Invalid adapter', () => { + it('Invalid adapter', () => { expect(() => { let a = new Adapter(); a.execute(); }).to.throw(Error, 'Correct adapter not defined for query execution'); }); - test('Invalid adapter - missing transformResult', () => { + it('Invalid adapter - missing transformResult', () => { expect(() => { let a = new Adapter(); a.transformResult([]); diff --git a/test/docker_install.sh b/test/docker_install.sh index 7009d6b..341b328 100644 --- a/test/docker_install.sh +++ b/test/docker_install.sh @@ -9,8 +9,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" set -xe # Install sqlite3 -apt-get update -yqq -apt-get install sqlite3 libsqlite3-dev -yqq +echo -e 'http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community\nhttp://dl-cdn.alpinelinux.org/alpine/edge/testing' > /etc/apk/repositories +apk add --no-cache git yarn sqlite3 libsqlite3 # Replace test config with docker config file mv "$DIR/config-ci.json" "$DIR/config.json" \ No newline at end of file diff --git a/test/helpers_test.js b/test/helpers_test.js index f44d4e2..d94f6b7 100644 --- a/test/helpers_test.js +++ b/test/helpers_test.js @@ -7,23 +7,23 @@ const expect = chai.expect; let helpers = require('../lib/helpers'); -suite('Helper Module Tests -', () => { - suite('Type-checking methods -', () => { - suite('Object wrappers are listed as their native type', () => { - test('Boolean Wrapper returns \'boolean\' not \'object\'', () => { +describe('Helper Module Tests -', () => { + describe('Type-checking methods -', () => { + describe('Object wrappers are listed as their native type', () => { + it('Boolean Wrapper returns \'boolean\' not \'object\'', () => { let item = Boolean(true); expect(helpers.type(item)).to.deep.equal('boolean'); }); - test('Number Wrapper returns \'number\' not \'object\'', () => { + it('Number Wrapper returns \'number\' not \'object\'', () => { let item = Number(4867); expect(helpers.type(item)).to.deep.equal('number'); }); - test('String Wrapper returns \'string\' not \'object\'', () => { + it('String Wrapper returns \'string\' not \'object\'', () => { let item = String('Foo'); expect(helpers.type(item)).to.deep.equal('string'); }); }); - suite('is..Method methods exist -', () => { + describe('is..Method methods exist -', () => { let types = [ 'Null', 'Undefined', @@ -39,19 +39,19 @@ suite('Helper Module Tests -', () => { ]; types.forEach(type => { - test(`is${type} method exists`, () => { + it(`is${type} method exists`, () => { assert.ok(helpers[`is${type}`]); }); }); }); - suite('isScalar -', () => { + describe('isScalar -', () => { let trueCases = { 'Strings are scalar': 'foo', 'Booleans are scalar': true, 'Numbers are scalar': 545 }; Object.keys(trueCases).forEach(desc => { - test(desc, () => { + it(desc, () => { expect(helpers.isScalar(trueCases[desc])).to.be.true; }); }); @@ -61,38 +61,38 @@ suite('Helper Module Tests -', () => { 'Objects are not scalar': [] }; Object.keys(falseCases).forEach(desc => { - test(desc, () => { + it(desc, () => { expect(helpers.isScalar(falseCases[desc])).to.be.false; }); }); }); - suite('isInfinity -', () => { - test('The type of 1/0 is infinity', () => { + describe('isInfinity -', () => { + it('The type of 1/0 is infinity', () => { expect(helpers.type(1 / 0)).to.equal('infinity'); }); - test('isInfinity is the same as isInfinite', () => { + it('isInfinity is the same as isInfinite', () => { expect(helpers.isInfinite(1 / 0)).to.be.true; }); }); - suite('isNaN -', () => { - test('The type of 0 / 0 is NaN', () => { + describe('isNaN -', () => { + it('The type of 0 / 0 is NaN', () => { expect(helpers.type(0 / 0)).to.equal('nan'); }); - test('isNaN method agrees with type', () => { + it('isNaN method agrees with type', () => { expect(helpers.isNaN(0 / 0)).to.be.true; }); }); }); - suite('Other helper methods -', () => { - suite('stringTrim -', () => { - test('stringTrim method works as expected', () => { + describe('Other helper methods -', () => { + describe('stringTrim -', () => { + it('stringTrim method works as expected', () => { let orig = [' x y ', 'z ', ' q']; let ret = ['x y', 'z', 'q']; expect(orig.map(helpers.stringTrim)).to.be.deep.equal(ret); }); }); - suite('arrayPluck -', () => { + describe('arrayPluck -', () => { let orig = [ { foo: 1 @@ -105,17 +105,17 @@ suite('Helper Module Tests -', () => { } ]; - test('Finding members in all objects', () => { + it('Finding members in all objects', () => { expect(helpers.arrayPluck(orig, 'foo')).to.be.deep.equal([1, 2, 3]); }); - test('Some members are missing in some objects', () => { + it('Some members are missing in some objects', () => { expect(helpers.arrayPluck(orig, 'bar')).to.be.deep.equal([10, 15]); }); - test('Empty case', () => { + it('Empty case', () => { expect(helpers.arrayPluck([], 'apple')).to.be.deep.equal([]); }); }); - suite('regexInArray -', () => { + describe('regexInArray -', () => { let orig = ['apple', ' string ', 6, 4, 7]; let cases = [ @@ -131,7 +131,7 @@ suite('Helper Module Tests -', () => { [0, 1].forEach(i => { let boolCase = cases[i]; Object.keys(boolCase).forEach(desc => { - test(desc, () => { + it(desc, () => { if (i) { expect(helpers.regexInArray(orig, boolCase[desc])).to.be.true; } else { @@ -141,15 +141,15 @@ suite('Helper Module Tests -', () => { }); }); - test('First argument is not an array', () => { + it('First argument is not an array', () => { expect(helpers.regexInArray(5, /5/)).to.be.false; }); - test('Array is empty', () => { + it('Array is empty', () => { expect(helpers.regexInArray([], /.*/)).to.be.false; }); }); - suite('upperCaseFirst -', () => { - test('Capitalizes only the first letter of the string', () => { + describe('upperCaseFirst -', () => { + it('Capitalizes only the first letter of the string', () => { expect(helpers.upperCaseFirst('foobar')).to.equal('Foobar'); expect(helpers.upperCaseFirst('FOOBAR')).to.equal('FOOBAR'); }); diff --git a/test/mocha.opts b/test/mocha.opts index 4065ed0..fedf205 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,9 +1,8 @@ ---ui tdd --bail --recursive --reporter nyan --slow 200 --timeout 25000 --check-leaks ---growl +--growl test/**/*_test.js \ No newline at end of file diff --git a/test/query-parser_test.js b/test/query-parser_test.js index 7e10dcb..b90bd8e 100644 --- a/test/query-parser_test.js +++ b/test/query-parser_test.js @@ -52,34 +52,34 @@ let whereMock = function (key, val) { // ! Start Tests // ----------------------------------------------------------------------------- -suite('Query Parser Tests', () => { - suite('Has operator tests', () => { - test('Has operator', () => { +describe('Query Parser Tests', () => { + describe('Has operator tests', () => { + it('Has operator', () => { let matches = parser.hasOperator('foo <> 2'); expect(matches).to.be.deep.equal(['<>']); }); - test('Has no operator', () => { + it('Has no operator', () => { let matches = parser.hasOperator('foo'); expect(matches).to.be.null; }); }); - suite('Where parser tests', () => { - setup(() => { + describe('Where parser tests', () => { + beforeAll(() => { state = new State(); }); - test('Has function full string', () => { + it('Has function full string', () => { whereMock('time < SUM(FOO(BAR()))'); parser.parseWhere(driver, state); expect(state.whereMap) .to.be.deep.equal(['"time" < SUM(FOO(BAR()))']); }); - test('Has function key/val', () => { + it('Has function key/val', () => { whereMock('time <', 'SUM(FOO(BAR()))'); parser.parseWhere(driver, state); expect(state.whereMap) .to.be.deep.equal(['"time" < SUM(FOO(BAR()))']); }); - test('Has function key/val object', () => { + it('Has function key/val object', () => { whereMock({ 'time <': 'SUM(FOO(BAR(\'x\')))' }); @@ -87,7 +87,7 @@ suite('Query Parser Tests', () => { expect(state.whereMap) .to.be.deep.equal(['"time" < SUM(FOO(BAR(\'x\')))']); }); - test('Has literal value', () => { + it('Has literal value', () => { whereMock({ foo: 3 }); @@ -97,7 +97,7 @@ suite('Query Parser Tests', () => { expect(state.whereValues) .to.be.deep.equal(['3']); }); - test('Has multiple literal values', () => { + it('Has multiple literal values', () => { whereMock({ foo: 3, bar: 5 @@ -109,7 +109,7 @@ suite('Query Parser Tests', () => { .to.be.deep.equal(['3', '5']); }); }); - suite('Parse join tests', () => { + describe('Parse join tests', () => { let data = [ { desc: 'Simple equals condition', @@ -131,13 +131,13 @@ suite('Query Parser Tests', () => { ]; data.forEach(datum => { - test(datum.desc, () => { + it(datum.desc, () => { let matches = parser.parseJoin(datum.join); expect(matches.combined).to.be.deep.equal(datum.expected); }); }); }); - suite('Compile join tests', () => { + describe('Compile join tests', () => { let data = [ { desc: 'Simple equals condition', @@ -159,7 +159,7 @@ suite('Query Parser Tests', () => { ]; data.forEach(datum => { - test(datum.desc, () => { + it(datum.desc, () => { let join = parser.compileJoin(datum.clause); expect(join).to.be.deep.equal(datum.expected); });