mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
browser = {
|
|
navigateTo: function(url){
|
|
$scenario.addStep('Navigate to: ' + url, function(done){
|
|
var self = this;
|
|
self.testFrame.load(function(){
|
|
self.testFrame.unbind();
|
|
self.testDocument = self.testWindow.angular.element(self.testWindow.document);
|
|
done();
|
|
});
|
|
if (this.testFrame.attr('src') == url) {
|
|
this.testWindow.location.reload();
|
|
} else {
|
|
this.testFrame.attr('src', url);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
function input(selector) {
|
|
return {
|
|
enter: function(value){
|
|
$scenario.addStep("Set input text of '" + selector + "' to value '" + value + "'", function(done){
|
|
var input = this.testDocument.find('input[name=' + selector + ']');
|
|
input.val(value);
|
|
input.trigger('change');
|
|
done();
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
function expect(selector) {
|
|
return {
|
|
toEqual: function(expected) {
|
|
$scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){
|
|
var attrName = selector.substring(2, selector.length - 2);
|
|
var binding = this.testDocument.find('span[ng-bind=' + attrName + ']');
|
|
if (binding.text() != expected) {
|
|
this.result.fail("Expected '" + expected + "' but was '" + binding.text() + "'");
|
|
}
|
|
done();
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
describe('widgets', function(){
|
|
it('should verify that basic widgets work', function(){
|
|
browser.navigateTo('widgets.html');
|
|
expect('{{text.basic}}').toEqual('');
|
|
input('text.basic').enter('John');
|
|
expect('{{text.basic}}').toEqual('JohnXX');
|
|
});
|
|
});
|