Permalink
Browse files

Rebuild @ 1.6.0

  • Loading branch information...
1 parent c5070ed commit 3de6c2659cbede3c9d636bf67e6e77ab7dd50434 @ryanve committed Nov 3, 2013
Showing with 35 additions and 43 deletions.
  1. +1 −1 README.md
  2. +31 −39 aok.js
  3. +2 −2 aok.min.js
  4. +1 −1 package.json
View
@@ -2,7 +2,7 @@
#### Extensible JavaScript test suite [module](https://npmjs.org/package/aok)
-## API ([1.5](../../releases))
+## API ([1.6](../../releases))
### `aok(testObject)`
View
70 aok.js
@@ -1,5 +1,5 @@
/*!
- * aok 1.5.3+201311020500
+ * aok 1.6.0+201311030705
* https://github.com/ryanve/aok
* MIT License 2013 Ryan Van Etten
*/
@@ -23,6 +23,12 @@
}
, assign = function(to, from) {
for (var k in from) has(from, k) && (to[k] = from[k]);
+ return to;
+ }
+ , clone = function(fn) {
+ return assign(function() {
+ fn.apply(this, arguments);
+ }, fn);
};
/**
@@ -50,38 +56,35 @@
implement = aok.prototype = Aok.prototype;
// Console abstractions
- (function(target, console, hasAlert, win) {
- /**
- * @param {string} name
- * @param {(boolean|number)=} force
- * @param {string=} key
- */
- function assign(name, force, key) {
+ assign(aok, aok['console'] = (function(abstracted, console, hasAlert, win) {
+ function abstracts(name, force, fallback) {
var method = console && typeof console[name] == 'function' ? function() {
console[name].apply(console, arguments);
- } : hasAlert ? function() {
+ } : fallback ? fallback : hasAlert ? function() {
method['force'] && win.alert(name + ': ' + [].join.call(arguments, ' '));
} : function() {};
method['force'] = !!force;
- target[key || name] = method;
+ abstracted[name] = method;
}
-
- assign('info', 1);
- assign('warn', 1);
- assign('error', 1);
- assign('trace');
- assign('log');
- assign('log', 0, 'express');
- }(aok, nativeConsole, hasAlert, win));
+
+ abstracts('log');
+ abstracts('trace');
+ abstracts('info', 1);
+ abstracts('warn', 1);
+ abstracts('error', 1);
+ abstracts('assert', 1, function(exp, msg) {
+ exp || abstracted['warn'](msg);
+ });
+ return abstracted;
+ }({}, nativeConsole, hasAlert, win)));
+
+ // Alias the "express" method to the prototype for usage with tests.
+ implement['express'] = aok['express'] = clone(aok['log']);
// Default messages
implement['pass'] = 'Pass';
implement['fail'] = 'Fail';
- // Alias the "express" method to the prototype for usage from
- // the default handler. Override as needed for customization.
- implement['express'] = aok['express'];
-
/**
* @param {*=} item
* @return {string}
@@ -94,18 +97,14 @@
/**
* @param {*} o
* @param {(string|number|Function)=} k
- * @example result(0) // 0
+ * @param {Object=} guard array methods
* @example result([1], 0) // 1
*/
- function result(o, k) {
- if (2 != arguments.length) k = o, o = this;
- else typeof k == 'function' ? k : k = o[k];
+ function result(o, k, guard) {
+ guard || k === guard ? (k = o, o = this) : (typeof k == 'function' ? k : k = o[k]);
return typeof k == 'function' ? k.call(o) : k;
}
aok['result'] = result;
- implement['result'] = function(k) {
- return result.apply(aok, 2 == arguments.length ? arguments : [this, k]);
- };
/**
* Get a new function that uses try/catch to test if `fn` can run.
@@ -139,9 +138,7 @@
*/
implement['run'] = function() {
if (this === globe) throw new Error('@this');
- var use = this['result'], at = 'test';
- use = typeof use == 'function' ? use.call(this, at) : result(this, at);
- this[at] = !!use;
+ this['test'] = !!result(this, 'test');
return this['handler']();
};
@@ -159,13 +156,8 @@
*/
implement['handler'] = function() {
var msg = this['cull']();
- if (typeof msg == 'function') {
- msg.call(this);
- } else {
- msg = this['explain'](msg);
- has(this, 'remark') && (msg += ' (' + this['explain'](this['remark']) + ')');
- this['express']('#' + this['id'] + ': ' + msg);
- }
+ if (typeof msg == 'function') msg.call(this);
+ else this['express']('#' + this['id'] + ': ' + this['explain'](msg));
return this;
};
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,7 +1,7 @@
{
"name": "aok",
"description": "Extensible test suite API.",
- "version": "1.5.3",
+ "version": "1.6.0",
"homepage": "https://github.com/ryanve/aok",
"author": "Ryan Van Etten",
"keywords": ["testing", "test suite", "javascript", "ender", "browser", "server"],

0 comments on commit 3de6c26

Please sign in to comment.