mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-10 07:44:43 +00:00
add repeater DSL and fix typo
This commit is contained in:
parent
cb5d211927
commit
fe03ea0d1f
3 changed files with 29 additions and 14 deletions
|
|
@ -44,17 +44,20 @@ angular.scenario.dsl.input = function(selector) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
angular.scenario.dsl.expect = function(selector) {
|
angular.scenario.dsl.expect = {
|
||||||
return {
|
repeater: function(selector) {
|
||||||
toEqual: function(expected) {
|
return {
|
||||||
$scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){
|
count: {
|
||||||
var attrName = selector.substring(2, selector.length - 2);
|
toEqual: function(number) {
|
||||||
var binding = this.testDocument.find('span[ng-bind=' + attrName + ']');
|
$scenario.addStep("Expect to see " + number + " items repeated with selector '" + selector + "'", function(done) {
|
||||||
if (binding.text() != expected) {
|
var items = this.testDocument.find(selector);
|
||||||
this.result.fail("Expected '" + expected + "' but was '" + binding.text() + "'");
|
if (items.length != number) {
|
||||||
|
this.result.fail("Expected " + number + " but was " + items.length);
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
done();
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,16 @@ describe("DSL", function() {
|
||||||
expect(lastDocument.find(':radio:checked').val()).toEqual('female');
|
expect(lastDocument.find(':radio:checked').val()).toEqual('female');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
describe('expect', function() {
|
||||||
|
var dslExpect = angular.scenario.dsl.expect;
|
||||||
|
describe('repeater', function() {
|
||||||
|
it('should check the count of repeated elements', function() {
|
||||||
|
dslExpect.repeater('.repeater-row').count.toEqual(2);
|
||||||
|
expect(lastStep.name).toEqual("Expect to see 2 items repeated with selector '.repeater-row'");
|
||||||
|
var html = "<div class='repeater-row'>a</div><div class='repeater-row'>b</div>";
|
||||||
|
executeStep(lastStep, html);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ describe('Runner', function(){
|
||||||
expect(spec.name).toEqual('describe name: it should text');
|
expect(spec.name).toEqual('describe name: it should text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should camplain on duplicate it', angular.noop);
|
it('should complain on duplicate it', angular.noop);
|
||||||
it('should create a failing step if there is a javascript error', function(){
|
it('should create a failing step if there is a javascript error', function(){
|
||||||
var spec;
|
var spec;
|
||||||
Describe('D1', function(){
|
Describe('D1', function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue