Comparing version 0.2.7 to 0.2.8
44
bean.js
@@ -10,4 +10,9 @@ /*! | ||
*/ | ||
!function (context) { | ||
var __uid = 1, | ||
!function (name, definition) { | ||
if (typeof define == 'function') define(definition); | ||
else if (typeof module != 'undefined') module.exports = definition(); | ||
else this[name] = definition(); | ||
}('bean', function () { | ||
var win = window, | ||
__uid = 1, | ||
registry = {}, | ||
@@ -22,3 +27,3 @@ collected = {}, | ||
detachEvent = 'detachEvent', | ||
doc = context.document || {}, | ||
doc = document || {}, | ||
root = doc.documentElement || {}, | ||
@@ -50,3 +55,5 @@ W3C_MODEL = root[addEvent], | ||
} : function (element, type, fn, add, custom) { | ||
custom && add && (element['_on' + custom] = element['_on' + custom] || 0); | ||
if (custom && add && element['_on' + custom] === null) { | ||
element['_on' + custom] = 0; | ||
} | ||
element[add ? attachEvent : detachEvent]('on' + type, fn); | ||
@@ -57,3 +64,3 @@ }, | ||
return function (event) { | ||
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || context).event); | ||
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event); | ||
return fn.apply(element, [event].concat(args)); | ||
@@ -64,5 +71,6 @@ }; | ||
customHandler = function (element, fn, type, condition, args) { | ||
return function (e) { | ||
if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : e && e.propertyName == '_on' + type || !e) { | ||
fn.apply(element, Array.prototype.slice.call(arguments, e ? 0 : 1).concat(args)); | ||
return function (event) { | ||
if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : event && event.propertyName == '_on' + type || !event) { | ||
event = event ? fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event) : null; | ||
fn.apply(element, Array.prototype.slice.call(arguments, event ? 0 : 1).concat(args)); | ||
} | ||
@@ -161,5 +169,5 @@ }; | ||
names = isString && orgEvents.replace(namespace, ''), | ||
names = names && names.split('.'), | ||
rm = removeListener, | ||
attached = retrieveEvents(element); | ||
names = names && names.split('.'); | ||
if (isString && /\s/.test(orgEvents)) { | ||
@@ -229,3 +237,3 @@ orgEvents = orgEvents.split(' '); | ||
evt = document.createEvent(isNative ? "HTMLEvents" : "UIEvents"); | ||
evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, context, 1); | ||
evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, win, 1); | ||
element.dispatchEvent(evt); | ||
@@ -333,21 +341,17 @@ } : function (isNative, type, element) { | ||
if (context[attachEvent]) { | ||
add(context, 'unload', function () { | ||
if (win[attachEvent]) { | ||
add(win, 'unload', function () { | ||
for (var k in collected) { | ||
collected.hasOwnProperty(k) && clean(collected[k]); | ||
} | ||
context.CollectGarbage && CollectGarbage(); | ||
win.CollectGarbage && CollectGarbage(); | ||
}); | ||
} | ||
var oldBean = context.bean; | ||
bean.noConflict = function () { | ||
context.bean = oldBean; | ||
context.bean = old; | ||
return this; | ||
}; | ||
(typeof module !== 'undefined' && module.exports) ? | ||
(module.exports = bean) : | ||
(context['bean'] = bean); | ||
}(this); | ||
return bean; | ||
}); |
@@ -10,2 +10,2 @@ /*! | ||
*/ | ||
!function(a){function F(a){var b=a.relatedTarget;return b?b!=this&&b.prefix!="xul"&&!/document/.test(this.toString())&&!p(this,b):b===null}var b=1,c={},d={},e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=a.document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=function(a,b){var c=b.parentNode;while(c!==null){if(c==a)return!0;c=c.parentNode}},q=function(a,c){return a.__uid=c&&c+"::"+b++||a.__uid||b++},r=function(a){var b=q(a);return c[b]=c[b]||{}},s=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&(a["_on"+e]=a["_on"+e]||0),a[d?i:k]("on"+b,c)},t=function(b,c,d){return function(e){e=D(e||((this.ownerDocument||this.document||this).parentWindow||a).event);return c.apply(b,[e].concat(d))}},u=function(a,b,c,d,e){return function(f){(d?d.apply(this,arguments):n?!0:f&&f.propertyName=="_on"+c||!f)&&b.apply(a,Array.prototype.slice.call(arguments,f?0:1).concat(e))}},v=function(a,b,c,e){var h=b.replace(g,""),i=r(a),j=i[h]||(i[h]={}),k=c,l=q(c,b.replace(f,""));if(j[l])return a;var m=G[h];m&&(c=m.condition?u(a,c,h,m.condition):c,h=m.base||h);var p=E[h];c=p?t(a,c,e):u(a,c,h,!1,e),p=n||p;if(h=="unload"){var v=c;c=function(){w(a,h,c)&&v()}}a[o]&&s(a,p?h:"propertychange",c,!0,!p&&h),j[l]=c,c.__uid=l,c.__originalFn=k;return h=="unload"?a:d[q(a)]=a},w=function(a,b,c){function l(b){c=j[k][b];if(!!c){delete j[k][b];if(a[o]){k=G[k]?G[k].base:k;var d=n||E[k];s(a,d?k:"propertychange",c,!1,!d&&k)}}}var d,e,h,i,j=r(a),k=b.replace(g,"");if(!j||!j[k])return a;e=b.replace(f,""),h=e?e.split("."):[c.__uid],l(e);for(i=h.length;i--;l(h[i]));return a},x=function(a,b,c){return function(d){var e=typeof a=="string"?c(a,this):a;for(var f=d.target;f&&f!=this;f=f.parentNode)for(var g=e.length;g--;)if(e[g]==f)return b.apply(f,arguments)}},y=function(a,b,c,d,e){if(typeof b=="object"&&!c)for(var f in b)b.hasOwnProperty(f)&&y(a,f,b[f]);else{var g=typeof c=="string",h=(g?c:b).split(" ");c=g?x(b,d,e):c;for(var i=h.length;i--;)v(a,h[i],c,Array.prototype.slice.call(arguments,g?4:3))}return a},z=function(a,b,c){var d,e,h,i,j,k=typeof b=="string",l=k&&b.replace(f,""),l=l&&l.split("."),m=w,n=r(a);if(k&&/\s/.test(b)){b=b.split(" "),j=b.length-1;while(z(a,b[j])&&j--);return a}i=k?b.replace(g,""):b;if(!n||l||k&&!n[i]){for(d in n)if(n.hasOwnProperty(d))for(j in n[d])for(e=l.length;e--;)n[d].hasOwnProperty(j)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(j)&&m(a,[d,j].join("."));return a}if(typeof c=="function")m(a,i,c);else if(l)m(a,b);else{m=i?m:z,h=k&&i,i=i?c||n[i]||i:n;for(d in i)i.hasOwnProperty(d)&&(m(a,h||d,i[d]),delete i[d])}return a},A=function(a,b,c){var d,e,h,i,j=b.split(" ");for(h=j.length;h--;){b=j[h].replace(g,"");var k=E[b],l=j[h].replace(f,""),m=r(a)[b];if(l){l=l.split(".");for(e=l.length;e--;)for(i in m)m.hasOwnProperty(i)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(i)&&m[i].apply(a,[!1].concat(c))}else if(!c&&a[o])B(k,b,a);else for(e in m)m.hasOwnProperty(e)&&m[e].apply(a,[!1].concat(c))}return a},B=n?function(b,c,d){evt=document.createEvent(b?"HTMLEvents":"UIEvents"),evt[b?"initEvent":"initUIEvent"](c,!0,!0,a,1),d.dispatchEvent(evt)}:function(a,b,c){a?c.fireEvent("on"+b,document.createEventObject()):c["_on"+b]++},C=function(a,b,c){var d=r(b),e,f,g=q(a);e=c?d[c]:d;for(f in e)e.hasOwnProperty(f)&&(c?y:C)(a,c||b,c?e[f].__originalFn:f);return a},D=function(a){var b={};if(!a)return b;var c=a.type,d=a.target||a.srcElement;b.preventDefault=D.preventDefault(a),b.stopPropagation=D.stopPropagation(a),b.target=d&&d.nodeType==3?d.parentNode:d;if(~c.indexOf("key"))b.keyCode=a.which||a.keyCode;else if(/click|mouse|menu/i.test(c)){b.rightClick=a.which==3||a.button==2,b.pos={x:0,y:0};if(a.pageX||a.pageY)b.clientX=a.pageX,b.clientY=a.pageY;else if(a.clientX||a.clientY)b.clientX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.clientY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;e.test(c)&&(b.relatedTarget=a.relatedTarget||a[(c=="mouseover"?"from":"to")+"Element"])}for(var f in a)f in b||(b[f]=a[f]);return b};D.preventDefault=function(a){return function(){a.preventDefault?a.preventDefault():a.returnValue=!1}},D.stopPropagation=function(a){return function(){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}};var E={click:1,dblclick:1,mouseup:1,mousedown:1,contextmenu:1,mousewheel:1,DOMMouseScroll:1,mouseover:1,mouseout:1,mousemove:1,selectstart:1,selectend:1,keydown:1,keypress:1,keyup:1,orientationchange:1,touchstart:1,touchmove:1,touchend:1,touchcancel:1,gesturestart:1,gesturechange:1,gestureend:1,focus:1,blur:1,change:1,reset:1,select:1,submit:1,load:1,unload:1,beforeunload:1,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1},G={mouseenter:{base:"mouseover",condition:F},mouseleave:{base:"mouseout",condition:F},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}},H={add:y,remove:z,clone:C,fire:A},I=function(a){var b=z(a).__uid;b&&(delete d[b],delete c[b])};a[i]&&y(a,"unload",function(){for(var b in d)d.hasOwnProperty(b)&&I(d[b]);a.CollectGarbage&&CollectGarbage()});var J=a.bean;H.noConflict=function(){a.bean=J;return this},typeof module!="undefined"&&module.exports?module.exports=H:a.bean=H}(this) | ||
!function(a,b){typeof define=="function"?define(b):typeof module!="undefined"?module.exports=b():this[a]=b()}("bean",function(){function F(a){var b=a.relatedTarget;if(!b)return b===null;return b!=this&&b.prefix!="xul"&&!/document/.test(this.toString())&&!p(this,b)}var a=window,b=1,c={},d={},e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=function(a,b){var c=b.parentNode;while(c!==null){if(c==a)return!0;c=c.parentNode}},q=function(a,c){return a.__uid=c&&c+"::"+b++||a.__uid||b++},r=function(a){var b=q(a);return c[b]=c[b]||{}},s=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&a["_on"+e]===null&&(a["_on"+e]=0),a[d?i:k]("on"+b,c)},t=function(b,c,d){return function(e){e=D(e||((this.ownerDocument||this.document||this).parentWindow||a).event);return c.apply(b,[e].concat(d))}},u=function(b,c,d,e,f){return function(g){if(e?e.apply(this,arguments):n?!0:g&&g.propertyName=="_on"+d||!g)g=g?D(g||((this.ownerDocument||this.document||this).parentWindow||a).event):null,c.apply(b,Array.prototype.slice.call(arguments,g?0:1).concat(f))}},v=function(a,b,c,e){var h=b.replace(g,""),i=r(a),j=i[h]||(i[h]={}),k=c,l=q(c,b.replace(f,""));if(j[l])return a;var m=G[h];m&&(c=m.condition?u(a,c,h,m.condition):c,h=m.base||h);var p=E[h];c=p?t(a,c,e):u(a,c,h,!1,e),p=n||p;if(h=="unload"){var v=c;c=function(){w(a,h,c)&&v()}}a[o]&&s(a,p?h:"propertychange",c,!0,!p&&h),j[l]=c,c.__uid=l,c.__originalFn=k;return h=="unload"?a:d[q(a)]=a},w=function(a,b,c){function l(b){c=j[k][b];if(!!c){delete j[k][b];if(a[o]){k=G[k]?G[k].base:k;var d=n||E[k];s(a,d?k:"propertychange",c,!1,!d&&k)}}}var d,e,h,i,j=r(a),k=b.replace(g,"");if(!j||!j[k])return a;e=b.replace(f,""),h=e?e.split("."):[c.__uid],l(e);for(i=h.length;i--;l(h[i]));return a},x=function(a,b,c){return function(d){var e=typeof a=="string"?c(a,this):a;for(var f=d.target;f&&f!=this;f=f.parentNode)for(var g=e.length;g--;)if(e[g]==f)return b.apply(f,arguments)}},y=function(a,b,c,d,e){if(typeof b=="object"&&!c)for(var f in b)b.hasOwnProperty(f)&&y(a,f,b[f]);else{var g=typeof c=="string",h=(g?c:b).split(" ");c=g?x(b,d,e):c;for(var i=h.length;i--;)v(a,h[i],c,Array.prototype.slice.call(arguments,g?4:3))}return a},z=function(a,b,c){var d,e,h,i,j,k=typeof b=="string",l=k&&b.replace(f,""),m=w,n=r(a);l=l&&l.split(".");if(k&&/\s/.test(b)){b=b.split(" "),j=b.length-1;while(z(a,b[j])&&j--);return a}i=k?b.replace(g,""):b;if(!n||l||k&&!n[i]){for(d in n)if(n.hasOwnProperty(d))for(j in n[d])for(e=l.length;e--;)n[d].hasOwnProperty(j)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(j)&&m(a,[d,j].join("."));return a}if(typeof c=="function")m(a,i,c);else if(l)m(a,b);else{m=i?m:z,h=k&&i,i=i?c||n[i]||i:n;for(d in i)i.hasOwnProperty(d)&&(m(a,h||d,i[d]),delete i[d])}return a},A=function(a,b,c){var d,e,h,i,j=b.split(" ");for(h=j.length;h--;){b=j[h].replace(g,"");var k=E[b],l=j[h].replace(f,""),m=r(a)[b];if(l){l=l.split(".");for(e=l.length;e--;)for(i in m)m.hasOwnProperty(i)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(i)&&m[i].apply(a,[!1].concat(c))}else if(!c&&a[o])B(k,b,a);else for(e in m)m.hasOwnProperty(e)&&m[e].apply(a,[!1].concat(c))}return a},B=n?function(b,c,d){evt=document.createEvent(b?"HTMLEvents":"UIEvents"),evt[b?"initEvent":"initUIEvent"](c,!0,!0,a,1),d.dispatchEvent(evt)}:function(a,b,c){a?c.fireEvent("on"+b,document.createEventObject()):c["_on"+b]++},C=function(a,b,c){var d=r(b),e,f,g=q(a);e=c?d[c]:d;for(f in e)e.hasOwnProperty(f)&&(c?y:C)(a,c||b,c?e[f].__originalFn:f);return a},D=function(a){var b={};if(!a)return b;var c=a.type,d=a.target||a.srcElement;b.preventDefault=D.preventDefault(a),b.stopPropagation=D.stopPropagation(a),b.target=d&&d.nodeType==3?d.parentNode:d;if(~c.indexOf("key"))b.keyCode=a.which||a.keyCode;else if(/click|mouse|menu/i.test(c)){b.rightClick=a.which==3||a.button==2,b.pos={x:0,y:0};if(a.pageX||a.pageY)b.clientX=a.pageX,b.clientY=a.pageY;else if(a.clientX||a.clientY)b.clientX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.clientY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;e.test(c)&&(b.relatedTarget=a.relatedTarget||a[(c=="mouseover"?"from":"to")+"Element"])}for(var f in a)f in b||(b[f]=a[f]);return b};D.preventDefault=function(a){return function(){a.preventDefault?a.preventDefault():a.returnValue=!1}},D.stopPropagation=function(a){return function(){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}};var E={click:1,dblclick:1,mouseup:1,mousedown:1,contextmenu:1,mousewheel:1,DOMMouseScroll:1,mouseover:1,mouseout:1,mousemove:1,selectstart:1,selectend:1,keydown:1,keypress:1,keyup:1,orientationchange:1,touchstart:1,touchmove:1,touchend:1,touchcancel:1,gesturestart:1,gesturechange:1,gestureend:1,focus:1,blur:1,change:1,reset:1,select:1,submit:1,load:1,unload:1,beforeunload:1,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1},G={mouseenter:{base:"mouseover",condition:F},mouseleave:{base:"mouseout",condition:F},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}},H={add:y,remove:z,clone:C,fire:A},I=function(a){var b=z(a).__uid;b&&(delete d[b],delete c[b])};a[i]&&y(a,"unload",function(){for(var b in d)d.hasOwnProperty(b)&&I(d[b]);a.CollectGarbage&&CollectGarbage()}),H.noConflict=function(){context.bean=old;return this};return H}) |
@@ -12,3 +12,3 @@ require('smoosh').config({ | ||
"forin": false, | ||
"curly": true, | ||
"curly": false, | ||
"debug": false, | ||
@@ -20,7 +20,7 @@ "devel": false, | ||
"sub": true, | ||
"white": true, | ||
"white": false, | ||
"indent": 2, | ||
"whitespace": true, | ||
"asi": false | ||
"asi": true | ||
} | ||
}).run().build().analyze(); |
{ | ||
"name": "bean", | ||
"description": "an events api for javascript", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"homepage": "https://github.com/fat/bean", | ||
@@ -6,0 +6,0 @@ "authors": ["Jacob Thornton <@fat>"], |
@@ -146,3 +146,3 @@ Bean | ||
var inst = new Klass(); | ||
bean.add(klass, 'complete', handler); | ||
bean.add(inst, 'complete', handler); | ||
@@ -149,0 +149,0 @@ //later on... |
@@ -1,3 +0,8 @@ | ||
!function (context) { | ||
var __uid = 1, | ||
!function (name, definition) { | ||
if (typeof define == 'function') define(definition); | ||
else if (typeof module != 'undefined') module.exports = definition(); | ||
else this[name] = definition(); | ||
}('bean', function () { | ||
var win = window, | ||
__uid = 1, | ||
registry = {}, | ||
@@ -12,3 +17,3 @@ collected = {}, | ||
detachEvent = 'detachEvent', | ||
doc = context.document || {}, | ||
doc = document || {}, | ||
root = doc.documentElement || {}, | ||
@@ -40,3 +45,5 @@ W3C_MODEL = root[addEvent], | ||
} : function (element, type, fn, add, custom) { | ||
custom && add && (element['_on' + custom] = element['_on' + custom] || 0); | ||
if (custom && add && element['_on' + custom] === null) { | ||
element['_on' + custom] = 0; | ||
} | ||
element[add ? attachEvent : detachEvent]('on' + type, fn); | ||
@@ -47,3 +54,3 @@ }, | ||
return function (event) { | ||
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || context).event); | ||
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event); | ||
return fn.apply(element, [event].concat(args)); | ||
@@ -54,5 +61,6 @@ }; | ||
customHandler = function (element, fn, type, condition, args) { | ||
return function (e) { | ||
if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : e && e.propertyName == '_on' + type || !e) { | ||
fn.apply(element, Array.prototype.slice.call(arguments, e ? 0 : 1).concat(args)); | ||
return function (event) { | ||
if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : event && event.propertyName == '_on' + type || !event) { | ||
event = event ? fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event) : null; | ||
fn.apply(element, Array.prototype.slice.call(arguments, event ? 0 : 1).concat(args)); | ||
} | ||
@@ -151,5 +159,5 @@ }; | ||
names = isString && orgEvents.replace(namespace, ''), | ||
names = names && names.split('.'), | ||
rm = removeListener, | ||
attached = retrieveEvents(element); | ||
names = names && names.split('.'); | ||
if (isString && /\s/.test(orgEvents)) { | ||
@@ -219,3 +227,3 @@ orgEvents = orgEvents.split(' '); | ||
evt = document.createEvent(isNative ? "HTMLEvents" : "UIEvents"); | ||
evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, context, 1); | ||
evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, win, 1); | ||
element.dispatchEvent(evt); | ||
@@ -323,21 +331,17 @@ } : function (isNative, type, element) { | ||
if (context[attachEvent]) { | ||
add(context, 'unload', function () { | ||
if (win[attachEvent]) { | ||
add(win, 'unload', function () { | ||
for (var k in collected) { | ||
collected.hasOwnProperty(k) && clean(collected[k]); | ||
} | ||
context.CollectGarbage && CollectGarbage(); | ||
win.CollectGarbage && CollectGarbage(); | ||
}); | ||
} | ||
var oldBean = context.bean; | ||
bean.noConflict = function () { | ||
context.bean = oldBean; | ||
context.bean = old; | ||
return this; | ||
}; | ||
(typeof module !== 'undefined' && module.exports) ? | ||
(module.exports = bean) : | ||
(context['bean'] = bean); | ||
}(this); | ||
return bean; | ||
}); |
{ | ||
"name": "sink-test", | ||
"description": "test your javascript - headless, or in the browser", | ||
"version": "0.0.6", | ||
"version": "0.0.5", | ||
"authors": ["Dustin Diaz <@ded>", "Jacob Thornton <@fat>"], | ||
@@ -10,6 +10,3 @@ "keywords": ["testing", "unit tests", "headless", "boosh", "luke warm"], | ||
"node": ">= 0.1.0" | ||
}, | ||
"dependencies": { | ||
"colors": ">= 0.5.0" | ||
} | ||
} |
@@ -11,9 +11,7 @@ Sink Test | ||
``` js | ||
test('should have foo', 1, function() { | ||
$.ajax('/foo', function(resp) { | ||
ok(resp.stat == '200'); | ||
}); | ||
}); | ||
``` | ||
test('should have foo', 1, function() { | ||
$.ajax('/foo', function(resp) { | ||
ok(resp.stat == '200'); | ||
}); | ||
}); | ||
@@ -25,26 +23,24 @@ Loading a suite of tests | ||
``` js | ||
sink('my module', function(test, ok, before, after) { | ||
before(function () { | ||
// run this before every test | ||
}); | ||
sink('my module', function(test, ok, before, after) { | ||
before(function () { | ||
// run this before every test | ||
}); | ||
after(function () { | ||
// run this after every test | ||
}); | ||
after(function () { | ||
// run this after every test | ||
}); | ||
test('should have foo', 2, function () { | ||
ok(true, 'this is basically true'); | ||
ok(1 == 1, 'also true for you math majors'); | ||
}); | ||
}); | ||
test('should have foo', 2, function() { | ||
ok(true, 'this is basically true'); | ||
ok(1 == 1, 'also true for you math majors'); | ||
}); | ||
}); | ||
sink('another module', function (t, o, b, a) { | ||
test('a failure', 1, function () { | ||
ok(1 == 2, 'should fail'); | ||
}); | ||
}); | ||
sink('another module', function (t, o, b, a) { | ||
test('a failure', 1, function () { | ||
ok(1 == 2, 'should fail'); | ||
}); | ||
}); | ||
start(); // start all test modules | ||
``` | ||
start(); // start all test modules | ||
@@ -56,24 +52,22 @@ Browser support | ||
``` js | ||
// tests.js | ||
/** this snippet can be found in src/headless.js */ | ||
var sink = require('path/to/sink'); | ||
var start = sink.start; | ||
sink = sink.sink; | ||
// tests.js | ||
/** this snippet can be found in src/headless.js */ | ||
var sink = require('path/to/sink'); | ||
var start = sink.start; | ||
sink = sink.sink; | ||
sink('some module', function (test, ok) { | ||
// write tests | ||
}); | ||
sink('some module', function (test, ok) { | ||
// write tests | ||
}); | ||
sink('another module', function (test, ok) { | ||
// write tests | ||
}); | ||
sink('another module', function (test, ok) { | ||
// write tests | ||
}); | ||
start(); | ||
``` | ||
start(); | ||
in your terminal | ||
$ node path/to/my/tests.js | ||
% node path/to/my/tests.js | ||
Happy testing! |
@@ -1,2 +0,1 @@ | ||
//stub this for ie crap | ||
if (!window.console) { | ||
@@ -114,2 +113,8 @@ window.console = { log: function () {}} | ||
test('add: shouldn\'t trigger event when adding additional custom event listeners', 0, function () { | ||
var el = document.getElementById('input'); | ||
bean.add(el, 'foo', function () {ok(true, 'additional custom event listeners trigger event 1')}); | ||
bean.add(el, 'foo', function () {ok(true, 'additional custom event listeners trigger event 2')}); | ||
}); | ||
}) | ||
@@ -197,2 +202,16 @@ | ||
test('event: should have stop propagation method on custom event', 1, function () { | ||
var el = document.getElementById('foo'); | ||
bean.remove(el); | ||
bean.add(el, 'customEvent', function (e) {ok(e.stopPropagation != null, 'has stop propagation')}); | ||
bean.fire(el, 'customEvent'); | ||
}); | ||
test('event: should have preventDefault method on custom event', 1, function () { | ||
var el = document.getElementById('foo'); | ||
bean.remove(el); | ||
bean.add(el, 'customEvent', function (e) {ok(e.preventDefault != null, 'has prevent default method')}); | ||
bean.fire(el, 'customEvent'); | ||
}); | ||
test('event: should have keyCode', 1, function () { | ||
@@ -199,0 +218,0 @@ var el = document.getElementById('input'); |
653478
107
17764