mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
parent
9250fce19c
commit
1eebb771e3
5 changed files with 21 additions and 21 deletions
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
/**
|
||||
* Usage:
|
||||
* wait() waits until you call resume() in the console
|
||||
* pause() pauses until you call resume() in the console
|
||||
*/
|
||||
angular.scenario.dsl('wait', function() {
|
||||
angular.scenario.dsl('pause', function() {
|
||||
return function() {
|
||||
return this.addFuture('waiting for you to resume', function(done) {
|
||||
this.emit('InteractiveWait', this.spec, this.step);
|
||||
return this.addFuture('pausing for you to resume', function(done) {
|
||||
this.emit('InteractivePause', this.spec, this.step);
|
||||
this.$window.resume = function() { done(); };
|
||||
});
|
||||
};
|
||||
|
|
@ -17,11 +17,11 @@ angular.scenario.dsl('wait', function() {
|
|||
|
||||
/**
|
||||
* Usage:
|
||||
* pause(seconds) pauses the test for specified number of seconds
|
||||
* sleep(seconds) pauses the test for specified number of seconds
|
||||
*/
|
||||
angular.scenario.dsl('pause', function() {
|
||||
angular.scenario.dsl('sleep', function() {
|
||||
return function(time) {
|
||||
return this.addFuture('pause for ' + time + ' seconds', function(done) {
|
||||
return this.addFuture('sleep for ' + time + ' seconds', function(done) {
|
||||
this.$window.setTimeout(function() { done(null, time * 1000); }, time * 1000);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ angular.scenario.output('html', function(context, runner, model) {
|
|||
'</div>'
|
||||
);
|
||||
|
||||
runner.on('InteractiveWait', function(spec, step) {
|
||||
runner.on('InteractivePause', function(spec, step) {
|
||||
var ui = lastStepUiMap[spec.id];
|
||||
ui.find('.test-title').
|
||||
html('waiting for you to <a href="javascript:resume()">resume</a>.');
|
||||
html('paused... <a href="javascript:resume()">resume</a> when ready.');
|
||||
});
|
||||
|
||||
runner.on('SpecBegin', function(spec) {
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ extend(angularValidator, {
|
|||
expect(textBox.attr('className')).not().toMatch(/ng-validation-error/);
|
||||
input('text').enter('X');
|
||||
expect(textBox.attr('className')).toMatch(/ng-input-indicator-wait/);
|
||||
pause(.6);
|
||||
sleep(.6);
|
||||
expect(textBox.attr('className')).not().toMatch(/ng-input-indicator-wait/);
|
||||
expect(textBox.attr('className')).toMatch(/ng-validation-error/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,20 +46,20 @@ describe("angular.scenario.dsl", function() {
|
|||
SpecRunner.prototype.addFutureAction;
|
||||
});
|
||||
|
||||
describe('Wait', function() {
|
||||
it('should wait until resume to complete', function() {
|
||||
describe('Pause', function() {
|
||||
it('should pause until resume to complete', function() {
|
||||
expect($window.resume).toBeUndefined();
|
||||
$root.dsl.wait();
|
||||
$root.dsl.pause();
|
||||
expect(angular.isFunction($window.resume)).toBeTruthy();
|
||||
expect($root.futureLog).toEqual([]);
|
||||
$window.resume();
|
||||
expect($root.futureLog).
|
||||
toEqual(['waiting for you to resume']);
|
||||
expect(eventLog).toContain('InteractiveWait');
|
||||
toEqual(['pausing for you to resume']);
|
||||
expect(eventLog).toContain('InteractivePause');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pause', function() {
|
||||
describe('Sleep', function() {
|
||||
beforeEach(function() {
|
||||
$root.$window.setTimeout = function(fn, value) {
|
||||
$root.timerValue = value;
|
||||
|
|
@ -67,8 +67,8 @@ describe("angular.scenario.dsl", function() {
|
|||
};
|
||||
});
|
||||
|
||||
it('should pause for specified seconds', function() {
|
||||
$root.dsl.pause(10);
|
||||
it('should sleep for specified seconds', function() {
|
||||
$root.dsl.sleep(10);
|
||||
expect($root.timerValue).toEqual(10000);
|
||||
expect($root.futureResult).toEqual(10000);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ describe('angular.scenario.output.html', function() {
|
|||
toBeTruthy();
|
||||
});
|
||||
|
||||
it('should add link on InteractiveWait', function() {
|
||||
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('InteractiveWait', 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(
|
||||
'waiting for you to <a href="javascript:resume()">resume</a>.'
|
||||
'paused... <a href="javascript:resume()">resume</a> when ready.'
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue