mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
Polish the Scenario Runner UI to include: - a scroll pane that steps appear in since the list can be very long - Collapse successful tests - Show the line where the DSL statements were when there's an error (Chrome, Firefox) Also: - Remove lots angular.bind calls to reduce the amount of stack space used. - Use setTimeout(...,0) to schedule the next future to let the browser breathe and have it repaint the steps. Also prevents overflowing the stack when an it() creates many futures. - Run afterEach() handlers even if the it() block fails. - Make navigateTo() take a function as the second argument so you can compute a URL in the future. - Add wait() DSL statement to allow interactive debugging of tests. - Allow custom jQuery selectors with element(...).query(fn) DSL statement. Known Issues: - All afterEach() handlers run even if a beforeEach() handler fails. Only after handlers for the same level as the failure and above should run.
98 lines
2.8 KiB
JavaScript
98 lines
2.8 KiB
JavaScript
describe('angular.scenario.HtmlUI', function() {
|
|
var ui;
|
|
var context;
|
|
var spec;
|
|
|
|
function line() { return 'unknown:-1'; }
|
|
|
|
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');
|
|
// Failure
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish('failure');
|
|
specUI.finish();
|
|
// Failure
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish('failure');
|
|
specUI.finish();
|
|
// Failure
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish('failure');
|
|
specUI.finish();
|
|
// Success
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish();
|
|
specUI.finish();
|
|
// Success
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('another step', line).finish();
|
|
specUI.finish();
|
|
|
|
expect(parseInt(context.find('#status-legend .status-failure').text(), 10)).
|
|
toEqual(3);
|
|
expect(parseInt(context.find('#status-legend .status-success').text(), 10)).
|
|
toEqual(2);
|
|
expect(parseInt(context.find('#status-legend .status-error').text(), 10)).
|
|
toEqual(1);
|
|
});
|
|
|
|
it('should update timer when test completes', function() {
|
|
// Success
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish();
|
|
specUI.finish();
|
|
|
|
// Failure
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).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$/);
|
|
});
|
|
});
|
|
|
|
it('should include line if provided', function() {
|
|
specUI = ui.addSpec(spec);
|
|
specUI.addStep('some step', line).finish('error!');
|
|
specUI.finish();
|
|
|
|
var errorHtml = context.find('#describe-10 .tests li pre').html();
|
|
expect(errorHtml.indexOf('unknown:-1')).toEqual(0);
|
|
});
|
|
|
|
});
|