Skip to content

Commit

Permalink
even better testing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Jul 3, 2017
1 parent a607652 commit 79c2e85
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/lib/index.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset='utf-8' />
<title>jssm 2.9.2 | Documentation</title>
<title>jssm 2.9.5 | Documentation</title>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
<link href='assets/style.css' type='text/css' rel='stylesheet' />
Expand All @@ -14,7 +14,7 @@
<div class='fixed xs-hide fix-3 overflow-auto max-height-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>jssm</h3>
<div class='mb1'><code>2.9.2</code></div>
<div class='mb1'><code>2.9.5</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jssm",
"version": "2.9.2",
"version": "2.9.5",
"engines": {
"node": ">=6.0.0"
},
Expand Down
66 changes: 66 additions & 0 deletions src/js/tests/general.js
Expand Up @@ -229,6 +229,72 @@ describe('Complex stop light', async it => {



describe('reports on actions', async it => {

const machine = new jssm.machine({
initial_state: 'off',
transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ]
});

it('that it has', t => t.is('number', typeof machine.current_action_for('power_on') ) );
it('that it doesn\'t have', t => t.is('undefined', typeof machine.current_action_for('power_left') ) );

});





describe('reports on action edges', async it => {

const machine = new jssm.machine({
initial_state: 'off',
transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ]
});

it('that it has', t => t.is('object', typeof machine.current_action_edge_for('power_on') ) );
it('that it doesn\'t have', t => t.is('undefined', typeof machine.current_action_edge_for('power_left') ) );

});





describe('reports on states', async it => {

const machine = new jssm.machine({
initial_state: 'off',
transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ]
});

it('that it has', t => t.is('object', typeof machine.state_for('off') ) );

it('that it doesn\'t have', t => t.throws(() => { machine.state_for('no such state'); }) );

});





describe('reports on transitions', async it => {

const machine = new jssm.machine({
initial_state: 'off',
transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ]
});

it('return type', t => t.is('object', typeof machine.list_transitions() ) );
it('correct entrance count', t => t.is(0, machine.list_transitions().entrances.length ) );
it('correct exit count', t => t.is(1, machine.list_transitions().exits.length ) );

});





describe('Illegal machines', async it => {


Expand Down

0 comments on commit 79c2e85

Please sign in to comment.