UNPKG

core-graphics

Version:

A core library for creating shape-based graphic editors

67 lines (47 loc) 2.09 kB
'use strict'; var _tap = require('tap'); var _eventSourcing = require('./event-sourcing'); var ALICE = 'Alice'; var BOB = 'Bob'; var EVE = 'Eve'; var TEST_HISTORY = [{ id: '0', author: ALICE, applied: true, payload: { some: 'payload' } }, { id: '1', author: BOB, applied: false, payload: { some: 'payload' } }, { id: '2', author: BOB, applied: false, payload: { some: 'payload' } }, { id: '3', author: ALICE, applied: true, payload: { some: 'payload' } }, { id: '4', author: ALICE, applied: false, payload: { some: 'payload' } }, { id: '5', author: EVE, applied: true, payload: { some: 'payload' } }, { id: '6', author: EVE, applied: true, payload: { some: 'payload' } }, { id: '7', author: ALICE, applied: false, payload: { some: 'payload' } }]; // GET UNDO (0, _tap.test)('getUndoEvent 0', function (t) { t.equal((0, _eventSourcing.getUndoEvent)([], ALICE), null); t.end(); }); (0, _tap.test)('getUndoEvent 1', function (t) { var expected = TEST_HISTORY[3]; // .id === '3' t.deepEqual((0, _eventSourcing.getUndoEvent)(TEST_HISTORY, ALICE), expected); t.end(); }); (0, _tap.test)('getUndoEvent 2', function (t) { var expected = null; t.deepEqual((0, _eventSourcing.getUndoEvent)(TEST_HISTORY, BOB), expected); t.end(); }); (0, _tap.test)('getUndoEvent 3', function (t) { var expected = TEST_HISTORY[6]; t.deepEqual((0, _eventSourcing.getUndoEvent)(TEST_HISTORY, EVE), expected); t.end(); }); // GET REDO (0, _tap.test)('getRedoEvent 0', function (t) { t.deepEqual((0, _eventSourcing.getRedoEvent)([], ALICE), null); t.end(); }); (0, _tap.test)('getRedoEvent 1', function (t) { var expected = TEST_HISTORY[4]; t.deepEqual((0, _eventSourcing.getRedoEvent)(TEST_HISTORY, ALICE), expected); t.end(); }); (0, _tap.test)('getRedoEvent 2', function (t) { var expected = TEST_HISTORY[1]; t.deepEqual((0, _eventSourcing.getRedoEvent)(TEST_HISTORY, BOB), expected); t.end(); }); (0, _tap.test)('getRedoEvent 3', function (t) { var expected = null; t.deepEqual((0, _eventSourcing.getRedoEvent)(TEST_HISTORY, EVE), expected); t.end(); });