Skip to content

Commit

Permalink
packages update, fix PR #29, some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolab committed Jan 21, 2019
1 parent f9ad2f4 commit a67f83e
Show file tree
Hide file tree
Showing 75 changed files with 9,240 additions and 2,087 deletions.
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog


## 2.1.0 - 2019-01-21

* Update all dependencies
* Break changes:
The native `Number()` is an object.
So `test.number(val)` and `test.value(val).isNumber()` consider the reality,
an instance of `Number()` is an object.

## 2.0.0 - 2015-04-19

### Update Should.js _v5.*_ to _v6*_.
Expand Down
7 changes: 1 addition & 6 deletions browser/dist/tests-unit.js

Large diffs are not rendered by default.

102 changes: 0 additions & 102 deletions browser/dist/unit.js

This file was deleted.

117 changes: 112 additions & 5 deletions browser/test/tests-unit.js

Large diffs are not rendered by default.

904 changes: 802 additions & 102 deletions browser/test/unit.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions browser/tmp/src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

var Noder = require('noder.io').Noder;

/**
* @constructor
*/
function UnitJS() {
Noder.call(this);
}

UnitJS.prototype = Object.create(Noder.prototype, {
constructor: { value: UnitJS }
});

UnitJS.prototype.UnitJS = UnitJS;

module.exports = new UnitJS();
46 changes: 46 additions & 0 deletions browser/tmp/src/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

var nativeAssert = require('assert');
var stats = require('./helpers').stats;
var methods = [
'ok', 'fail', 'equal', 'notEqual', 'deepEqual', 'notDeepEqual', 'strictEqual',
'notStrictEqual', 'throws', 'doesNotThrow', 'ifError'
];

function countAssertion(assertion) {
assertion = assertion ? 'assert.' + assertion : 'assert';

if (typeof stats.assertions[assertion] == 'undefined') {
stats.assertions[assertion] = 0;
}

stats.assertions[assertion]++;
stats.total.assertions++;
}

function assert(value, message) {
countAssertion();
return nativeAssert(value, message);
}


methods.forEach(function(method) {
assert[method] = function() {
countAssertion(method);
return nativeAssert[method].apply(assert, arguments);
};
});

module.exports = assert;
27 changes: 27 additions & 0 deletions browser/tmp/src/asserters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

// asserters are added below
module.exports.array = function(actual) { var Asserter = require('./asserters/array'); return new Asserter(actual); };
module.exports.bool = function(actual) { var Asserter = require('./asserters/bool'); return new Asserter(actual); };
module.exports.date = function(actual) { var Asserter = require('./asserters/date'); return new Asserter(actual); };
module.exports.error = function(actual) { var Asserter = require('./asserters/error'); return new Asserter(actual); };
module.exports.exception = function(actual) { var Asserter = require('./asserters/exception'); return new Asserter(actual); };
module.exports.function = function(actual) { var Asserter = require('./asserters/function'); return new Asserter(actual); };
module.exports.number = function(actual) { var Asserter = require('./asserters/number'); return new Asserter(actual); };
module.exports.object = function(actual) { var Asserter = require('./asserters/object'); return new Asserter(actual); };
module.exports.regexp = function(actual) { var Asserter = require('./asserters/regexp'); return new Asserter(actual); };
module.exports.string = function(actual) { var Asserter = require('./asserters/string'); return new Asserter(actual); };
module.exports.undefined = function(actual) { var Asserter = require('./asserters/undefined'); return new Asserter(actual); };
module.exports.value = function(actual) { var Asserter = require('./asserters/value'); return new Asserter(actual); };
80 changes: 80 additions & 0 deletions browser/tmp/src/asserters/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

var _ = require('lodash');

// constructor
var RawControlFlow = require('../control-flow');

// object
var rawAssertions = require('../assertions');

// array
var commonAssertions = require('../common-assertions');

// list the assertions to the current asserter (specific and common)
var useAssertions = commonAssertions.concat([

// matchers
'matchEach', 'notMatchEach',

// types augmented
'isEmpty', 'isNotEmpty',

// quantifications
'hasLength', 'hasNotLength',

// containers
'hasValue', 'notHasValue', 'hasValues', 'notHasValues',
'contains', 'notContains', 'isReverseOf', 'isNotReverseOf',
'isEnumerable', 'isNotEnumerable', 'hasKey', 'notHasKey',
'hasProperty', 'hasNotProperty'
]);

/**
* Expose all assertions
* @type {function}
* @param {mixed} actual Actual value tested
* @return {Object} The current asserter
*/
module.exports = function ArrayAsserter(actual) {

// actual value tested
this.actual = actual;

// assertions with the current context
var assertions = rawAssertions.call(this, actual);

// Build the common API with the current context
var ControlFlow = RawControlFlow.bind(this);
var commonApi = new ControlFlow();

// provides the common API in the current asserter
for (var method in commonApi) {
this[method] = commonApi[method];
}

// assert the type
assertions.isArray(this.actual);

// provides the assertions to the current asserter (specific and common)
var asserterAssertions = _.pick(assertions, useAssertions);

for (var method in asserterAssertions) {
this[method] = asserterAssertions[method];
}

// return this asserter
return this;
};
59 changes: 59 additions & 0 deletions browser/tmp/src/asserters/bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

var _ = require('lodash');

// constructor
var RawControlFlow = require('../control-flow');

// object
var rawAssertions = require('../assertions');

/**
* Expose all assertions
* @type {function}
* @param {mixed} actual Actual value tested
* @return {Object} The current asserter
*/
module.exports = function BoolAsserter(actual) {

// actual value tested
this.actual = actual;

// assertions with the current context
var assertions = rawAssertions.call(this, actual);

// Build the common API with the current context
var ControlFlow = RawControlFlow.bind(this);
var commonApi = new ControlFlow();

// provides the common API in the current asserter
for (var method in commonApi) {
this[method] = commonApi[method];
}

// assert the type
assertions.isBool(this.actual);

// provides the assertions to the current asserter
var useAssertions = ['isTrue', 'isNotTrue', 'isFalse', 'isNotFalse'];
var asserterAssertions = _.pick(assertions, useAssertions);

for (var method in asserterAssertions) {
this[method] = asserterAssertions[method];
}

// return this asserter
return this;
};
67 changes: 67 additions & 0 deletions browser/tmp/src/asserters/date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* This file is part of the Unit.js testing framework.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view
* the LICENSE file distributed with this source code
* or visit http://unitjs.com.
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/

'use strict';

var _ = require('lodash');

// constructor
var RawControlFlow = require('../control-flow');

// object
var rawAssertions = require('../assertions');

// array
var commonAssertions = require('../common-assertions');

var useAssertions = commonAssertions.concat([

// quantifications
'isBetween', 'isNotBetween', 'isBefore', 'isAfter'
]);

/**
* Expose all assertions
* @type {function}
* @param {mixed} actual Actual value tested
* @return {Object} The current asserter
*/
module.exports = function DateAsserter(actual) {

// actual value tested
this.actual = actual;

// assertions with the current context
var assertions = rawAssertions.call(this, actual);

// Build the common API with the current context
var ControlFlow = RawControlFlow.bind(this);
var commonApi = new ControlFlow();

// provides the common API in the current asserter
for (var method in commonApi) {
this[method] = commonApi[method];
}

// assert the type
assertions.isDate();

// provides the assertions to the current asserter (specific and common)
var asserterAssertions = _.pick(assertions, useAssertions);

for (var method in asserterAssertions) {
this[method] = asserterAssertions[method];
}

// return this asserter
return this;
};
Loading

0 comments on commit a67f83e

Please sign in to comment.