mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
Uses the Jasmine syntax for tests, ex:
describe('widgets', function() {
it('should verify that basic widgets work', function(){
navigateTo('widgets.html');
input('text.basic').enter('Carlos');
expect(binding('text.basic')).toEqual('Carlos');
input('text.basic').enter('Carlos Santana');
expect(binding('text.basic')).not().toEqual('Carlos Boozer');
input('text.password').enter('secret');
expect(binding('text.password')).toEqual('secret');
expect(binding('text.hidden')).toEqual('hiddenValue');
expect(binding('gender')).toEqual('male');
input('gender').select('female');
expect(binding('gender')).toEqual('female');
});
});
Note: To create new UI's implement the interface shown in angular.scenario.ui.Html.
22 lines
523 B
JavaScript
22 lines
523 B
JavaScript
/**
|
|
* A future action in a spec.
|
|
*/
|
|
angular.scenario.Future = function(name, behavior) {
|
|
this.name = name;
|
|
this.behavior = behavior;
|
|
this.fulfilled = false;
|
|
this.value = undefined;
|
|
};
|
|
|
|
/**
|
|
* Executes the behavior of the closure.
|
|
*
|
|
* @param {Function} Callback function(error, result)
|
|
*/
|
|
angular.scenario.Future.prototype.execute = function(doneFn) {
|
|
this.behavior(angular.bind(this, function(error, result) {
|
|
this.fulfilled = true;
|
|
this.value = error || result;
|
|
doneFn(error, result);
|
|
}));
|
|
};
|