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/output/HtmlSpec.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/output/HtmlSpec.js')
| -rw-r--r-- | test/scenario/output/HtmlSpec.js | 124 | 
1 files changed, 124 insertions, 0 deletions
diff --git a/test/scenario/output/HtmlSpec.js b/test/scenario/output/HtmlSpec.js new file mode 100644 index 00000000..f5bb90b0 --- /dev/null +++ b/test/scenario/output/HtmlSpec.js @@ -0,0 +1,124 @@ +describe('angular.scenario.output.html', function() { +  var runner, spec, listeners; +  var ui, context; + +  beforeEach(function() { +    listeners = []; +    spec = { +      name: 'test spec', +      definition: { +        id: 10, +        name: 'child', +        children: [], +        parent: { +          id: 20, +          name: 'parent', +          children: [] +        } +      } +    }; +    step = { +      name: 'some step', +      line: function() { return 'unknown:-1'; }, +    }; +    runner = new angular.scenario.testing.MockRunner(); +    context = _jQuery("<div></div>"); +    ui = angular.scenario.output.html(context, runner); +  }); + +  it('should create nested describe context', function() { +    runner.emit('SpecBegin', spec); +    expect(context.find('#describe-20 #describe-10 > h2').text()). +      toEqual('describe: child'); +    expect(context.find('#describe-20 > h2').text()).toEqual('describe: parent'); +    expect(context.find('#describe-10 .tests > li .test-info .test-name').text()). +      toEqual('test spec'); +    expect(context.find('#describe-10 .tests > li').hasClass('status-pending')). +      toBeTruthy(); +  }); + +  it('should add link on InteractiveWait', function() { +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepEnd', spec, step); +    runner.emit('StepBegin', spec, step); +    runner.emit('InteractiveWait', spec, step); +    expect(context.find('.test-actions .test-title:first').text()).toEqual('some step'); +    expect(context.find('.test-actions .test-title:last').html()).toEqual( +      'waiting for you to <a href="javascript:resume()">resume</a>.' +    ); +  }); + +  it('should update totals when steps complete', function() { +    // Failure +    for (var i=0; i < 3; ++i) { +      runner.emit('SpecBegin', spec); +      runner.emit('StepBegin', spec, step); +      runner.emit('StepFailure', spec, step, 'error'); +      runner.emit('StepEnd', spec, step); +      runner.emit('SpecEnd', spec); +    } + +    // Error +    runner.emit('SpecBegin', spec); +    runner.emit('SpecError', spec, 'error'); +    runner.emit('SpecEnd', spec); + +    // Error +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepError', spec, step, 'error'); +    runner.emit('StepEnd', spec, step); +    runner.emit('SpecEnd', spec); + +    // Success +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepEnd', spec, step); +    runner.emit('SpecEnd', spec); + +    expect(parseInt(context.find('#status-legend .status-failure').text(), 10)). +      toEqual(3); +    expect(parseInt(context.find('#status-legend .status-error').text(), 10)). +      toEqual(2); +    expect(parseInt(context.find('#status-legend .status-success').text(), 10)). +      toEqual(1); +  }); + +  it('should update timer when test completes', function() { +    // Success +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepEnd', spec, step); +    runner.emit('SpecEnd', spec); + +    // Failure +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepFailure', spec, step, 'error'); +    runner.emit('StepEnd', spec, step); +    runner.emit('SpecEnd', spec); + +    // Error +    runner.emit('SpecBegin', spec); +    runner.emit('SpecError', spec, 'error'); +    runner.emit('SpecEnd', spec); + +    context.find('#describe-10 .tests > li .test-info .timer-result'). +      each(function(index, timer) { +        expect(timer.innerHTML).toMatch(/ms$/); +    }); +  }); + +  it('should include line if provided', function() { +    runner.emit('SpecBegin', spec); +    runner.emit('StepBegin', spec, step); +    runner.emit('StepFailure', spec, step, 'error'); +    runner.emit('StepEnd', spec, step); +    runner.emit('SpecEnd', spec); + +    var errorHtml = context.find('#describe-10 .tests li pre').html(); +    expect(errorHtml.indexOf('unknown:-1')).toEqual(0); +  }); + +});  | 
