aboutsummaryrefslogtreecommitdiffstats
path: root/test/scenario/HtmlUISpec.js
diff options
context:
space:
mode:
authorElliott Sprehn2010-10-08 16:43:40 -0700
committerElliott Sprehn2010-10-14 09:47:39 -0700
commit03df6cbddbb80186caf571e29957370b2ef9881c (patch)
treed5a321c8b207b464a5c8a300c422186e20e8ae31 /test/scenario/HtmlUISpec.js
parent0f104317dff5628765e26cc68df7dd1175b2aa5e (diff)
downloadangular.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 'test/scenario/HtmlUISpec.js')
-rw-r--r--test/scenario/HtmlUISpec.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/test/scenario/HtmlUISpec.js b/test/scenario/HtmlUISpec.js
new file mode 100644
index 00000000..b2e2652f
--- /dev/null
+++ b/test/scenario/HtmlUISpec.js
@@ -0,0 +1,87 @@
+describe('angular.scenario.HtmlUI', function() {
+ var ui;
+ var context;
+ var spec;
+
+ beforeEach(function() {
+ spec = {
+ name: 'test spec',
+ definition: {
+ id: 10,
+ name: 'child',
+ children: [],
+ parent: {
+ id: 20,
+ name: 'parent',
+ children: []
+ }
+ }
+ };
+ context = _jQuery("<div></div>");
+ ui = new angular.scenario.ui.Html(context);
+ });
+
+ it('should create nested describe context', function() {
+ ui.addSpec(spec);
+ expect(context.find('#describe-20 #describe-10 > h2').text())
+ .toEqual('describe: child');
+ expect(context.find('#describe-20 > h2').text()).toEqual('describe: parent');
+ expect(context.find('#describe-10 .tests > li .test-info .test-name').text())
+ .toEqual('it test spec');
+ expect(context.find('#describe-10 .tests > li').hasClass('status-pending'))
+ .toBeTruthy();
+ });
+
+ it('should update totals when steps complete', function() {
+ // Error
+ ui.addSpec(spec).error('error');
+ // Error
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish();
+ specUI.finish('error');
+ // Failure
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish('failure');
+ specUI.finish('failure');
+ // Failure
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish('failure');
+ specUI.finish('failure');
+ // Failure
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish('failure');
+ specUI.finish('failure');
+ // Success
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish();
+ specUI.finish();
+
+ expect(parseInt(context.find('#status-legend .status-failure').text()))
+ .toEqual(3);
+ expect(parseInt(context.find('#status-legend .status-error').text()))
+ .toEqual(2);
+ expect(parseInt(context.find('#status-legend .status-success').text()))
+ .toEqual(1);
+ });
+
+ it('should update timer when test completes', function() {
+ // Success
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish();
+ specUI.finish();
+
+ // Failure
+ specUI = ui.addSpec(spec);
+ specUI.addStep('some step').finish('failure');
+ specUI.finish('failure');
+
+ // Error
+ specUI = ui.addSpec(spec).error('error');
+
+ context.find('#describe-10 .tests > li .test-info .timer-result')
+ .each(function(index, timer) {
+ expect(timer.innerHTML).toMatch(/ms$/);
+ });
+ });
+
+});