1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
describe("DSL", function() {
var scenario, runner, $scenario, lastDocument, executeFuture;
beforeEach(function() {
scenario = {};
runner = new angular.scenario.Runner(scenario, _jQuery);
$scenario = scenario.$scenario;
executeFuture = function(future, html, callback) {
lastDocument =_jQuery('<div>' + html + '</div>');
_jQuery(document.body).append(lastDocument);
var specThis = {
testWindow: window,
testDocument: lastDocument
};
future.behavior.call(specThis, callback || noop);
};
});
describe("input", function() {
var input = angular.scenario.dsl.input;
it('should enter', function() {
var future = input('name').enter('John');
expect(future.name).toEqual("input 'name' enter 'John'");
executeFuture(future, '<input type="text" name="name" />');
expect(lastDocument.find('input').val()).toEqual('John');
});
it('should select', function() {
var future = input('gender').select('female');
expect(future.name).toEqual("input 'gender' select 'female'");
executeFuture(future,
'<input type="radio" name="0@gender" value="male" checked/>' +
'<input type="radio" name="0@gender" value="female"/>');
expect(lastDocument.find(':radio:checked').length).toEqual(1);
expect(lastDocument.find(':radio:checked').val()).toEqual('female');
});
});
describe('repeater', function() {
var repeater = angular.scenario.dsl.repeater;
it('should fetch the count of repeated elements', function() {
var future = repeater('.repeater-row').count();
expect(future.name).toEqual("repeater '.repeater-row' count");
executeFuture(future, "<div class='repeater-row'>a</div>" +
"<div class='repeater-row'>b</div>");
// Expect(future).toEqual(2);
});
});
});
|