-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'); | ||
|
||
var sm = require('../lib/statemutate.js') | ||
|
||
vows.describe('With basic state projection').addBatch({ | ||
'When no initital state defined and no elements arranged': { | ||
topic: function () { | ||
var sut = new sm.Projections(); | ||
return sut; | ||
}, | ||
'we get a empty string as final state': function (topic) { | ||
assert.equal(topic.perform(), ''); | ||
} | ||
}, | ||
'When a simple initial state and a element added': { | ||
topic: function () { | ||
var sut = new sm.Projections(); | ||
sut | ||
.append({ | ||
payload: 'tests' | ||
}) | ||
.for({ | ||
text: '' | ||
}) | ||
.with(function(state, message) { | ||
state.text += message.payload; | ||
return state; | ||
}) | ||
return sut.perform(); | ||
}, | ||
|
||
'we get other final state': { | ||
'has a final "test" state': function (topic) { | ||
assert.equal(topic.text, 'test'); | ||
}, | ||
'is not a empty string': function (topic) { | ||
assert.notEqual(topic, ''); | ||
} | ||
} | ||
} | ||
}).export(module); |