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", "name": "@klenty/gunner",
"version": "0.9.1", "version": "0.9.2",
"description": "Zero magic, fast test-runner and assertion framework. No magic globals.", "description": "Zero magic, fast test-runner and assertion framework. No magic globals.",
"main": "index.js", "main": "index.js",
"repository": { "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] instance.__suite__.beforeHooks[symbols.End]
.map(wrap('@end'))); .map(wrap('@beforeend')));
testQueue.push.apply( Array.prototype.push.apply(testQueue,
instance.__suite__.afterHooks[symbols.End] instance.__suite__.afterHooks[symbols.End]
.map(wrap(symbols.End))); .map(wrap('@end')));
return testQueue; return testQueue;

7
src/lib/expect.js

@ -46,14 +46,17 @@ const expect = (thing, args) =>
new Proxy({}, { new Proxy({}, {
get: function (obj, prop) { get: function (obj, prop) {
const toCheck = args ? thing(...args) : thing; 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) => return (...check) =>
negateP( negateP(
expects[ expects[
lowerCaseFirstLetter(prop.slice(3)) lowerCaseFirstLetter(prop.slice(3))
](toCheck)(...check) ](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 { 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') { if (item.type === '@test') {
const resultObject = { const resultObject = {
@ -73,13 +66,20 @@ const reduceQueue =
} else { } else {
const identifier = (item.unit.label)
|| (queue
.filter(i => i.type === item.type)
.filter(i => (i.unit.description
=== item.unit.description))
.length);
const stateAddition = const stateAddition =
/* eslint-disable-next-line */ /* eslint-disable-next-line */
status === 'ok' status === 'ok'
? result.promise ? result.resolve : result.value ? result.promise ? result.resolve : result.value
: null; : null;
if (stateAddition) if (identifier && stateAddition)
assignToObject( assignToObject(
acc.state, item.type acc.state, item.type
)(identifier, stateAddition); )(identifier, stateAddition);

Loading…
Cancel
Save