Skip to content

Commit

Permalink
Merge pull request matthewp#184 from gkiely/bugfix/tests
Browse files Browse the repository at this point in the history
Fixed test, removed duplicate test, fix CI
  • Loading branch information
gkiely authored Jan 27, 2023
2 parents 9fde607 + 78b0c44 commit ebf53a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Puppeteer Container
uses: ianwalter/puppeteer@v2.0.0
uses: ianwalter/puppeteer@v4.0.0
- name: npm install, build, and test
run: |
npm ci
Expand Down
27 changes: 2 additions & 25 deletions test/test-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,13 @@ QUnit.test('Errors if an invalid initial state is provided', assert => {

QUnit.test('Errors when no transitions for event from the current state', assert => {
try {
const {send} = createMachine('one', {
const machine = createMachine('one', {
one: state(),
});
const { send } = interpret(machine, () => {});
send('go');
assert.ok(false, 'should have failed');
} catch(e) {
assert.ok(true, 'it is errored');
}
});

QUnit.test('Calls the onEnter function if the state is changed', assert => {
const machine = createMachine({
one: state(
transition('go', 'two', reduce((ctx) => (
{ ...ctx, x: 1 }
)))
),
two: state()
}, () => ({x: 0, y: 0}));

const service = interpret(machine, () => {});
const enterFN = (m, to, state, prevState, event) => {
assert.deepEqual(m, machine, 'Machines equal');
assert.deepEqual(state, {x:1, y:0}, 'Changed state passed.')
assert.deepEqual(prevState, {x:0, y:0}, 'Previous state passed.')
assert.equal(to, 'two', 'To state passed.')
assert.equal(event, 'go', 'Send event passed.')
}

d._onEnter = enterFN;

service.send('go');
});

0 comments on commit ebf53a6

Please sign in to comment.