forked from nathansobo/screw-unit
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/nkallen/screw-unit
Conflicts: lib/screw.behaviors.js lib/screw.builder.js spec/screwunit_spec.html
- Loading branch information
Showing
12 changed files
with
542 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
need a way to do global before and afters | ||
need to investigate race condition with data store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,91 @@ | ||
$(Screw).bind('loaded', function() { | ||
$(Screw).trigger('before'); | ||
$('.status').fn({ | ||
display: function() { | ||
$(this).text( | ||
$('.passed').length + $('.failed').length + ' test(s), ' + $('.failed').length + ' failure(s)' | ||
); | ||
} | ||
}); | ||
$(Screw).bind('after', function() { | ||
$('.status').fn('display'); | ||
}); | ||
|
||
$('.describe').fn({ | ||
parent: function() { | ||
return $(this).parent('.describes').parent('.describe'); | ||
}, | ||
run_befores: function() { | ||
$(this).fn('parent').fn('run_befores'); | ||
$(this).children('.befores').find('.before').each(function() { | ||
Screw.befores[this.id](); | ||
}); | ||
}, | ||
run_afters: function() { | ||
$(this).fn('parent').fn('run_afters'); | ||
$(this).children('.afters').find('.after').each(function() { | ||
Screw.afters[this.id](); | ||
}); | ||
}, | ||
enqueue: function() { | ||
$(this).children('.its').children('.it').fn('enqueue'); | ||
$(this).children('.describes').children('.describe').fn('enqueue'); | ||
}, | ||
selector: function() { | ||
var parent_selector = $(this).fn('parent').fn('selector'); | ||
if(parent_selector) { | ||
return parent_selector + ' > .describes > .describe:eq(' + $(this).parent('.describes').children('.describe').index(this) + ')'; | ||
} else { | ||
return 'body > .describe'; | ||
(function($) { | ||
$(Screw).bind('load', function() { | ||
$('.status').fn({ | ||
display: function() { | ||
$(this).text( | ||
$('.passed').length + $('.failed').length + ' test(s), ' + $('.failed').length + ' failure(s)' | ||
); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$('.it').fn({ | ||
parent: function() { | ||
return $(this).parent('.its').parent('.describe'); | ||
}, | ||
run: function() { | ||
try { | ||
$('.describe').fn({ | ||
parent: function() { | ||
return $(this).parent('.describes').parent('.describe'); | ||
}, | ||
|
||
run_befores: function() { | ||
$(this).fn('parent').fn('run_befores'); | ||
$(this).children('.befores').children('.before').fn('run'); | ||
}, | ||
|
||
run_afters: function() { | ||
$(this).fn('parent').fn('run_afters'); | ||
$(this).children('.afters').children('.after').fn('run'); | ||
}, | ||
|
||
enqueue: function() { | ||
$(this).children('.its').children('.it').fn('enqueue'); | ||
$(this).children('.describes').children('.describe').fn('enqueue'); | ||
}, | ||
|
||
selector: function() { | ||
return $(this).fn('parent').fn('selector') | ||
+ ' > .describes > .describe:eq(' + $(this).parent('.describes').children('.describe').index(this) + ')'; | ||
} | ||
}); | ||
|
||
$('body > .describe').fn({ | ||
selector: function() { return 'body > .describe' } | ||
}); | ||
|
||
$('.it').fn({ | ||
parent: function() { | ||
return $(this).parent('.its').parent('.describe'); | ||
}, | ||
|
||
run: function() { | ||
try { | ||
$(this) | ||
.fn('parent').fn('run_befores'); | ||
|
||
Screw.its[this.id](); | ||
} finally { | ||
$(this).fn('parent').fn('run_afters'); | ||
try { | ||
$(this).fn('parent').fn('run_befores'); | ||
$(this).data('screwunit.run')(); | ||
} finally { | ||
$(this).fn('parent').fn('run_afters'); | ||
} | ||
$(this).trigger('passed'); | ||
} catch(e) { | ||
$(this).trigger('failed', [e]); | ||
} | ||
$(this).trigger('passed'); | ||
} catch(e) { | ||
$(this).trigger('failed', [e]); | ||
}, | ||
|
||
enqueue: function() { | ||
var self = $(this).trigger('enqueued'); | ||
$(Screw) | ||
.queue(function() { | ||
self.fn('run'); | ||
setTimeout(function() { $(Screw).dequeue() }, 0); | ||
}); | ||
}, | ||
|
||
selector: function() { | ||
return $(this).fn('parent').fn('selector') | ||
+ ' > .its > .it:eq(' + $(this).parent('.its').children('.it').index(this) + ')'; | ||
} | ||
}, | ||
enqueue: function() { | ||
var self = $(this).trigger('enqueued'); | ||
$(Screw) | ||
.queue(function() { | ||
self.fn('run'); | ||
setTimeout(function() { $(Screw).dequeue() }, 0); | ||
}); | ||
}, | ||
selector: function() { | ||
return $(this).fn('parent').fn('selector') | ||
+ ' > .its > .it:eq(' + $(this).parent('.its').children('.it').index(this) + ')'; | ||
} | ||
}); | ||
}); | ||
|
||
$('.before').fn({ | ||
run: function() { $(this).data('screwunit.run')() } | ||
}); | ||
|
||
$('.after').fn({ | ||
run: function() { $(this).data('screwunit.run')() } | ||
}); | ||
|
||
$('.status').text('Running...'); | ||
var to_run = unescape(location.search.slice(1)) || 'body > .describe > .describes > .describe'; | ||
$(to_run) | ||
.focus() | ||
.fn('enqueue'); | ||
$(Screw).queue(function() {$(Screw).trigger('after');}); | ||
}); | ||
$(Screw).trigger('before'); | ||
var to_run = unescape(location.search.slice(1)) || 'body > .describe > .describes > .describe'; | ||
$(to_run) | ||
.focus() | ||
.eq(0).trigger('scroll').end() | ||
.fn('enqueue'); | ||
$(Screw).queue(function() { $(Screw).trigger('after') }); | ||
}) | ||
})(jQuery); |
Oops, something went wrong.