Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hydro

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydro - npm Package Compare versions

Comparing version 0.8.10 to 0.8.11

lib/hydro/interface.js

3

component.json

@@ -5,3 +5,3 @@ {

"description": "",
"version": "0.8.10",
"version": "0.8.11",
"license": "MIT",

@@ -28,4 +28,5 @@ "main": "lib/hydro.js",

"lib/hydro/suite/root.js",
"lib/hydro/interface.js",
"lib/hydro/util.js"
]
}

@@ -598,2 +598,3 @@ ;(function(){

var RootSuite = require('./hydro/suite/root');
var Interface = require('./hydro/interface');
var Suite = require('./hydro/suite');

@@ -614,2 +615,3 @@ var Test = require('./hydro/test');

this.emitter = new EventEmitter;
this.interface = new Interface(this);
this.plugins = [];

@@ -674,65 +676,2 @@ this.stack = [new RootSuite];

/**
* Add a new test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.addTest = function() {
var test = this.createTest.apply(this, arguments);
this.stack[0].addTest(test);
return test;
};
/**
* Create a test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.createTest = function() {
var test = Test.create(util.slice(arguments));
var timeout = this.get('timeout');
if (timeout) test.timeout(timeout);
return test;
};
/**
* Add a test suite.
*
* @param {String} title
* @param {Function} body
* @api public
*/
Hydro.prototype.addSuite = function(title, fn) {
var suite = this.createSuite(title);
this.stack[0].addSuite(suite);
if (fn) {
this.stack.unshift(suite);
fn();
this.stack.shift();
}
return suite;
};
/**
* Create a test suite.
*
* @param {String} title
* @api public
*/
Hydro.prototype.createSuite = function(title) {
return new Suite(title);
};
/**
* Register event handler.

@@ -889,2 +828,67 @@ *

/**
* Add a new test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.addTest = function() {
var test = this.createTest.apply(this, arguments);
this.stack[0].addTest(test);
return test;
};
/**
* Create a test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.createTest = function() {
var test = Test.create(util.slice(arguments));
var timeout = this.get('timeout');
if (timeout) test.timeout(timeout);
return test;
};
/**
* Add a test suite.
*
* @param {String} title
* @param {Function} body
* @api public
*/
Hydro.prototype.addSuite = function(title, fn) {
var suite = this.createSuite(title);
this.stack[0].addSuite(suite);
if (fn) {
this.stack.unshift(suite);
fn();
this.stack.shift();
}
return suite;
};
/**
* Create a test suite.
*
* @param {String} title
* @api public
*/
Hydro.prototype.createSuite = function(title) {
return new Suite(title);
};
/**
* Attach global methods and properties.

@@ -915,3 +919,3 @@ *

target[key] = function() {
return self[val].apply(self, arguments);
return self.interface[val].apply(self.interface, arguments);
};

@@ -954,2 +958,4 @@ });

module.exports.util = util;
module.exports.Test = Test;
module.exports.Suite = Suite;

@@ -1432,2 +1438,37 @@ });

});
require.register("hydro/lib/hydro/interface.js", function(exports, require, module){
/**
* Internal dependencies.
*/
var util = require('./util');
/**
* Public interface for proxy methods.
*
* @param {Hydro} hydro
* @constructor
*/
function Interface(hydro) {
this.hydro = hydro;
}
/**
* Delegate to Hydro.
*/
util.forEach(['addTest', 'addSuite', 'createTest', 'createSuite'], function(method) {
Interface.prototype[method] = function() {
return this.hydro[method].apply(this.hydro, arguments);
};
});
/**
* Primary export.
*/
module.exports = Interface;
});
require.register("hydro/lib/hydro/util.js", function(exports, require, module){

@@ -1434,0 +1475,0 @@ /**

@@ -1,1 +0,1 @@

(function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path;parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');err.path=orig;err.parent=parent;err.require=true;throw err}var module=require.modules[resolved];if(!module._resolving&&!module.exports){var mod={};mod.exports={};mod.client=mod.component=true;module._resolving=true;module.call(this,mod.exports,require.relative(resolved),mod);delete module._resolving;module.exports=mod.exports}return module.exports}require.modules={};require.aliases={};require.resolve=function(path){if(path.charAt(0)==="/")path=path.slice(1);var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"];for(var i=0;i<paths.length;i++){var path=paths[i];if(require.modules.hasOwnProperty(path))return path;if(require.aliases.hasOwnProperty(path))return require.aliases[path]}};require.normalize=function(curr,path){var segs=[];if("."!=path.charAt(0))return path;curr=curr.split("/");path=path.split("/");for(var i=0;i<path.length;++i){if(".."==path[i]){curr.pop()}else if("."!=path[i]&&""!=path[i]){segs.push(path[i])}}return curr.concat(segs).join("/")};require.register=function(path,definition){require.modules[path]=definition};require.alias=function(from,to){if(!require.modules.hasOwnProperty(from)){throw new Error('Failed to alias "'+from+'", it does not exist')}require.aliases[to]=from};require.relative=function(parent){var p=require.normalize(parent,"..");function lastIndexOf(arr,obj){var i=arr.length;while(i--){if(arr[i]===obj)return i}return-1}function localRequire(path){var resolved=localRequire.resolve(path);return require(resolved,parent,path)}localRequire.resolve=function(path){var c=path.charAt(0);if("/"==c)return path.slice(1);if("."==c)return require.normalize(p,path);var segs=parent.split("/");var i=lastIndexOf(segs,"deps")+1;if(!i)i=0;path=segs.slice(0,i+1).join("/")+"/deps/"+path;return path};localRequire.exists=function(path){return require.modules.hasOwnProperty(localRequire.resolve(path))};return localRequire};require.register("hydrojs-loa/index.js",function(exports,require,module){var root=typeof global!=="undefined"?global:window;var toString=Object.prototype.toString;function is(type,input){if(type==="Object")return Object(input)===input;return toString.call(input)==="[object "+type+"]"}function str(input){if(!is("String",input))return;return root[input]||(root.require||require)(input)}function handeled(input){if(is("Object",input)||is("Function",input))return input}function raise(input){throw new TypeError("loa: Can't handle: "+input)}function loa(input){return handeled(input)||str(input)||raise(input)}module.exports=loa});require.register("vesln-evts/lib/evts.js",function(exports,require,module){var slice=Array.prototype.slice;function EventEmitter(){this.events={}}EventEmitter.prototype.on=function(evt,fn){this.events[evt]=this.events[evt]||[];this.events[evt].push(fn)};EventEmitter.prototype.emit=function(evt,fn){var listeners=this.events[evt];var i=0;var args=slice.call(arguments,1);var done=args.pop();if(!listeners)return done();(function next(){var handler=listeners[i];if(!handler)return done();i++;if(handler.length>args.length)return handler.apply(null,args.concat(next));handler.apply(null,args);next()})()};module.exports=EventEmitter});require.register("vesln-tryc/lib/browser.js",function(exports,require,module){module.exports=function(fn,end){var prev=window.onerror;function handler(err){window.onerror=prev;end(err)}window.onerror=function(msg,url,line){handler(new Error(msg+" at "+url+":"+line))};try{fn(handler)}catch(err){handler(err)}}});require.register("vesln-fload/lib/browser.js",function(exports,require,module){function load(files,callbacks){var target=document.getElementsByTagName("script")[0];files=files.slice(0);(function next(){var file=files.shift();if(!file)return callbacks.done();callbacks.pre(file,function(){var script=document.createElement("script");script.src=file;script.onload=script.onreadystatechange=function(e){if(e&&e.type==="load"||/loaded|complete/.test(script.readyState)){script.onload=null;script.onreadystatechange=null;callbacks.post(file,null,next)}};target.parentNode.insertBefore(script,target)})})()}module.exports=load});require.register("vesln-globalo/index.js",function(exports,require,module){module.exports=function(){if(typeof global!=="undefined"){return global}else if(typeof window!=="undefined"){return window}else if(typeof Alloy!=="undefined"&&typeof Alloy.Globals!=="undefined"){return Alloy.Globals}else if(typeof Ti!=="undefined"&&typeof Ti.App!=="undefined"){return Ti.App}}});require.register("vesln-super/lib/super.js",function(exports,require,module){var slice=Array.prototype.slice;var exports=module.exports=super_;function super_(){var args=slice.call(arguments);if(!args.length)return;if(typeof args[0]!=="function")return exports.merge(args);exports.inherits.apply(null,args)}exports.extend=function(proto,klass){var self=this,child=function(){return self.apply(this,arguments)};exports.merge([child,this]);exports.inherits(child,this);if(proto)exports.merge([child.prototype,proto]);if(klass)exports.merge([child,klass]);child.extend=this.extend;return child};exports.inherits=function(ctor,superCtor){ctor.super_=superCtor;if(Object.create){ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}else{ctor.prototype=new superCtor;ctor.prototype.constructor=ctor}};exports.merge=function(arr){var main=arr.length===2?arr.shift():{};var obj=null;for(var i=0,len=arr.length;i<len;i++){obj=arr[i];for(var p in obj){if(!obj.hasOwnProperty(p))continue;main[p]=obj[p]}}return main}});require.register("hydro/lib/hydro.js",function(exports,require,module){var EventEmitter=require("evts");var globalo=require("globalo");var loader=require("fload");var merge=require("super").merge;var loa=require("loa");var RootSuite=require("./hydro/suite/root");var Suite=require("./hydro/suite");var Test=require("./hydro/test");var util=require("./hydro/util");function Hydro(){if(!(this instanceof Hydro))return new Hydro;this.loader=loader;this.emitter=new EventEmitter;this.plugins=[];this.stack=[new RootSuite];this.root=this.stack[0];this.options={plugins:[],aliases:{},globals:{},tests:[]}}Hydro.prototype.set=function(key,val){if(Object(key)===key){this.options=merge([this.options,key])}else if(arguments.length===3){if(typeof this.options[key]==="undefined"){this.options[key]={}}this.options[key][val]=arguments[2]}else{this.options[key]=val}};Hydro.prototype.push=function(key,val){if(typeof this.options[key]==="undefined"){this.options[key]=[]}this.options[key].push(val)};Hydro.prototype.get=function(key){return this.options[key]};Hydro.prototype.addTest=function(){var test=this.createTest.apply(this,arguments);this.stack[0].addTest(test);return test};Hydro.prototype.createTest=function(){var test=Test.create(util.slice(arguments));var timeout=this.get("timeout");if(timeout)test.timeout(timeout);return test};Hydro.prototype.addSuite=function(title,fn){var suite=this.createSuite(title);this.stack[0].addSuite(suite);if(fn){this.stack.unshift(suite);fn();this.stack.shift()}return suite};Hydro.prototype.createSuite=function(title){return new Suite(title)};Hydro.prototype.on=function(evt,fn){this.emitter.on(evt,fn)};Hydro.prototype.suites=function(){var suites=[];this.traverse({enterSuite:function(suite){suites.push(suite)}});return suites};Hydro.prototype.tests=function(){var tests=[];this.traverse({test:function(test){tests.push(test)}});return tests};Hydro.prototype.traverse=function(handlers){handlers.test=handlers.test||util.noop;handlers.enterSuite=handlers.enterSuite||util.noop;handlers.leaveSuite=handlers.leaveSuite||util.noop;(function next(suite){handlers.enterSuite(suite);util.forEach(suite.suites,next);util.forEach(suite.tests,handlers.test);handlers.leaveSuite(suite)})(this.root)};Hydro.prototype.setup=function(){var emitter=this.emitter;var suite=null;var stackLimit=null;var self=this;this.loadPlugins();this.attachGlobals();this.attachProxies();this.loadFormatter();if(suite=this.get("suite")){suite=this.createSuite(suite);this.root.addSuite(suite);this.stack.unshift(suite)}if(stackLimit=this.get("stackLimit")){Error.stackTraceLimit=stackLimit}this._init=true};Hydro.prototype.exec=function(fn){var emitter=this.emitter;var self=this;var suite=this.get("suite");fn=fn||function(){};this.loader(this.get("tests"),{pre:function(file,done){emitter.emit("pre:file",file,done)},post:function(file,contents,done){emitter.emit("post:file",file,done)},done:function(){if(suite)self.stack.shift();self.root.run(emitter,fn)}})};Hydro.prototype.run=function(fn){if(!this._init)this.setup();this.exec(fn)};Hydro.prototype.loadPlugins=function(){util.forEach(this.get("plugins"),function(plugin){plugin=loa(plugin);plugin(this,util);this.plugins.push(plugin)},this)};Hydro.prototype.attachGlobals=function(){var target=this.global();util.eachKey(this.get("globals"),function(key,val){target[key]=val})};Hydro.prototype.attachProxies=function(){var proxies=this.get("proxies");var target=this.global();var self=this;util.eachKey(proxies,function(key,val){target[key]=function(){return self[val].apply(self,arguments)}})};Hydro.prototype.global=function(){return this.get("attach")||globalo()};Hydro.prototype.loadFormatter=function(){var name=this.get("formatter");var formatter=null;if(!name)return;formatter=loa(name);if(util.isFunction(formatter))formatter=new formatter;formatter.use(this)};module.exports=Hydro;module.exports.util=util});require.register("hydro/lib/hydro/test/async.js",function(exports,require,module){var tryc=require("tryc");var sTimeout=setTimeout;var BaseTest=require("./base");var AsyncTest=BaseTest.extend();AsyncTest.prototype._timeout=1e3*2;AsyncTest.prototype.async=true;AsyncTest.prototype.exec=function(done){var timeout=null;var ended=false;var fn=this.fn;var context=this.context;function end(err){if(ended)return;ended=true;clearTimeout(timeout);done(err)}timeout=sTimeout(function(){end(new Error("Test timed out"))},this._timeout);tryc(function(done){fn.call(context,done)},end)};module.exports=AsyncTest});require.register("hydro/lib/hydro/test/base.js",function(exports,require,module){var extend=require("super").extend;var util=require("../util");var D=Date;function Base(title,fn,meta){this.title=title;this.fn=fn;this.meta=util.toArray(meta||[]);this.status=null;this.error=null;this.time=null;this.context={};this.events={pre:"pre:test",post:"post:test"};if(!this.fn)this.pending()}Base.extend=extend;Base.prototype.timeout=function(ms){this._timeout=ms;return this};Base.prototype.skip=function(condition){if(arguments.length&&!condition)return;this.status="skipped";this.time=0};Base.prototype.pending=function(){this.status="pending";this.time=0;return this};Base.prototype.run=function(emitter,done){var self=this;var events=this.events;var disabled=this.status==="pending"||this.status==="skipped";emitter.emit(events.pre,this,function(){var disabled=self.status==="pending"||self.status==="skipped";if(disabled)return emitter.emit(events.post,self,done);var start=(new D).getTime();self.exec(function(err){self.time=(new D).getTime()-start;if(err)self.fail(err);else self.pass();emitter.emit(events.post,self,done)})})};Base.prototype.parents=function(){return this.suite.parents().concat(this.suite)};Base.prototype.fail=function(err){this.status="failed";this.error=err;return this};Base.prototype.pass=function(){this.status="passed";return this};module.exports=Base});require.register("hydro/lib/hydro/test/index.js",function(exports,require,module){var SyncTest=require("./sync");var AsyncTest=require("./async");exports.create=function(params){var title=params.shift();var fn=null;var klass=null;if(typeof params[params.length-1]==="function")fn=params.pop();klass=fn&&fn.length?AsyncTest:SyncTest;return new klass(title,fn,params)};exports.SyncTest=SyncTest;exports.AsyncTest=AsyncTest});require.register("hydro/lib/hydro/test/sync.js",function(exports,require,module){var BaseTest=require("./base");var SyncTest=BaseTest.extend();SyncTest.prototype.sync=true;SyncTest.prototype.exec=function(done){var err=null;try{this.fn.call(this.context)}catch(e){err=e}done(err)};module.exports=SyncTest});require.register("hydro/lib/hydro/suite/index.js",function(exports,require,module){var util=require("../util");function Suite(title){this.title=util.isFunction(title)?util.fnName(title):title;this.parent=null;this.tests=[];this.suites=[];this.events={pre:"pre:suite",post:"post:suite"}}Suite.prototype.addTest=function(test){test.suite=this;this.tests.push(test)};Suite.prototype.addSuite=function(suite){suite.parent=this;this.suites.push(suite)};Suite.prototype.run=function(emitter,fn){var self=this;var runnable=this.tests.slice(0).concat(this.suites.slice(0));var current=null;var events=this.events;function next(){if(current=runnable.shift()){return current.run(emitter,next)}emitter.emit(events.post,self,function(){fn(self)})}emitter.emit(events.pre,this,next)};Suite.prototype.parents=function(){return this.parent.parents().concat(this.parent)};module.exports=Suite});require.register("hydro/lib/hydro/suite/root.js",function(exports,require,module){var inherits=require("super");var Suite=require("./index");function RootSuite(){Suite.call(this);this.events={pre:"pre:all",post:"post:all"}}inherits(RootSuite,Suite);RootSuite.prototype.addTest=function(){throw new Error("Please add a test suite")};RootSuite.prototype.parents=function(){return[]};module.exports=RootSuite});require.register("hydro/lib/hydro/util.js",function(exports,require,module){var toString=Object.prototype.toString;var slice=Array.prototype.slice;exports.isString=function(str){return toString.call(str)==="[object String]"};exports.isFunction=function(fn){return toString.call(fn)==="[object Function]"};exports.isArray=function(arr){return toString.call(arr)==="[object Array]"};exports.slice=function(args){return slice.call(args)};exports.toArray=function(arr){if(exports.isArray(arr))return arr;return[arr]};exports.forEach=function(arr,fn,ctx){for(var i=0,len=arr.length;i<len;i++){fn.call(ctx,arr[i])}};exports.eachKey=function(obj,fn){for(var key in obj){if(!obj.hasOwnProperty(key))continue;fn(key,obj[key])}};exports.fnName=function(fn){if(fn.name)return fn.name;var match=/^\s?function ([^(]*)\(/.exec(fn);return match&&match[1]?match[1]:""};exports.noop=function(){}});require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","loa/index.js");require.alias("hydrojs-loa/index.js","hydrojs-loa/index.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/lib/evts.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/index.js");require.alias("vesln-evts/lib/evts.js","evts/index.js");require.alias("vesln-evts/lib/evts.js","vesln-evts/index.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/lib/browser.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/index.js");require.alias("vesln-tryc/lib/browser.js","tryc/index.js");require.alias("vesln-tryc/lib/browser.js","vesln-tryc/index.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/lib/browser.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/index.js");require.alias("vesln-fload/lib/browser.js","fload/index.js");require.alias("vesln-fload/lib/browser.js","vesln-fload/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","globalo/index.js");require.alias("vesln-globalo/index.js","vesln-globalo/index.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/lib/super.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/index.js");require.alias("vesln-super/lib/super.js","super/index.js");require.alias("vesln-super/lib/super.js","vesln-super/index.js");require.alias("hydro/lib/hydro.js","hydro/index.js");if(typeof exports=="object"){module.exports=require("hydro")}else if(typeof define=="function"&&define.amd){define(function(){return require("hydro")})}else{this["Hydro"]=require("hydro")}})();
(function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path;parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');err.path=orig;err.parent=parent;err.require=true;throw err}var module=require.modules[resolved];if(!module._resolving&&!module.exports){var mod={};mod.exports={};mod.client=mod.component=true;module._resolving=true;module.call(this,mod.exports,require.relative(resolved),mod);delete module._resolving;module.exports=mod.exports}return module.exports}require.modules={};require.aliases={};require.resolve=function(path){if(path.charAt(0)==="/")path=path.slice(1);var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"];for(var i=0;i<paths.length;i++){var path=paths[i];if(require.modules.hasOwnProperty(path))return path;if(require.aliases.hasOwnProperty(path))return require.aliases[path]}};require.normalize=function(curr,path){var segs=[];if("."!=path.charAt(0))return path;curr=curr.split("/");path=path.split("/");for(var i=0;i<path.length;++i){if(".."==path[i]){curr.pop()}else if("."!=path[i]&&""!=path[i]){segs.push(path[i])}}return curr.concat(segs).join("/")};require.register=function(path,definition){require.modules[path]=definition};require.alias=function(from,to){if(!require.modules.hasOwnProperty(from)){throw new Error('Failed to alias "'+from+'", it does not exist')}require.aliases[to]=from};require.relative=function(parent){var p=require.normalize(parent,"..");function lastIndexOf(arr,obj){var i=arr.length;while(i--){if(arr[i]===obj)return i}return-1}function localRequire(path){var resolved=localRequire.resolve(path);return require(resolved,parent,path)}localRequire.resolve=function(path){var c=path.charAt(0);if("/"==c)return path.slice(1);if("."==c)return require.normalize(p,path);var segs=parent.split("/");var i=lastIndexOf(segs,"deps")+1;if(!i)i=0;path=segs.slice(0,i+1).join("/")+"/deps/"+path;return path};localRequire.exists=function(path){return require.modules.hasOwnProperty(localRequire.resolve(path))};return localRequire};require.register("hydrojs-loa/index.js",function(exports,require,module){var root=typeof global!=="undefined"?global:window;var toString=Object.prototype.toString;function is(type,input){if(type==="Object")return Object(input)===input;return toString.call(input)==="[object "+type+"]"}function str(input){if(!is("String",input))return;return root[input]||(root.require||require)(input)}function handeled(input){if(is("Object",input)||is("Function",input))return input}function raise(input){throw new TypeError("loa: Can't handle: "+input)}function loa(input){return handeled(input)||str(input)||raise(input)}module.exports=loa});require.register("vesln-evts/lib/evts.js",function(exports,require,module){var slice=Array.prototype.slice;function EventEmitter(){this.events={}}EventEmitter.prototype.on=function(evt,fn){this.events[evt]=this.events[evt]||[];this.events[evt].push(fn)};EventEmitter.prototype.emit=function(evt,fn){var listeners=this.events[evt];var i=0;var args=slice.call(arguments,1);var done=args.pop();if(!listeners)return done();(function next(){var handler=listeners[i];if(!handler)return done();i++;if(handler.length>args.length)return handler.apply(null,args.concat(next));handler.apply(null,args);next()})()};module.exports=EventEmitter});require.register("vesln-tryc/lib/browser.js",function(exports,require,module){module.exports=function(fn,end){var prev=window.onerror;function handler(err){window.onerror=prev;end(err)}window.onerror=function(msg,url,line){handler(new Error(msg+" at "+url+":"+line))};try{fn(handler)}catch(err){handler(err)}}});require.register("vesln-fload/lib/browser.js",function(exports,require,module){function load(files,callbacks){var target=document.getElementsByTagName("script")[0];files=files.slice(0);(function next(){var file=files.shift();if(!file)return callbacks.done();callbacks.pre(file,function(){var script=document.createElement("script");script.src=file;script.onload=script.onreadystatechange=function(e){if(e&&e.type==="load"||/loaded|complete/.test(script.readyState)){script.onload=null;script.onreadystatechange=null;callbacks.post(file,null,next)}};target.parentNode.insertBefore(script,target)})})()}module.exports=load});require.register("vesln-globalo/index.js",function(exports,require,module){module.exports=function(){if(typeof global!=="undefined"){return global}else if(typeof window!=="undefined"){return window}else if(typeof Alloy!=="undefined"&&typeof Alloy.Globals!=="undefined"){return Alloy.Globals}else if(typeof Ti!=="undefined"&&typeof Ti.App!=="undefined"){return Ti.App}}});require.register("vesln-super/lib/super.js",function(exports,require,module){var slice=Array.prototype.slice;var exports=module.exports=super_;function super_(){var args=slice.call(arguments);if(!args.length)return;if(typeof args[0]!=="function")return exports.merge(args);exports.inherits.apply(null,args)}exports.extend=function(proto,klass){var self=this,child=function(){return self.apply(this,arguments)};exports.merge([child,this]);exports.inherits(child,this);if(proto)exports.merge([child.prototype,proto]);if(klass)exports.merge([child,klass]);child.extend=this.extend;return child};exports.inherits=function(ctor,superCtor){ctor.super_=superCtor;if(Object.create){ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}else{ctor.prototype=new superCtor;ctor.prototype.constructor=ctor}};exports.merge=function(arr){var main=arr.length===2?arr.shift():{};var obj=null;for(var i=0,len=arr.length;i<len;i++){obj=arr[i];for(var p in obj){if(!obj.hasOwnProperty(p))continue;main[p]=obj[p]}}return main}});require.register("hydro/lib/hydro.js",function(exports,require,module){var EventEmitter=require("evts");var globalo=require("globalo");var loader=require("fload");var merge=require("super").merge;var loa=require("loa");var RootSuite=require("./hydro/suite/root");var Interface=require("./hydro/interface");var Suite=require("./hydro/suite");var Test=require("./hydro/test");var util=require("./hydro/util");function Hydro(){if(!(this instanceof Hydro))return new Hydro;this.loader=loader;this.emitter=new EventEmitter;this.interface=new Interface(this);this.plugins=[];this.stack=[new RootSuite];this.root=this.stack[0];this.options={plugins:[],aliases:{},globals:{},tests:[]}}Hydro.prototype.set=function(key,val){if(Object(key)===key){this.options=merge([this.options,key])}else if(arguments.length===3){if(typeof this.options[key]==="undefined"){this.options[key]={}}this.options[key][val]=arguments[2]}else{this.options[key]=val}};Hydro.prototype.push=function(key,val){if(typeof this.options[key]==="undefined"){this.options[key]=[]}this.options[key].push(val)};Hydro.prototype.get=function(key){return this.options[key]};Hydro.prototype.on=function(evt,fn){this.emitter.on(evt,fn)};Hydro.prototype.suites=function(){var suites=[];this.traverse({enterSuite:function(suite){suites.push(suite)}});return suites};Hydro.prototype.tests=function(){var tests=[];this.traverse({test:function(test){tests.push(test)}});return tests};Hydro.prototype.traverse=function(handlers){handlers.test=handlers.test||util.noop;handlers.enterSuite=handlers.enterSuite||util.noop;handlers.leaveSuite=handlers.leaveSuite||util.noop;(function next(suite){handlers.enterSuite(suite);util.forEach(suite.suites,next);util.forEach(suite.tests,handlers.test);handlers.leaveSuite(suite)})(this.root)};Hydro.prototype.setup=function(){var emitter=this.emitter;var suite=null;var stackLimit=null;var self=this;this.loadPlugins();this.attachGlobals();this.attachProxies();this.loadFormatter();if(suite=this.get("suite")){suite=this.createSuite(suite);this.root.addSuite(suite);this.stack.unshift(suite)}if(stackLimit=this.get("stackLimit")){Error.stackTraceLimit=stackLimit}this._init=true};Hydro.prototype.exec=function(fn){var emitter=this.emitter;var self=this;var suite=this.get("suite");fn=fn||function(){};this.loader(this.get("tests"),{pre:function(file,done){emitter.emit("pre:file",file,done)},post:function(file,contents,done){emitter.emit("post:file",file,done)},done:function(){if(suite)self.stack.shift();self.root.run(emitter,fn)}})};Hydro.prototype.run=function(fn){if(!this._init)this.setup();this.exec(fn)};Hydro.prototype.loadPlugins=function(){util.forEach(this.get("plugins"),function(plugin){plugin=loa(plugin);plugin(this,util);this.plugins.push(plugin)},this)};Hydro.prototype.addTest=function(){var test=this.createTest.apply(this,arguments);this.stack[0].addTest(test);return test};Hydro.prototype.createTest=function(){var test=Test.create(util.slice(arguments));var timeout=this.get("timeout");if(timeout)test.timeout(timeout);return test};Hydro.prototype.addSuite=function(title,fn){var suite=this.createSuite(title);this.stack[0].addSuite(suite);if(fn){this.stack.unshift(suite);fn();this.stack.shift()}return suite};Hydro.prototype.createSuite=function(title){return new Suite(title)};Hydro.prototype.attachGlobals=function(){var target=this.global();util.eachKey(this.get("globals"),function(key,val){target[key]=val})};Hydro.prototype.attachProxies=function(){var proxies=this.get("proxies");var target=this.global();var self=this;util.eachKey(proxies,function(key,val){target[key]=function(){return self.interface[val].apply(self.interface,arguments)}})};Hydro.prototype.global=function(){return this.get("attach")||globalo()};Hydro.prototype.loadFormatter=function(){var name=this.get("formatter");var formatter=null;if(!name)return;formatter=loa(name);if(util.isFunction(formatter))formatter=new formatter;formatter.use(this)};module.exports=Hydro;module.exports.util=util;module.exports.Test=Test;module.exports.Suite=Suite});require.register("hydro/lib/hydro/test/async.js",function(exports,require,module){var tryc=require("tryc");var sTimeout=setTimeout;var BaseTest=require("./base");var AsyncTest=BaseTest.extend();AsyncTest.prototype._timeout=1e3*2;AsyncTest.prototype.async=true;AsyncTest.prototype.exec=function(done){var timeout=null;var ended=false;var fn=this.fn;var context=this.context;function end(err){if(ended)return;ended=true;clearTimeout(timeout);done(err)}timeout=sTimeout(function(){end(new Error("Test timed out"))},this._timeout);tryc(function(done){fn.call(context,done)},end)};module.exports=AsyncTest});require.register("hydro/lib/hydro/test/base.js",function(exports,require,module){var extend=require("super").extend;var util=require("../util");var D=Date;function Base(title,fn,meta){this.title=title;this.fn=fn;this.meta=util.toArray(meta||[]);this.status=null;this.error=null;this.time=null;this.context={};this.events={pre:"pre:test",post:"post:test"};if(!this.fn)this.pending()}Base.extend=extend;Base.prototype.timeout=function(ms){this._timeout=ms;return this};Base.prototype.skip=function(condition){if(arguments.length&&!condition)return;this.status="skipped";this.time=0};Base.prototype.pending=function(){this.status="pending";this.time=0;return this};Base.prototype.run=function(emitter,done){var self=this;var events=this.events;var disabled=this.status==="pending"||this.status==="skipped";emitter.emit(events.pre,this,function(){var disabled=self.status==="pending"||self.status==="skipped";if(disabled)return emitter.emit(events.post,self,done);var start=(new D).getTime();self.exec(function(err){self.time=(new D).getTime()-start;if(err)self.fail(err);else self.pass();emitter.emit(events.post,self,done)})})};Base.prototype.parents=function(){return this.suite.parents().concat(this.suite)};Base.prototype.fail=function(err){this.status="failed";this.error=err;return this};Base.prototype.pass=function(){this.status="passed";return this};module.exports=Base});require.register("hydro/lib/hydro/test/index.js",function(exports,require,module){var SyncTest=require("./sync");var AsyncTest=require("./async");exports.create=function(params){var title=params.shift();var fn=null;var klass=null;if(typeof params[params.length-1]==="function")fn=params.pop();klass=fn&&fn.length?AsyncTest:SyncTest;return new klass(title,fn,params)};exports.SyncTest=SyncTest;exports.AsyncTest=AsyncTest});require.register("hydro/lib/hydro/test/sync.js",function(exports,require,module){var BaseTest=require("./base");var SyncTest=BaseTest.extend();SyncTest.prototype.sync=true;SyncTest.prototype.exec=function(done){var err=null;try{this.fn.call(this.context)}catch(e){err=e}done(err)};module.exports=SyncTest});require.register("hydro/lib/hydro/suite/index.js",function(exports,require,module){var util=require("../util");function Suite(title){this.title=util.isFunction(title)?util.fnName(title):title;this.parent=null;this.tests=[];this.suites=[];this.events={pre:"pre:suite",post:"post:suite"}}Suite.prototype.addTest=function(test){test.suite=this;this.tests.push(test)};Suite.prototype.addSuite=function(suite){suite.parent=this;this.suites.push(suite)};Suite.prototype.run=function(emitter,fn){var self=this;var runnable=this.tests.slice(0).concat(this.suites.slice(0));var current=null;var events=this.events;function next(){if(current=runnable.shift()){return current.run(emitter,next)}emitter.emit(events.post,self,function(){fn(self)})}emitter.emit(events.pre,this,next)};Suite.prototype.parents=function(){return this.parent.parents().concat(this.parent)};module.exports=Suite});require.register("hydro/lib/hydro/suite/root.js",function(exports,require,module){var inherits=require("super");var Suite=require("./index");function RootSuite(){Suite.call(this);this.events={pre:"pre:all",post:"post:all"}}inherits(RootSuite,Suite);RootSuite.prototype.addTest=function(){throw new Error("Please add a test suite")};RootSuite.prototype.parents=function(){return[]};module.exports=RootSuite});require.register("hydro/lib/hydro/interface.js",function(exports,require,module){var util=require("./util");function Interface(hydro){this.hydro=hydro}util.forEach(["addTest","addSuite","createTest","createSuite"],function(method){Interface.prototype[method]=function(){return this.hydro[method].apply(this.hydro,arguments)}});module.exports=Interface});require.register("hydro/lib/hydro/util.js",function(exports,require,module){var toString=Object.prototype.toString;var slice=Array.prototype.slice;exports.isString=function(str){return toString.call(str)==="[object String]"};exports.isFunction=function(fn){return toString.call(fn)==="[object Function]"};exports.isArray=function(arr){return toString.call(arr)==="[object Array]"};exports.slice=function(args){return slice.call(args)};exports.toArray=function(arr){if(exports.isArray(arr))return arr;return[arr]};exports.forEach=function(arr,fn,ctx){for(var i=0,len=arr.length;i<len;i++){fn.call(ctx,arr[i])}};exports.eachKey=function(obj,fn){for(var key in obj){if(!obj.hasOwnProperty(key))continue;fn(key,obj[key])}};exports.fnName=function(fn){if(fn.name)return fn.name;var match=/^\s?function ([^(]*)\(/.exec(fn);return match&&match[1]?match[1]:""};exports.noop=function(){}});require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","loa/index.js");require.alias("hydrojs-loa/index.js","hydrojs-loa/index.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/lib/evts.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/index.js");require.alias("vesln-evts/lib/evts.js","evts/index.js");require.alias("vesln-evts/lib/evts.js","vesln-evts/index.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/lib/browser.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/index.js");require.alias("vesln-tryc/lib/browser.js","tryc/index.js");require.alias("vesln-tryc/lib/browser.js","vesln-tryc/index.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/lib/browser.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/index.js");require.alias("vesln-fload/lib/browser.js","fload/index.js");require.alias("vesln-fload/lib/browser.js","vesln-fload/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","globalo/index.js");require.alias("vesln-globalo/index.js","vesln-globalo/index.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/lib/super.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/index.js");require.alias("vesln-super/lib/super.js","super/index.js");require.alias("vesln-super/lib/super.js","vesln-super/index.js");require.alias("hydro/lib/hydro.js","hydro/index.js");if(typeof exports=="object"){module.exports=require("hydro")}else if(typeof define=="function"&&define.amd){define(function(){return require("hydro")})}else{this["Hydro"]=require("hydro")}})();

@@ -16,2 +16,3 @@ /**

var RootSuite = require('./hydro/suite/root');
var Interface = require('./hydro/interface');
var Suite = require('./hydro/suite');

@@ -32,2 +33,3 @@ var Test = require('./hydro/test');

this.emitter = new EventEmitter;
this.interface = new Interface(this);
this.plugins = [];

@@ -92,65 +94,2 @@ this.stack = [new RootSuite];

/**
* Add a new test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.addTest = function() {
var test = this.createTest.apply(this, arguments);
this.stack[0].addTest(test);
return test;
};
/**
* Create a test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.createTest = function() {
var test = Test.create(util.slice(arguments));
var timeout = this.get('timeout');
if (timeout) test.timeout(timeout);
return test;
};
/**
* Add a test suite.
*
* @param {String} title
* @param {Function} body
* @api public
*/
Hydro.prototype.addSuite = function(title, fn) {
var suite = this.createSuite(title);
this.stack[0].addSuite(suite);
if (fn) {
this.stack.unshift(suite);
fn();
this.stack.shift();
}
return suite;
};
/**
* Create a test suite.
*
* @param {String} title
* @api public
*/
Hydro.prototype.createSuite = function(title) {
return new Suite(title);
};
/**
* Register event handler.

@@ -307,2 +246,67 @@ *

/**
* Add a new test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.addTest = function() {
var test = this.createTest.apply(this, arguments);
this.stack[0].addTest(test);
return test;
};
/**
* Create a test.
*
* @param {String} title
* @param {Mixed} meta1 (optional)
* @param {Mixed} meta2 (optional)
* @param {Function} test (optional)
* @api public
*/
Hydro.prototype.createTest = function() {
var test = Test.create(util.slice(arguments));
var timeout = this.get('timeout');
if (timeout) test.timeout(timeout);
return test;
};
/**
* Add a test suite.
*
* @param {String} title
* @param {Function} body
* @api public
*/
Hydro.prototype.addSuite = function(title, fn) {
var suite = this.createSuite(title);
this.stack[0].addSuite(suite);
if (fn) {
this.stack.unshift(suite);
fn();
this.stack.shift();
}
return suite;
};
/**
* Create a test suite.
*
* @param {String} title
* @api public
*/
Hydro.prototype.createSuite = function(title) {
return new Suite(title);
};
/**
* Attach global methods and properties.

@@ -333,3 +337,3 @@ *

target[key] = function() {
return self[val].apply(self, arguments);
return self.interface[val].apply(self.interface, arguments);
};

@@ -372,1 +376,3 @@ });

module.exports.util = util;
module.exports.Test = Test;
module.exports.Suite = Suite;
{
"name": "hydro",
"version": "0.8.10",
"version": "0.8.11",
"preferGlobal": true,

@@ -5,0 +5,0 @@ "description": "Teeny-weeny test runner for Node.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc