diff options
| author | Elliott Sprehn | 2010-10-08 16:43:40 -0700 |
|---|---|---|
| committer | Elliott Sprehn | 2010-10-14 09:47:39 -0700 |
| commit | 03df6cbddbb80186caf571e29957370b2ef9881c (patch) | |
| tree | d5a321c8b207b464a5c8a300c422186e20e8ae31 /src/scenario/bootstrap.js | |
| parent | 0f104317dff5628765e26cc68df7dd1175b2aa5e (diff) | |
| download | angular.js-03df6cbddbb80186caf571e29957370b2ef9881c.tar.bz2 | |
New Angular Scenario runner and DSL system with redesigned HTML UI.
Uses the Jasmine syntax for tests, ex:
describe('widgets', function() {
it('should verify that basic widgets work', function(){
navigateTo('widgets.html');
input('text.basic').enter('Carlos');
expect(binding('text.basic')).toEqual('Carlos');
input('text.basic').enter('Carlos Santana');
expect(binding('text.basic')).not().toEqual('Carlos Boozer');
input('text.password').enter('secret');
expect(binding('text.password')).toEqual('secret');
expect(binding('text.hidden')).toEqual('hiddenValue');
expect(binding('gender')).toEqual('male');
input('gender').select('female');
expect(binding('gender')).toEqual('female');
});
});
Note: To create new UI's implement the interface shown in angular.scenario.ui.Html.
Diffstat (limited to 'src/scenario/bootstrap.js')
| -rw-r--r-- | src/scenario/bootstrap.js | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/src/scenario/bootstrap.js b/src/scenario/bootstrap.js index f74305c3..014c636d 100644 --- a/src/scenario/bootstrap.js +++ b/src/scenario/bootstrap.js @@ -1,4 +1,4 @@ -(function(onLoadDelegate){ +(function(previousOnLoad){ var prefix = (function(){ var filename = /(.*\/)bootstrap.js(#(.*))?/; var scripts = document.getElementsByTagName("script"); @@ -10,6 +10,7 @@ } } })(); + function addScript(path) { document.write('<script type="text/javascript" src="' + prefix + path + '"></script>'); } @@ -18,26 +19,51 @@ document.write('<link rel="stylesheet" type="text/css" href="' + prefix + path + '"/>'); } - window.angular = { - scenario: { - dsl: window - } - }; - window.onload = function(){ - setTimeout(function(){ - $scenarioRunner.run(jQuery(window.document.body)); - }, 0); - (onLoadDelegate||function(){})(); + try { + if (previousOnLoad) previousOnLoad(); + } catch(e) {} + _jQuery(document.body).append( + '<div id="runner"></div>' + + '<div id="frame"></div>' + ); + var frame = _jQuery('#frame'); + var runner = _jQuery('#runner'); + var application = new angular.scenario.Application(frame); + var ui = new angular.scenario.ui.Html(runner); + $scenario.run(ui, application, angular.scenario.SpecRunner, function(error) { + frame.remove(); + if (error) { + if (window.console) { + console.log(error.stack || error); + } else { + // Do something for IE + alert(error); + } + } + }); }; + addCSS("../../css/angular-scenario.css"); addScript("../../lib/jquery/jquery-1.4.2.js"); + addScript("../angular-bootstrap.js"); + + addScript("Scenario.js"); + addScript("Application.js"); + addScript("Describe.js"); + addScript("Future.js"); + addScript("HtmlUI.js"); addScript("Runner.js"); - addScript("../Angular.js"); - addScript("../JSON.js"); - addScript("DSL.js"); - document.write('<script type="text/javascript">' + - '$scenarioRunner = new angular.scenario.Runner(window, jQuery);' + - '</script>'); -})(window.onload); + addScript("SpecRunner.js"); + addScript("dsl.js"); + addScript("matchers.js"); + // Create the runner (which also sets up the global API) + document.write( + '<script type="text/javascript">' + + 'var _jQuery = jQuery.noConflict(true);' + + 'var $scenario = new angular.scenario.Runner(window);' + + '</script>' + ); + +})(window.onload); |
