|
39 | 39 | <script type="text/javascript" src="../src/scenario/SpecRunner.js"></script> |
40 | 40 | <script type="text/javascript" src="../src/scenario/dsl.js"></script> |
41 | 41 | <script type="text/javascript" src="../src/scenario/matchers.js"></script> |
| 42 | + <script type="text/javascript" src="../src/scenario/ObjectModel.js"></script> |
| 43 | + |
| 44 | + <script type="text/javascript" src="../src/scenario/output/Html.js"></script> |
| 45 | + <script type="text/javascript" src="../src/scenario/output/Object.js"></script> |
| 46 | + <script type="text/javascript" src="../src/scenario/output/Json.js"></script> |
| 47 | + <script type="text/javascript" src="../src/scenario/output/Xml.js"></script> |
42 | 48 |
|
43 | 49 | <script type="text/javascript" src="angular-mocks.js"></script> |
| 50 | + <script type="text/javascript" src="../test/scenario/mocks.js"></script> |
44 | 51 | <script type="text/javascript" src="testabilityPatch.js"></script> |
45 | 52 |
|
46 | 53 | <!-- include spec files here... --> |
47 | 54 | <script type="text/javascript"> |
48 | 55 | describe('manual', function(){ |
49 | | - var scope; |
| 56 | + var compile, model, element; |
50 | 57 |
|
51 | | - function compile(html, initialScope, parent) { |
| 58 | + beforeEach(function() { |
52 | 59 | var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget); |
53 | | - var element = self.element = jqLite(html); |
54 | | - scope = compiler.compile(element)(element); |
55 | | - |
56 | | - if (parent) parent.append(element); |
57 | | - |
58 | | - extend(scope, initialScope); |
59 | | - scope.$init(); |
60 | | - return {node:element, scope:scope}; |
61 | | - }; |
| 60 | + compile = function(html) { |
| 61 | + element = jqLite(html); |
| 62 | + model = compiler.compile(element)(element); |
| 63 | + model.$init(); |
| 64 | + return model; |
| 65 | + }; |
| 66 | + }); |
62 | 67 |
|
63 | | - it('should debug', function(){ |
64 | | - var x = compile( |
65 | | - '<select name="selection" ng:format="number">' + |
66 | | - '<option value="{{$index}}" ng:repeat="name in [\'A\', \'B\', \'C\']">{{name}}</option>' + |
67 | | - '</select>'); |
68 | | - expect(scope.selection).toEqual(undefined); |
| 68 | + it('should get called on form submit', function() { |
| 69 | + var scope = compile('<form action="" ng:submit="submitted = true">' + |
| 70 | + '<input type="submit"/>' + |
| 71 | + '</form>'); |
| 72 | + scope.$eval(); |
| 73 | + expect(scope.submitted).not.toBeDefined(); |
69 | 74 |
|
70 | | - browserTrigger(element[0].childNodes[2], 'change'); |
71 | | - expect(scope.selection).toEqual(1); |
| 75 | + browserTrigger(element.children()[0]); |
| 76 | + expect(scope.submitted).toEqual(true); |
| 77 | + }); |
| 78 | +}); |
72 | 79 |
|
73 | | - scope.selection = 2; |
74 | | - scope.$eval(); |
75 | | - expect(element[0].childNodes[3].selected).toEqual(true); |
| 80 | +describe('angular.scenario.output.json', function() { |
| 81 | + var output, context; |
| 82 | + var runner, $window; |
| 83 | + var spec, step; |
| 84 | + |
| 85 | + beforeEach(function() { |
| 86 | + $window = {}; |
| 87 | + context = _jQuery('<div>text</div>'); |
| 88 | + $(document.body).append(context); |
| 89 | + runner = new angular.scenario.testing.MockRunner(); |
| 90 | + output = angular.scenario.output.xml(context, runner); |
| 91 | + spec = { |
| 92 | + name: 'test spec', |
| 93 | + definition: { |
| 94 | + id: 10, |
| 95 | + name: 'describe' |
| 96 | + } |
| 97 | + }; |
| 98 | + step = { |
| 99 | + name: 'some step', |
| 100 | + line: function() { return 'unknown:-1'; } |
| 101 | + }; |
76 | 102 | }); |
77 | 103 |
|
78 | | - it('should reproduce', function(){ |
79 | | - var select = $('<select name=""><option>a</option></select>'); |
80 | | - var log = ''; |
81 | | - select.bind('change', function(){ log += 'change;'; }); |
82 | | - select.bind('click', function(){ log += 'click;'; }); |
83 | | - select.bind('keyup', function(){ log += 'keyup;'; }); |
84 | | - select[0].attachEvent('onchange', function(){ log += 'CHANGE;';}); |
85 | | - select[0].fireEvent('onfocusout'); |
86 | | - select[0].fireEvent('onchange'); |
87 | | - select[0].fireEvent('onclick'); |
88 | | - select[0].fireEvent('onkeyup'); |
89 | | - expect(log).toEqual('CHANGE;change;click;keyup;'); |
| 104 | + it('should create XML nodes for object model', function() { |
| 105 | + runner.emit('SpecBegin', spec); |
| 106 | + runner.emit('StepBegin', spec, step); |
| 107 | + runner.emit('StepEnd', spec, step); |
| 108 | + runner.emit('SpecEnd', spec); |
| 109 | + runner.emit('RunnerEnd'); |
| 110 | + expect(_jQuery(context).find('it').attr('status')).toEqual('success'); |
| 111 | + expect(_jQuery(context).find('it step').attr('status')).toEqual('success'); |
90 | 112 | }); |
91 | 113 | }); |
| 114 | + |
| 115 | + |
92 | 116 | </script> |
93 | 117 |
|
94 | 118 | </head> |
95 | 119 | <body> |
96 | 120 |
|
97 | 121 | <script type="text/javascript"> |
98 | 122 | jasmine.getEnv().addReporter(new jasmine.TrivialReporter()); |
99 | | - jasmine.getEnv().execute(); |
| 123 | + function run(){ |
| 124 | + jasmine.getEnv().execute(); |
| 125 | + } |
| 126 | + run(); |
100 | 127 | </script> |
101 | 128 |
|
102 | 129 | </body> |
|
0 commit comments