diff options
| author | Elliott Sprehn | 2010-10-24 14:14:45 -0700 |
|---|---|---|
| committer | Igor Minar | 2010-10-26 15:17:57 -0700 |
| commit | 40d7e66f408eaaa66efd8d7934ab2eb3324236a1 (patch) | |
| tree | daf88d70df9037416598307784eb83df93df4fed /test/scenario/ObjectModelSpec.js | |
| parent | 1d52349440d40de527b5d7f3849070f525c1b79b (diff) | |
| download | angular.js-40d7e66f408eaaa66efd8d7934ab2eb3324236a1.tar.bz2 | |
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
Diffstat (limited to 'test/scenario/ObjectModelSpec.js')
| -rw-r--r-- | test/scenario/ObjectModelSpec.js | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/test/scenario/ObjectModelSpec.js b/test/scenario/ObjectModelSpec.js new file mode 100644 index 00000000..8b83a52f --- /dev/null +++ b/test/scenario/ObjectModelSpec.js @@ -0,0 +1,112 @@ +describe('angular.scenario.ObjectModel', function() { + var model; + var runner; + var spec, step; + + beforeEach(function() { + spec = { + name: 'test spec', + definition: { + id: 10, + name: 'describe 1' + } + }; + step = { + name: 'test step', + line: function() { return ''; } + }; + runner = new angular.scenario.testing.MockRunner(); + model = new angular.scenario.ObjectModel(runner); + }); + + it('should value default empty value', function() { + expect(model.value).toEqual({ + name: '', + children: [] + }); + }); + + it('should add spec and create describe blocks on SpecBegin event', function() { + runner.emit('SpecBegin', { + name: 'test spec', + definition: { + id: 10, + name: 'describe 2', + parent: { + id: 12, + name: 'describe 1' + } + } + }); + + expect(model.value.children['describe 1']).toBeDefined(); + expect(model.value.children['describe 1'].children['describe 2']).toBeDefined(); + expect(model.value.children['describe 1'].children['describe 2'].specs['test spec']).toBeDefined(); + }); + + it('should add step to spec on StepBegin', function() { + runner.emit('SpecBegin', spec); + runner.emit('StepBegin', spec, step); + runner.emit('StepEnd', spec, step); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].steps.length).toEqual(1); + }); + + it('should update spec timer duration on SpecEnd event', function() { + runner.emit('SpecBegin', spec); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].duration).toBeDefined(); + }); + + it('should update step timer duration on StepEnd event', function() { + runner.emit('SpecBegin', spec); + runner.emit('StepBegin', spec, step); + runner.emit('StepEnd', spec, step); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].steps[0].duration).toBeDefined(); + }); + + it('should set spec status on SpecEnd to success if no status set', function() { + runner.emit('SpecBegin', spec); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].status).toEqual('success'); + }); + + it('should set status to error after SpecError', function() { + runner.emit('SpecBegin', spec); + runner.emit('SpecError', spec, 'error'); + + expect(model.value.children['describe 1'].specs['test spec'].status).toEqual('error'); + }); + + it('should set spec status to failure if step fails', function() { + runner.emit('SpecBegin', spec); + runner.emit('StepBegin', spec, step); + runner.emit('StepEnd', spec, step); + runner.emit('StepBegin', spec, step); + runner.emit('StepFailure', spec, step, 'error'); + runner.emit('StepEnd', spec, step); + runner.emit('StepBegin', spec, step); + runner.emit('StepEnd', spec, step); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].status).toEqual('failure'); + }); + + it('should set spec status to error if step errors', function() { + runner.emit('SpecBegin', spec); + runner.emit('StepBegin', spec, step); + runner.emit('StepError', spec, step, 'error'); + runner.emit('StepEnd', spec, step); + runner.emit('StepBegin', spec, step); + runner.emit('StepFailure', spec, step, 'error'); + runner.emit('StepEnd', spec, step); + runner.emit('SpecEnd', spec); + + expect(model.value.children['describe 1'].specs['test spec'].status).toEqual('error'); + }); +}); |
