Skip to content

Commit

Permalink
Add test for inner scenario context prototype chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavey committed Aug 4, 2011
1 parent 45cc8cb commit 750ccae
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/Witness.Specs/OuterScenario.coffee
Expand Up @@ -125,6 +125,53 @@ describe "OuterScenario",
inner1ThenCalled: should.be true
doneCalled: should.be true
},
{
"given an OuterScenario in 'do all' mode, with two inner scenarios": ->
testContext = this
parts =
given: [ {
description: "given"
actions: [ new witness.Action (-> testContext.outerContext = this) ]
} ]

dispose: []

innerScenarios = [
new witness.Scenario({
given: [ {
description: "given"
actions: [ new witness.Action (-> testContext.innerContext1 = this) ]
} ]
when: []
then: []
}),
new witness.Scenario({
given: [ {
description: "given"
actions: [ new witness.Action (-> testContext.innerContext2 = this) ]
} ]
when: []
then: []
})
]
@outerScenario = new witness.OuterScenario parts, "all", innerScenarios

"when it is run": async ->
@outerScenario.run {},
(=> @done())
(=> @done())

"then outer and inner contexts are different objects": ->
@outerContext != @innerContext1 and
@outerContext != @innerContext2 and
@innerContext1 != @innerContext2

"then outer context is prototype of inner context 1": ->
@innerContext1.prototype == @outerContext

"then outer context is prototype of inner context 2": ->
@innerContext2.prototype == @outerContext
},
{
"given an OuterScenario with event handlers added": ->
parts =
Expand Down

0 comments on commit 750ccae

Please sign in to comment.