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
15 changed files
with
157 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Node files | ||
npm-debug.log | ||
node_modules | ||
report | ||
|
||
# IDE files | ||
.idea | ||
|
||
# CI files | ||
.travis.yml | ||
.istanbul.yml | ||
|
||
# Other | ||
.gitignore |
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,10 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [0.1.0] | ||
### Added | ||
|
||
- Initial implementation accessible via `.run()` interface |
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,25 @@ | ||
# Internals | ||
|
||
## Architecture in two minutes | ||
|
||
There are several entities in project: | ||
|
||
- Scenario: a tree graph of states that transition on into another. | ||
- Execution: object representing current scenario execution, contains | ||
scenario itself, runtime, state-machine, dealas with launching state | ||
machine and executing things not related to states (e.g. termination | ||
handler) | ||
- ExecutionRuntime: an object that is supplied as 'this' to state | ||
transitions - basically this is just a sack of properties and helper | ||
methods. | ||
- State machine is a class that diverged from execution and is | ||
basically a state scheduler. Execution had started to bloat up, so i've | ||
decided to separate those concerns. | ||
- Normalizer takes in scenario and tries to bring it in most | ||
schema-compliant way, wrapping everything in promises, filling missed | ||
things, etc. | ||
- Validator validates that scenario is compliant with schema nd is | ||
runnable. | ||
- Utility modules supply boring helper functions, concurrent module is | ||
a little bit, and i don't fully understand how some things have ended | ||
there D: |
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
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
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,59 @@ | ||
var framework = require('../../lib/index'), | ||
chai = require('chai'), | ||
assert = chai.assert; | ||
|
||
describe('/index.js', function () { | ||
|
||
var scenario = { | ||
states: [ | ||
{ | ||
id: 'entrypoint', | ||
entrypoint: true, | ||
transition: {trigger: 'terminated'} | ||
}, | ||
{ | ||
id: 'terminated', | ||
terminal: true | ||
} | ||
], | ||
trigger: framework.TriggerType.Http | ||
}, | ||
_engine = typeof VoxEngine === 'undefined' ? undefined : VoxEngine, | ||
_logger = typeof Logger === 'undefined' ? undefined : Logger, | ||
_events = typeof AppEvents === 'undefined' ? undefined : AppEvents; | ||
|
||
beforeEach(function () { | ||
VoxEngine = { | ||
addEventListener: function (_, listener) { | ||
listener(); | ||
}, | ||
customData: function () { | ||
return ''; | ||
} | ||
}; | ||
Logger = { | ||
write: function () {} | ||
}; | ||
AppEvents = { | ||
Started: function () {} | ||
} | ||
}); | ||
|
||
afterEach(function () { | ||
VoxEngine = _engine; | ||
Logger = _logger; | ||
AppEvents = _events; | ||
}); | ||
|
||
describe('.run', function () { | ||
it('should run scenario from index.js without hassle', function () { | ||
return framework.run(scenario); | ||
}); | ||
}); | ||
|
||
describe('.validate', function () { | ||
it('should not throw any exception during regular call', function () { | ||
assert(framework.validate(scenario)); | ||
}); | ||
}); | ||
}); |
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