open-vault/ui/tests/unit/machines/replication-machine-test.js
Jordan Reimer 52fe56ec87
Eslint prefer-const (#17864)
* adds prefer-const to eslint config and runs fixer

* reverts unintended change
2022-11-09 15:15:31 -08:00

37 lines
1.2 KiB
JavaScript

import { module, test } from 'qunit';
import { Machine } from 'xstate';
import ReplicationMachineConfig from 'vault/machines/replication-machine';
module('Unit | Machine | replication-machine', function () {
const replicationMachine = Machine(ReplicationMachineConfig);
const testCases = [
{
currentState: replicationMachine.initialState,
event: 'ENABLEREPLICATION',
params: null,
expectedResults: {
value: 'details',
actions: [{ type: 'render', level: 'feature', component: 'wizard/replication-details' }],
},
},
{
currentState: 'details',
event: 'CONTINUE',
params: null,
expectedResults: {
value: 'complete',
actions: ['completeFeature'],
},
},
];
testCases.forEach((testCase) => {
test(`transition: ${testCase.event} for currentState ${testCase.currentState} and componentState ${testCase.params}`, function (assert) {
const result = replicationMachine.transition(testCase.currentState, testCase.event, testCase.params);
assert.strictEqual(result.value, testCase.expectedResults.value);
assert.deepEqual(result.actions, testCase.expectedResults.actions);
});
});
});