aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngScenario/output
diff options
context:
space:
mode:
authorMisko Hevery2012-03-23 14:03:24 -0700
committerMisko Hevery2012-03-28 11:16:35 -0700
commit2430f52bb97fa9d682e5f028c977c5bf94c5ec38 (patch)
treee7529b741d70199f36d52090b430510bad07f233 /test/ngScenario/output
parent944098a4e0f753f06b40c73ca3e79991cec6c2e2 (diff)
downloadangular.js-2430f52bb97fa9d682e5f028c977c5bf94c5ec38.tar.bz2
chore(module): move files around in preparation for more modules
Diffstat (limited to 'test/ngScenario/output')
-rw-r--r--test/ngScenario/output/HtmlSpec.js126
-rw-r--r--test/ngScenario/output/jsonSpec.js37
-rw-r--r--test/ngScenario/output/objectSpec.js40
-rw-r--r--test/ngScenario/output/xmlSpec.js36
4 files changed, 239 insertions, 0 deletions
diff --git a/test/ngScenario/output/HtmlSpec.js b/test/ngScenario/output/HtmlSpec.js
new file mode 100644
index 00000000..442e596d
--- /dev/null
+++ b/test/ngScenario/output/HtmlSpec.js
@@ -0,0 +1,126 @@
+'use strict';
+
+describe('angular.scenario.output.html', function() {
+ var runner, model, spec, step, listeners, ui, context;
+
+ beforeEach(function() {
+ listeners = [];
+ spec = {
+ name: 'test spec',
+ definition: {
+ id: 10,
+ name: 'child',
+ children: [],
+ parent: {
+ id: 20,
+ name: 'parent',
+ children: []
+ }
+ }
+ };
+ step = {
+ name: 'some step',
+ line: function() { return 'unknown:-1'; }
+ };
+ runner = new angular.scenario.testing.MockRunner();
+ model = new angular.scenario.ObjectModel(runner);
+ context = _jQuery("<div></div>");
+ ui = angular.scenario.output.html(context, runner, model);
+ });
+
+ it('should create nested describe context', function() {
+ runner.emit('SpecBegin', 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('test spec');
+ expect(context.find('#describe-10 .tests > li').hasClass('status-pending')).
+ toBeTruthy();
+ });
+
+ it('should add link on InteractivePause', function() {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('InteractivePause', spec, step);
+ expect(context.find('.test-actions .test-title:first').text()).toEqual('some step');
+ expect(lowercase(context.find('.test-actions .test-title:last').html())).toEqual(
+ 'paused... <a href="javascript:resume()">resume</a> when ready.'
+ );
+ });
+
+ it('should update totals when steps complete', function() {
+ // Failure
+ for (var i=0; i < 3; ++i) {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, 'error');
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+ }
+
+ // Error
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecError', spec, 'error');
+ runner.emit('SpecEnd', spec);
+
+ // Error
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepError', spec, step, 'error');
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+
+ // Success
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+
+ expect(parseInt(context.find('#status-legend .status-failure').text(), 10)).
+ toEqual(3);
+ expect(parseInt(context.find('#status-legend .status-error').text(), 10)).
+ toEqual(2);
+ expect(parseInt(context.find('#status-legend .status-success').text(), 10)).
+ toEqual(1);
+ });
+
+ it('should update timer when test completes', function() {
+ // Success
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+
+ // Failure
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, 'error');
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+
+ // Error
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecError', spec, 'error');
+ runner.emit('SpecEnd', spec);
+
+ context.find('#describe-10 .tests > li .test-info .timer-result').
+ each(function(index, timer) {
+ expect(timer.innerHTML).toMatch(/ms$/);
+ });
+ });
+
+ it('should include line if provided', function() {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, 'error');
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+
+ var errorHtml = context.find('#describe-10 .tests li pre').html();
+ expect(errorHtml.indexOf('unknown:-1')).toEqual(0);
+ });
+
+});
diff --git a/test/ngScenario/output/jsonSpec.js b/test/ngScenario/output/jsonSpec.js
new file mode 100644
index 00000000..06caf91c
--- /dev/null
+++ b/test/ngScenario/output/jsonSpec.js
@@ -0,0 +1,37 @@
+'use strict';
+
+describe('angular.scenario.output.json', function() {
+ var output, context;
+ var runner, model, $window;
+ var spec, step;
+
+ beforeEach(function() {
+ $window = {};
+ context = _jQuery('<div></div>');
+ runner = new angular.scenario.testing.MockRunner();
+ model = new angular.scenario.ObjectModel(runner);
+ output = angular.scenario.output.json(context, runner, model);
+ spec = {
+ name: 'test spec',
+ definition: {
+ id: 10,
+ name: 'describe'
+ }
+ };
+ step = {
+ name: 'some step',
+ line: function() { return 'unknown:-1'; }
+ };
+ });
+
+ it('should put json in context on RunnerEnd', function() {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+ runner.emit('RunnerEnd');
+
+ expect(angular.fromJson(context.html()).children['describe']
+ .specs['test spec'].status).toEqual('success');
+ });
+});
diff --git a/test/ngScenario/output/objectSpec.js b/test/ngScenario/output/objectSpec.js
new file mode 100644
index 00000000..d92c939d
--- /dev/null
+++ b/test/ngScenario/output/objectSpec.js
@@ -0,0 +1,40 @@
+'use strict';
+
+describe('angular.scenario.output.object', function() {
+ var output;
+ var runner, model, $window;
+ var spec, step;
+
+ beforeEach(function() {
+ $window = {};
+ runner = new angular.scenario.testing.MockRunner();
+ model = new angular.scenario.ObjectModel(runner);
+ runner.$window = $window;
+ output = angular.scenario.output.object(null, runner, model);
+ spec = {
+ name: 'test spec',
+ definition: {
+ id: 10,
+ name: 'describe',
+ children: []
+ }
+ };
+ step = {
+ name: 'some step',
+ line: function() { return 'unknown:-1'; }
+ };
+ });
+
+ it('should create a global variable $result', function() {
+ expect($window.$result).toBeDefined();
+ });
+
+ it('should maintain live state in $result', function() {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+
+ expect($window.$result.children['describe']
+ .specs['test spec'].steps[0].duration).toBeDefined();
+ });
+});
diff --git a/test/ngScenario/output/xmlSpec.js b/test/ngScenario/output/xmlSpec.js
new file mode 100644
index 00000000..94c3cb5a
--- /dev/null
+++ b/test/ngScenario/output/xmlSpec.js
@@ -0,0 +1,36 @@
+'use strict';
+
+describe('angular.scenario.output.json', function() {
+ var output, context;
+ var runner, model, $window;
+ var spec, step;
+
+ beforeEach(function() {
+ $window = {};
+ context = _jQuery('<div></div>');
+ runner = new angular.scenario.testing.MockRunner();
+ model = new angular.scenario.ObjectModel(runner);
+ output = angular.scenario.output.xml(context, runner, model);
+ spec = {
+ name: 'test spec',
+ definition: {
+ id: 10,
+ name: 'describe'
+ }
+ };
+ step = {
+ name: 'some step',
+ line: function() { return 'unknown:-1'; }
+ };
+ });
+
+ it('should create XML nodes for object model', function() {
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+ runner.emit('SpecEnd', spec);
+ runner.emit('RunnerEnd');
+ expect(context.find('it').attr('status')).toEqual('success');
+ expect(context.find('it step').attr('status')).toEqual('success');
+ });
+});