Skip to content

Commit 5215e20

Browse files
committed
basic end to end runner
1 parent 31b35b1 commit 5215e20

13 files changed

Lines changed: 284 additions & 273 deletions

css/angular-scenario.css

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22
/* CSS Document */
33

44
#runner {
5-
position: absolute;
6-
top:5px;
7-
left:10px;
5+
position: absolute;
6+
top:5px;
7+
left:10px;
88
right:10px;
99
height: 200px;
1010
}
1111

12+
.console {
13+
display: block;
14+
overflow: scroll;
15+
height: 200px;
16+
border: 1px solid black;
17+
}
18+
1219
#testView {
13-
position: absolute;
14-
bottom:10px;
15-
top:210px;
16-
left:10px;
20+
position: absolute;
21+
bottom:10px;
22+
top:230px;
23+
left:10px;
1724
right:10px;
1825
}
1926

@@ -22,12 +29,8 @@
2229
height: 100%;
2330
}
2431

25-
.console {
26-
display: block;
27-
overflow: scroll;
28-
height: 200px;
29-
border: 1px solid black;
30-
}
32+
33+
///////////////
3134

3235
.collapsed .log {
3336
display: none;

jsTestDriver-jquery.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ load:
66
- lib/jquery/jquery-1.4.2.js
77
- src/Angular.js
88
- src/*.js
9-
- src/scenario/_namespace.js
109
- src/scenario/*.js
1110
- test/testabilityPatch.js
1211
- test/angular-mocks.js

jsTestDriver.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ load:
66
# - lib/jquery/jquery-1.4.2.js
77
- src/Angular.js
88
- src/*.js
9-
- src/scenario/_namespace.js
109
- src/scenario/*.js
1110
- test/testabilityPatch.js
1211
- test/angular-mocks.js

scenario/Runner.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
33
<head>
44
<script type="text/javascript" src="../src/scenario/bootstrap.js"></script>
5-
<script type="text/javascript" src="widgets-scenarios.js"></script>
6-
<script type="text/javascript" src="datastore-scenarios.js"></script>
5+
<script type="text/javascript" src="widgets-scenario2.js"></script>
76
</head>
87
<body>
98
</body>

scenario/widgets-scenario2.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
browser = {
2+
navigateTo: function(url){
3+
$scenario.addStep('Navigate to: ' + url, function(done){
4+
var self = this;
5+
self.testFrame.load(function(){
6+
self.testFrame.unbind();
7+
self.testDocument = self.testWindow.angular.element(self.testWindow.document);
8+
done();
9+
});
10+
if (this.testFrame.attr('src') == url) {
11+
this.testWindow.location.reload();
12+
} else {
13+
this.testFrame.attr('src', url);
14+
}
15+
});
16+
}
17+
};
18+
19+
function input(selector) {
20+
return {
21+
enter: function(value){
22+
$scenario.addStep("Set input text of '" + selector + "' to value '" + value + "'", function(done){
23+
var input = this.testDocument.find('input[name=' + selector + ']');
24+
input.val(value);
25+
input.trigger('change');
26+
done();
27+
});
28+
}
29+
};
30+
}
31+
32+
function expect(selector) {
33+
return {
34+
toEqual: function(expected) {
35+
$scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){
36+
var attrName = selector.substring(2, selector.length - 2);
37+
var binding = this.testDocument.find('span[ng-bind=' + attrName + ']');
38+
if (binding.text() != expected) {
39+
this.result.fail("Expected '" + expected + "' but was '" + binding.text() + "'");
40+
}
41+
done();
42+
});
43+
}
44+
};
45+
}
46+
47+
describe('widgets', function(){
48+
it('should verify that basic widgets work', function(){
49+
browser.navigateTo('widgets.html');
50+
expect('{{text.basic}}').toEqual('');
51+
input('text.basic').enter('John');
52+
expect('{{text.basic}}').toEqual('JohnXX');
53+
});
54+
});

scenario/widgets-scenarios.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ angular.scenarioDef.widgets = {
33
{Given:"browser", at:"widgets.html"}
44
],
55
checkWidgetBinding:[
6-
{Then:"text", at:"{{name}}", should_be:""},
7-
{When:"enter", text:"John", at:":input[name=name]"},
8-
{Then:"text", at:"{{name}}", should_be:"John"},
9-
10-
{Then:"text", at:"{{gender}}", should_be:""},
11-
{When:"click", at:"input:radio[value=male]"},
6+
{Then:"text", at:"{{text.basic}}", should_be:""},
7+
{When:"enter", text:"John", at:":input[name=text.basic]"},
8+
{Then:"text", at:"{{text.basic}}", should_be:"John"},
9+
1210
{Then:"text", at:"{{gender}}", should_be:"male"},
13-
11+
{When:"click", at:"input:radio[value=female]"},
12+
{Then:"text", at:"{{gender}}", should_be:"female"},
13+
1414
{Then:"text", at:"{{tea}}", should_be:"on"},
1515
{When:"click", at:"input[name=tea]"},
1616
{Then:"text", at:"{{tea}}", should_be:""},
17-
17+
1818
{Then:"text", at:"{{coffee}}", should_be:""},
1919
{When:"click", at:"input[name=coffee]"},
2020
{Then:"text", at:"{{coffee}}", should_be:"on"},
21-
21+
2222
{Then:"text", at:"{{count}}", should_be:0},
2323
{When:"click", at:"form :button"},
2424
{When:"click", at:"form :submit"},
2525
{When:"click", at:"form :image"},
2626
{Then:"text", at:"{{count}}", should_be:3},
27-
27+
2828
{Then:"text", at:"{{select}}", should_be:"A"},
2929
{When:"select", at:"select[name=select]", option:"B"},
3030
{Then:"text", at:"{{select}}", should_be:"B"},
@@ -36,7 +36,7 @@ angular.scenarioDef.widgets = {
3636
{Then:"text", at:"{{multiple}}", should_be:["A", "B"]},
3737
{When:"select", at:"select[name=multiple]", option:"A"},
3838
{Then:"text", at:"{{multiple}}", should_be:["B"]},
39-
39+
4040
{Then:"text", at:"{{hidden}}", should_be:"hiddenValue"},
4141

4242
{Then:"text", at:"{{password}}", should_be:"passwordValue"},

scenario/widgets.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
<tr>
1717
<td>basic</td>
1818
<td>
19-
<input type="text" name="text.basic" ng-required ng-validate="number" ng-format="number"/>
20-
<input type="text" name="text.basic" ng-format="number"/>
19+
<input type="text" name="text.basic"/>
2120
</td>
2221
<td>text.basic={{text.basic}}</td>
2322
</tr>

0 commit comments

Comments
 (0)