Browse Source

[several] Fixes and features:

* non-identifier is disallowed
* library not- tests are priority
* queue fix for before and after end hooks
master
Muthu Kumar 6 years ago
parent
commit
c3e8c22ea7
  1. 2
      package.json
  2. 8
      src/lib/buildTestQueue.js
  3. 7
      src/lib/expect.js
  4. 16
      src/lib/testrunner.js

2
package.json

@ -1,6 +1,6 @@
{
"name": "@klenty/gunner",
"version": "0.9.1",
"version": "0.9.2",
"description": "Zero magic, fast test-runner and assertion framework. No magic globals.",
"main": "index.js",
"repository": {

8
src/lib/buildTestQueue.js

@ -35,12 +35,12 @@ const buildTestTree = instance => {
));
testQueue.push.apply(
Array.prototype.push.apply(testQueue,
instance.__suite__.beforeHooks[symbols.End]
.map(wrap('@end')));
testQueue.push.apply(
.map(wrap('@beforeend')));
Array.prototype.push.apply(testQueue,
instance.__suite__.afterHooks[symbols.End]
.map(wrap(symbols.End)));
.map(wrap('@end')));
return testQueue;

7
src/lib/expect.js

@ -46,14 +46,17 @@ const expect = (thing, args) =>
new Proxy({}, {
get: function (obj, prop) {
const toCheck = args ? thing(...args) : thing;
if (prop.slice(0, 3) === 'not')
if (expects.hasOwnProperty(prop))
return (...check) => expects[prop](toCheck)(...check);
else if (prop.slice(0, 3) === 'not')
return (...check) =>
negateP(
expects[
lowerCaseFirstLetter(prop.slice(3))
](toCheck)(...check)
);
return (...check) => expects[prop](toCheck)(...check);
else
throw new Error('Unknown assertion method', prop);
},
});

16
src/lib/testrunner.js

@ -52,13 +52,6 @@ const reduceQueue =
const { status } = result;
const identifier = (item.unit.label)
|| (queue
.filter(i => i.type === item.type)
.filter(i => (i.unit.description
=== item.unit.description))
.length);
if (item.type === '@test') {
const resultObject = {
@ -73,13 +66,20 @@ const reduceQueue =
} else {
const identifier = (item.unit.label)
|| (queue
.filter(i => i.type === item.type)
.filter(i => (i.unit.description
=== item.unit.description))
.length);
const stateAddition =
/* eslint-disable-next-line */
status === 'ok'
? result.promise ? result.resolve : result.value
: null;
if (stateAddition)
if (identifier && stateAddition)
assignToObject(
acc.state, item.type
)(identifier, stateAddition);

Loading…
Cancel
Save