angular.js/test/scenario/output/HtmlSpec.js
Igor Minar fe5240732d feat(strict mode): adding strict mode flag to all js files
the flag must be in all src and test files so that we get the benefit of
running in the strict mode even in jstd

the following script was used to modify all files:

for file in `find src test -name "*.js"`; do
  echo -e "'use strict';\n" > temp.txt
  cat $file >> temp.txt
  mv temp.txt $file
done
2011-07-18 12:12:55 -07:00

126 lines
3.9 KiB
JavaScript

'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);
});
});