aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVojta Jina2011-05-19 17:33:25 +0200
committerIgor Minar2011-05-19 09:43:56 -0700
commit1abdc097b235366759a889bdcc68359653a9b8a3 (patch)
treeed53346c171de6c60748e65c7f7f065cc8837103 /test
parent9f56af9c15e1096033c91c2619f7f7f0115d0032 (diff)
downloadangular.js-1abdc097b235366759a889bdcc68359653a9b8a3.tar.bz2
JSTD adapter for running e2e tests
Couple of changes into angular.scenario runner: - add autotest config (runs tests when document ready) - update ObjectModel (forwards events) - use only one ObjectModel instance for all outputters - expose error msg and line number in ObjectModel.Spec and ObjectModel.Step - fix generating spec.ids - fix 'html' output so that it does not mutate ObjectModel Couple of changes into docs / generator: - rename copy -> copyTpl - move docs/static into docs/examples (to avoid conflict with jstd proxy) Running all docs e2e tests: ======================================================== 1/ compile angular-scenario, jstd-scenario-adapter >> rake compile 2/ build docs >> rake docs 3/ start jstd server >> ./server-scenario.sh 4/ capture some browser 5/ run node server to serve static content >> node ../lib/nodeserver/server.js 6/ run tests >> ./test-scenario.sh
Diffstat (limited to 'test')
-rw-r--r--test/jstd-scenario-adapter/AdapterSpecs.js320
-rw-r--r--test/scenario/DescribeSpec.js10
-rw-r--r--test/scenario/ObjectModelSpec.js257
-rw-r--r--test/scenario/output/HtmlSpec.js5
-rw-r--r--test/scenario/output/jsonSpec.js5
-rw-r--r--test/scenario/output/objectSpec.js5
-rw-r--r--test/scenario/output/xmlSpec.js5
7 files changed, 580 insertions, 27 deletions
diff --git a/test/jstd-scenario-adapter/AdapterSpecs.js b/test/jstd-scenario-adapter/AdapterSpecs.js
new file mode 100644
index 00000000..ccf08e3d
--- /dev/null
+++ b/test/jstd-scenario-adapter/AdapterSpecs.js
@@ -0,0 +1,320 @@
+describe('jstd-adapter', function() {
+ var fakeJSTD = { pluginRegistrar: { register: function() {} } },
+ originalNavigateTo = angular.scenario.Application.prototype.navigateTo;
+
+ /**
+ * Reverts hack on angular.scenario.Application.navigateTo
+ * We should revert this hack after any single call of initScenarioAdapter,
+ * so that it doesn't influence other tests...
+ */
+ function revertNavigateToHack() {
+ angular.scenario.Application.prototype.navigateTo = originalNavigateTo;
+ }
+
+ /**
+ * Helper for building angular.scenario.ObjectModel.Spec
+ * @returns {angular.scenario.ObjectModel.Spec}
+ */
+ function buildSpec(status, name, duration, definitions, error, line) {
+ var spec = new angular.scenario.ObjectModel.Spec(
+ 'fake-id', name || 'name', definitions || ['desc1', 'desc2']);
+ spec.duration = duration || 10;
+ spec.status = status || 'success';
+ spec.error = error || '';
+ spec.line = line || '';
+
+ return spec;
+ }
+
+ /**
+ * Helper for building angular.scenario.ObjectModel.Spec with error and error line
+ * @returns {angular.scenario.ObjectModel.Spec}
+ */
+ function buildErrorSpec(error, line, status, name) {
+ return buildSpec(status || 'error', name, null, null, error, line);
+ }
+
+ /**
+ * Helper for building TestConfiguration
+ * @returns {jstestdriver.TestRunConfiguration}
+ */
+ function buildTestConf(type) {
+ return new jstestdriver.TestRunConfiguration(
+ new jstestdriver.TestCaseInfo('Fake test - ' + Math.random(), function(){}, type), null);
+ }
+
+ /**
+ * Helper for building SCENARIO TestConfiguration
+ * @returns {jstestdriver.TestRunConfiguration}
+ */
+ function buildScenarioTestConf() {
+ return buildTestConf(SCENARIO_TYPE);
+ }
+
+ describe('initScenarioAdapter', function() {
+ afterEach(revertNavigateToHack);
+
+ it('should create and register plugin if jstestdriver defined', function() {
+ spyOn(fakeJSTD.pluginRegistrar, 'register');
+ initScenarioAdapter(fakeJSTD);
+ expect(fakeJSTD.pluginRegistrar.register).toHaveBeenCalled();
+ expect(fakeJSTD.pluginRegistrar.register.mostRecentCall.args[0] instanceof JstdPlugin);
+ });
+
+ it('should do nothing if jstestdriver not defined', function() {
+ expect(function() {
+ initScenarioAdapter(undefined);
+ }).not.toThrow();
+ });
+
+ it('should set setUpAndRun callback to plugin', function() {
+ var runFn = jasmine.createSpy('setUpAndRun');
+ plugin.runScenario = null;
+
+ initScenarioAdapter(fakeJSTD, runFn);
+ expect(plugin.runScenario).toBe(runFn);
+ });
+
+ describe('navigateTo', function() {
+ var fakeJSTD = { pluginRegistrar: { register: function() {} } },
+ app = new angular.scenario.Application(_jQuery('<div></div>')),
+ navigateSpy;
+
+ beforeEach(function() {
+ navigateSpy = spyOn(angular.scenario.Application.prototype, 'navigateTo');
+ });
+
+ it('should add url prefix when jstd defined', function() {
+ initScenarioAdapter(fakeJSTD, null, {relativeUrlPrefix: '/prefix/'});
+
+ app.navigateTo('test.html');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('/prefix/test.html');
+ });
+
+ it('should add forward-slash as default url prefix when jstd defined', function() {
+ initScenarioAdapter(fakeJSTD);
+
+ app.navigateTo('test.html');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('/test.html');
+ });
+
+ it('should not change url when jstd not defined', function() {
+ initScenarioAdapter(null);
+
+ app.navigateTo('test.html');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('test.html');
+ });
+
+ it('should not change hash url', function() {
+ initScenarioAdapter(fakeJSTD);
+
+ app.navigateTo('#/index.html/a');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('#/index.html/a');
+ });
+
+ it('should not change absolute url', function() {
+ initScenarioAdapter(fakeJSTD);
+
+ app.navigateTo('/index.html/a');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('/index.html/a');
+ });
+
+ it('should not change "about:blank" url', function() {
+ initScenarioAdapter(fakeJSTD);
+
+ app.navigateTo('about:blank');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('about:blank');
+ });
+
+ it('should not change url with domain', function() {
+ initScenarioAdapter(fakeJSTD);
+
+ app.navigateTo('http://www.google.com');
+ expect(navigateSpy).toHaveBeenCalled();
+ expect(navigateSpy.mostRecentCall.args[0]).toEqual('http://www.google.com');
+ });
+ });
+ });
+
+ describe('JstdPlugin', function() {
+ var p;
+
+ beforeEach(function() {
+ p = new JstdPlugin();
+ });
+
+ describe('runTestConfiguration', function() {
+ var initScenarioSpy, onTestSpy, onAllTestsSpy, spec, modelSpec;
+
+ beforeEach(function() {
+ initScenarioSpy = jasmine.createSpy('initScenarioAndRun');
+ onTestSpy = jasmine.createSpy('onOneTest');
+ onAllTestsSpy = jasmine.createSpy('onAllTests');
+
+ p.runScenario = initScenarioSpy;
+ spec = {id: 'fake', name: 'Spec Name'};
+ modelSpec = new angular.scenario.ObjectModel.Spec(spec.id, spec.name);
+ });
+
+ it('should ignore non scenario test cases', function() {
+ expect(p.runTestConfiguration(buildTestConf(), onTestSpy, onAllTestsSpy)).toBe(false);
+ expect(p.runTestConfiguration(buildTestConf('async'), onTestSpy, onAllTestsSpy)).toBe(false);
+ expect(initScenarioSpy).not.toHaveBeenCalled();
+ expect(onTestSpy).not.toHaveBeenCalled();
+ expect(onAllTestsSpy).not.toHaveBeenCalled();
+ });
+
+ it('should return true when scenario test case', function() {
+ expect(p.runTestConfiguration(buildScenarioTestConf(), onTestSpy, onAllTestsSpy)).toBe(true);
+ });
+
+ it('should call initAndRunTests when scenario test case', function() {
+ p.runTestConfiguration(buildScenarioTestConf(), onTestSpy, onAllTestsSpy);
+ expect(initScenarioSpy).toHaveBeenCalled();
+ });
+ });
+
+ describe('getTestRunsConfigurationFor', function() {
+ it('should add TestRunConfiguration with SCENARIO_TYPE TestCase', function() {
+ var configurations = [];
+ p.getTestRunsConfigurationFor(null, null, configurations);
+
+ expect(configurations.length).toBe(1);
+ expect(configurations[0] instanceof jstestdriver.TestRunConfiguration).toBe(true);
+ expect(configurations[0].getTestCaseInfo().getType()).toEqual(SCENARIO_TYPE);
+ });
+
+ it('should always return true', function() {
+ expect(p.getTestRunsConfigurationFor(null, null, [])).toBe(true);
+ });
+ });
+ });
+
+ describe('createTestResultFromSpec', function() {
+ it('should return jstestdriver.TestResult instance', function() {
+ expect(createTestResultFromSpec(buildSpec()) instanceof jstestdriver.TestResult).toBe(true);
+ });
+
+ it('should set proper test name', function() {
+ expect(createTestResultFromSpec(buildSpec()).testName).toEqual('name');
+ });
+
+ it('should set duration', function() {
+ expect(createTestResultFromSpec(buildSpec()).time).toEqual(10);
+ });
+
+ it('should set test case - full definition name', function() {
+ var spec = buildSpec();
+ expect(createTestResultFromSpec(spec).testCaseName).toEqual(spec.fullDefinitionName);
+ });
+
+ it('should set passed result when success', function() {
+ expect(createTestResultFromSpec(buildSpec('success')).result)
+ .toEqual(jstestdriver.TestResult.RESULT.PASSED);
+ });
+
+ it('should set error result when error', function() {
+ expect(createTestResultFromSpec(buildSpec('error')).result)
+ .toEqual(jstestdriver.TestResult.RESULT.ERROR);
+ });
+
+ it('should set failed result when failure', function() {
+ expect(createTestResultFromSpec(buildSpec('failure')).result)
+ .toEqual(jstestdriver.TestResult.RESULT.FAILED);
+ });
+
+ it('should set error message when error/failure', function() {
+ expect(createTestResultFromSpec(buildErrorSpec('error-message')).message)
+ .toEqual('error-message');
+ });
+
+ it('should log line number when error/failure', function() {
+ expect(createTestResultFromSpec(buildErrorSpec('msg', 'line-number')).log)
+ .toEqual('line-number');
+ });
+ });
+
+ describe('angular.scenario.output.jstd', function() {
+ var model;
+
+ beforeEach(function() {
+ var runner = new angular.scenario.testing.MockRunner(),
+ context = _jQuery("<div></div>");
+
+ plugin = new JstdPlugin();
+ model = new angular.scenario.ObjectModel(runner);
+ angular.scenario.output.jstd(context, runner, model);
+
+ spyOn(plugin, 'reportEnd');
+ spyOn(plugin, 'reportResult');
+ });
+
+ it('should report end of all tests', function() {
+ model.emit('RunnerEnd');
+ expect(plugin.reportEnd).toHaveBeenCalled();
+ });
+
+ it('should report jstestdriver.TestResult', function() {
+ model.emit('SpecEnd', buildSpec());
+ expect(plugin.reportResult).toHaveBeenCalled();
+ expect(plugin.reportResult.argsForCall[0][0] instanceof jstestdriver.TestResult).toBe(true);
+ });
+ });
+
+ // couple of higher level tests (wiring objects together)
+ describe('HIGHER LEVEL', function() {
+ var initScenarioSpy, onTestSpy, onAllTestsSpy, model;
+
+ beforeEach(function() {
+ plugin = new JstdPlugin();
+ initScenarioSpy = jasmine.createSpy('initScenarioAndRun');
+ onTestSpy = jasmine.createSpy('onOneTest');
+ onAllTestsSpy = jasmine.createSpy('onAllTests');
+
+ var runner = new angular.scenario.testing.MockRunner(),
+ context = _jQuery("<div></div>");
+
+ model = new angular.scenario.ObjectModel(runner);
+ angular.scenario.output.jstd(context, runner, model);
+
+ initScenarioAdapter(fakeJSTD, initScenarioSpy);
+ plugin.runTestConfiguration(buildScenarioTestConf(), onTestSpy, onAllTestsSpy);
+ });
+
+ afterEach(revertNavigateToHack);
+
+ it('should report and of test suite', function() {
+ model.emit('RunnerEnd');
+ expect(onAllTestsSpy).toHaveBeenCalled();
+ });
+
+ it('should report success test result', function() {
+ model.emit('SpecEnd', buildSpec('success', 'name'));
+ expect(onTestSpy).toHaveBeenCalled();
+ var result = onTestSpy.argsForCall[0][0];
+ expect(result instanceof jstestdriver.TestResult).toBe(true);
+ expect(result.testName).toEqual('name');
+ expect(result.result).toEqual(jstestdriver.TestResult.RESULT.PASSED);
+ });
+
+ it('should report error test result', function() {
+ model.emit('SpecEnd', buildSpec('error'));
+ expect(onTestSpy).toHaveBeenCalled();
+ var result = onTestSpy.argsForCall[0][0];
+ expect(result.result).toEqual(jstestdriver.TestResult.RESULT.ERROR);
+ });
+
+ it('should report failed test result', function() {
+ model.emit('SpecEnd', buildSpec('failure'));
+ expect(onTestSpy).toHaveBeenCalled();
+ var result = onTestSpy.argsForCall[0][0];
+ expect(result.result).toEqual(jstestdriver.TestResult.RESULT.FAILED);
+ });
+ });
+});
diff --git a/test/scenario/DescribeSpec.js b/test/scenario/DescribeSpec.js
index 6fcee731..0322b2d4 100644
--- a/test/scenario/DescribeSpec.js
+++ b/test/scenario/DescribeSpec.js
@@ -107,4 +107,14 @@ describe('angular.scenario.Describe', function() {
var b = new angular.scenario.Describe();
expect(a.id).toNotEqual(b.id);
});
+
+ it('should create uniqueIds for each spec', function() {
+ var d = new angular.scenario.Describe();
+ d.it('fake', function() {});
+ d.it('fake', function() {});
+
+ expect(d.its[0].id).toBeDefined();
+ expect(d.its[1].id).toBeDefined();
+ expect(d.its[0].id).not.toEqual(d.its[1].id);
+ });
});
diff --git a/test/scenario/ObjectModelSpec.js b/test/scenario/ObjectModelSpec.js
index 8b83a52f..cb84b33f 100644
--- a/test/scenario/ObjectModelSpec.js
+++ b/test/scenario/ObjectModelSpec.js
@@ -3,18 +3,36 @@ describe('angular.scenario.ObjectModel', function() {
var runner;
var spec, step;
- beforeEach(function() {
- spec = {
- name: 'test spec',
+ function buildSpec(id, name, definitions) {
+ var spec = {
+ id: id,
+ name: name,
definition: {
- id: 10,
- name: 'describe 1'
+ name: definitions.shift()
}
};
- step = {
- name: 'test step',
- line: function() { return ''; }
+ var currentDef = spec.definition;
+
+ forEach(definitions, function(defName) {
+ currentDef.parent = {
+ name: defName
+ };
+ currentDef = currentDef.parent;
+ });
+
+ return spec;
+ }
+
+ function buildStep(name, line) {
+ return {
+ name: name || 'test step',
+ line: function() { return line || ''; }
};
+ }
+
+ beforeEach(function() {
+ spec = buildSpec(1, 'test spec', ['describe 1']);
+ step = buildStep();
runner = new angular.scenario.testing.MockRunner();
model = new angular.scenario.ObjectModel(runner);
});
@@ -27,23 +45,28 @@ describe('angular.scenario.ObjectModel', function() {
});
it('should add spec and create describe blocks on SpecBegin event', function() {
- runner.emit('SpecBegin', {
- name: 'test spec',
- definition: {
- id: 10,
- name: 'describe 2',
- parent: {
- id: 12,
- name: 'describe 1'
- }
- }
- });
+ runner.emit('SpecBegin', buildSpec(1, 'test spec', ['describe 2', 'describe 1']));
expect(model.value.children['describe 1']).toBeDefined();
expect(model.value.children['describe 1'].children['describe 2']).toBeDefined();
expect(model.value.children['describe 1'].children['describe 2'].specs['test spec']).toBeDefined();
});
+ it('should set fullDefinitionName on SpecBegin event', function() {
+ runner.emit('SpecBegin', buildSpec(1, 'fake spec', ['describe 2']));
+ var spec = model.getSpec(1);
+
+ expect(spec.fullDefinitionName).toBeDefined();
+ expect(spec.fullDefinitionName).toEqual('describe 2');
+ });
+
+ it('should set fullDefinitionName on SpecBegin event (join more names by space)', function() {
+ runner.emit('SpecBegin', buildSpec(1, 'fake spec', ['describe 2', 'describe 1']));
+ var spec = model.getSpec(1);
+
+ expect(spec.fullDefinitionName).toEqual('describe 1 describe 2');
+ });
+
it('should add step to spec on StepBegin', function() {
runner.emit('SpecBegin', spec);
runner.emit('StepBegin', spec, step);
@@ -109,4 +132,200 @@ describe('angular.scenario.ObjectModel', function() {
expect(model.value.children['describe 1'].specs['test spec'].status).toEqual('error');
});
+
+ describe('events', function() {
+ var Spec = angular.scenario.ObjectModel.Spec,
+ Step = angular.scenario.ObjectModel.Step,
+ callback;
+
+ beforeEach(function() {
+ callback = jasmine.createSpy('listener');
+ });
+
+ it('should provide method for registering a listener', function() {
+ expect(model.on).toBeDefined();
+ expect(model.on instanceof Function).toBe(true);
+ });
+
+ it('should forward SpecBegin event', function() {
+ model.on('SpecBegin', callback);
+ runner.emit('SpecBegin', spec);
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward SpecBegin event with ObjectModel.Spec as a param', function() {
+ model.on('SpecBegin', callback);
+ runner.emit('SpecBegin', spec);
+
+ expect(callback.mostRecentCall.args[0] instanceof Spec).toBe(true);
+ expect(callback.mostRecentCall.args[0].name).toEqual(spec.name);
+ });
+
+ it('should forward SpecError event', function() {
+ model.on('SpecError', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecError', spec, {});
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward SpecError event with ObjectModel.Spec and error as a params', function() {
+ var error = {};
+ model.on('SpecError', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecError', spec, error);
+
+ var param = callback.mostRecentCall.args[0];
+ expect(param instanceof Spec).toBe(true);
+ expect(param.name).toEqual(spec.name);
+ expect(param.status).toEqual('error');
+ expect(param.error).toBe(error);
+ });
+
+ it('should forward SpecEnd event', function() {
+ model.on('SpecEnd', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecEnd', spec);
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward SpecEnd event with ObjectModel.Spec as a param', function() {
+ model.on('SpecEnd', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('SpecEnd', spec);
+
+ expect(callback.mostRecentCall.args[0] instanceof Spec).toBe(true);
+ expect(callback.mostRecentCall.args[0].name).toEqual(spec.name);
+ });
+
+ it('should forward StepBegin event', function() {
+ model.on('StepBegin', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward StepBegin event with Spec and Step as params', function() {
+ model.on('StepBegin', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+
+ var params = callback.mostRecentCall.args;
+ expect(params[0] instanceof Spec).toBe(true);
+ expect(params[0].name).toEqual(spec.name);
+ expect(params[1] instanceof Step).toBe(true);
+ });
+
+ it('should forward StepError event', function() {
+ model.on('StepError', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepError', spec, step, {});
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward StepError event with Spec, Step and error as params', function() {
+ var error = {};
+ model.on('StepError', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepError', spec, step, error);
+
+ var params = callback.mostRecentCall.args;
+ expect(params[0] instanceof Spec).toBe(true);
+ expect(params[0].name).toEqual(spec.name);
+ expect(params[1] instanceof Step).toBe(true);
+ expect(params[1].status).toEqual('error');
+ expect(params[2]).toBe(error);
+ });
+
+ it('should forward StepFailure event', function() {
+ model.on('StepFailure', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, {});
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward StepFailure event with Spec, Step and error as params', function() {
+ var error = {};
+ model.on('StepFailure', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, error);
+
+ var params = callback.mostRecentCall.args;
+ expect(params[0] instanceof Spec).toBe(true);
+ expect(params[0].name).toEqual(spec.name);
+ expect(params[1] instanceof Step).toBe(true);
+ expect(params[1].status).toEqual('failure');
+ expect(params[2]).toBe(error);
+ });
+
+ it('should forward StepEnd event', function() {
+ model.on('StepEnd', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should forward StepEnd event with Spec and Step as params', function() {
+ model.on('StepEnd', callback);
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepEnd', spec, step);
+
+ var params = callback.mostRecentCall.args;
+ expect(params[0] instanceof Spec).toBe(true);
+ expect(params[0].name).toEqual(spec.name);
+ expect(params[1] instanceof Step).toBe(true);
+ });
+
+ it('should forward RunnerEnd event', function() {
+ model.on('RunnerEnd', callback);
+ runner.emit('RunnerEnd');
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should set error of first failure', function() {
+ var error = 'first-error',
+ step2 = buildStep();
+
+ model.on('SpecEnd', function(spec) {
+ expect(spec.error).toBeDefined();
+ expect(spec.error).toBe(error);
+ });
+
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, error);
+ runner.emit('StepBegin', spec, step2);
+ runner.emit('StepFailure', spec, step2, 'second-error');
+ runner.emit('SpecEnd', spec);
+ });
+
+ it('should set line number of first failure', function() {
+ var step = buildStep('fake', 'first-line'),
+ step2 = buildStep('fake2', 'second-line');
+
+ model.on('SpecEnd', function(spec) {
+ expect(spec.line).toBeDefined();
+ expect(spec.line).toBe('first-line');
+ });
+
+ runner.emit('SpecBegin', spec);
+ runner.emit('StepBegin', spec, step);
+ runner.emit('StepFailure', spec, step, null);
+ runner.emit('StepBegin', spec, step2);
+ runner.emit('StepFailure', spec, step2, null);
+ runner.emit('SpecEnd', spec);
+ });
+ });
});
diff --git a/test/scenario/output/HtmlSpec.js b/test/scenario/output/HtmlSpec.js
index f973397e..6694bb45 100644
--- a/test/scenario/output/HtmlSpec.js
+++ b/test/scenario/output/HtmlSpec.js
@@ -1,5 +1,5 @@
describe('angular.scenario.output.html', function() {
- var runner, spec, listeners;
+ var runner, model, spec, listeners;
var ui, context;
beforeEach(function() {
@@ -22,8 +22,9 @@ describe('angular.scenario.output.html', function() {
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);
+ ui = angular.scenario.output.html(context, runner, model);
});
it('should create nested describe context', function() {
diff --git a/test/scenario/output/jsonSpec.js b/test/scenario/output/jsonSpec.js
index afc74a21..2c56b297 100644
--- a/test/scenario/output/jsonSpec.js
+++ b/test/scenario/output/jsonSpec.js
@@ -1,13 +1,14 @@
describe('angular.scenario.output.json', function() {
var output, context;
- var runner, $window;
+ var runner, model, $window;
var spec, step;
beforeEach(function() {
$window = {};
context = _jQuery('<div></div>');
runner = new angular.scenario.testing.MockRunner();
- output = angular.scenario.output.json(context, runner);
+ model = new angular.scenario.ObjectModel(runner);
+ output = angular.scenario.output.json(context, runner, model);
spec = {
name: 'test spec',
definition: {
diff --git a/test/scenario/output/objectSpec.js b/test/scenario/output/objectSpec.js
index 73c3dcf9..9fc2f7d4 100644
--- a/test/scenario/output/objectSpec.js
+++ b/test/scenario/output/objectSpec.js
@@ -1,13 +1,14 @@
describe('angular.scenario.output.object', function() {
var output;
- var runner, $window;
+ 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);
+ output = angular.scenario.output.object(null, runner, model);
spec = {
name: 'test spec',
definition: {
diff --git a/test/scenario/output/xmlSpec.js b/test/scenario/output/xmlSpec.js
index fbfabcc4..a0e92639 100644
--- a/test/scenario/output/xmlSpec.js
+++ b/test/scenario/output/xmlSpec.js
@@ -1,13 +1,14 @@
describe('angular.scenario.output.json', function() {
var output, context;
- var runner, $window;
+ var runner, model, $window;
var spec, step;
beforeEach(function() {
$window = {};
context = _jQuery('<div></div>');
runner = new angular.scenario.testing.MockRunner();
- output = angular.scenario.output.xml(context, runner);
+ model = new angular.scenario.ObjectModel(runner);
+ output = angular.scenario.output.xml(context, runner, model);
spec = {
name: 'test spec',
definition: {