diff --git a/src/pantograph/index.mjs b/src/pantograph/index.mjs index 6e143a7c..ae47a105 100644 --- a/src/pantograph/index.mjs +++ b/src/pantograph/index.mjs @@ -8,59 +8,17 @@ import { Signals } from 'shinkansen-signals' -const log = debug('shinkansen-pantograph/pantograph') - -const ALPHA = { - ERROR: 'ALPHA_ERROR', - ROUTE: 'ALPHA_ROUTE', - MOUNT: 'ALPHA_MOUNT', - FETCH: 'ALPHA_FETCH', - STORE: 'ALPHA_STORE', - QUERY: 'ALPHA_QUERY', - CHANGE: 'ALPHA_CHANGE', - SUBMIT: 'ALPHA_SUBMIT' -} - -const OMEGA = { - ERROR: 'OMEGA_ERROR', - ROUTE: 'OMEGA_ROUTE', - MOUNT: 'OMEGA_MOUNT', - FETCH: 'OMEGA_FETCH', - STORE: 'OMEGA_STORE', - QUERY: 'OMEGA_QUERY', - CHANGE: 'OMEGA_CHANGE', - SUBMIT: 'OMEGA_SUBMIT' -} - -const EMBARK = { - ERROR: 'EMBARK_ERROR', - ROUTE: 'EMBARK_ROUTE', - MOUNT: 'EMBARK_MOUNT', - FETCH: 'EMBARK_FETCH', - STORE: 'EMBARK_STORE', - CHANGE: 'EMBARK_CHANGE', - SUBMIT: 'EMBARK_SUBMIT' -} +import pantograph, { + ALPHA, + OMEGA, + EMBARK, + DEBARK, + CONFIRM +} from './pantograph.mjs' -const DEBARK = { - ERROR: 'DEBARK_ERROR', - ROUTE: 'DEBARK_ROUTE', - MOUNT: 'DEBARK_MOUNT', - FETCH: 'DEBARK_FETCH', - STORE: 'DEBARK_STORE', - CHANGE: 'DEBARK_CHANGE', - SUBMIT: 'DEBARK_SUBMIT' -} +const log = debug('shinkansen-pantograph/pantograph') -const CONFIRM = { - ERROR: 'CONFIRM_ERROR', - ROUTE: 'CONFIRM_ROUTE', - MOUNT: 'CONFIRM_MOUNT', - FETCH: 'CONFIRM_FETCH', - STORE: 'CONFIRM_STORE', - CHANGE: 'CONFIRM_CHANGE', - SUBMIT: 'CONFIRM_SUBMIT' -} +log('`shinkansen` is awake') const ACTION = {} @@ -68,8 +26,6 @@ const STATE = {} const ROUTE = {} -log('`shinkansen` is awake') - export function getRedirectToAlpha ({ alpha, route }) { log('getRedirectToAlpha') @@ -197,34 +153,4 @@ export function graphite ({ action: { type } = ACTION, state = STATE, route = RO } } -/** - * Getters without setters ensure that these fields are read-only - */ -class Pantograph { - static get ALPHA () { - return ALPHA - } - - static get OMEGA () { - return OMEGA - } - - static get EMBARK () { - return EMBARK - } - - static get DEBARK () { - return DEBARK - } - - static get CONFIRM () { - return CONFIRM - } - - static graphite = graphite -} - -/** - * As does `freeze` - */ -export default Object.freeze(Pantograph) +export default Object.freeze(pantograph) diff --git a/src/pantograph/pantograph.mjs b/src/pantograph/pantograph.mjs new file mode 100644 index 00000000..94d3b251 --- /dev/null +++ b/src/pantograph/pantograph.mjs @@ -0,0 +1,65 @@ +import debug from 'debug' + +const log = debug('shinkansen-pantograph/pantograph') + +log('`shinkansen` is awake') + +export const ALPHA = { + ERROR: 'ALPHA_ERROR', + ROUTE: 'ALPHA_ROUTE', + MOUNT: 'ALPHA_MOUNT', + FETCH: 'ALPHA_FETCH', + STORE: 'ALPHA_STORE', + QUERY: 'ALPHA_QUERY', + CHANGE: 'ALPHA_CHANGE', + SUBMIT: 'ALPHA_SUBMIT' +} + +export const OMEGA = { + ERROR: 'OMEGA_ERROR', + ROUTE: 'OMEGA_ROUTE', + MOUNT: 'OMEGA_MOUNT', + FETCH: 'OMEGA_FETCH', + STORE: 'OMEGA_STORE', + QUERY: 'OMEGA_QUERY', + CHANGE: 'OMEGA_CHANGE', + SUBMIT: 'OMEGA_SUBMIT' +} + +export const EMBARK = { + ERROR: 'EMBARK_ERROR', + ROUTE: 'EMBARK_ROUTE', + MOUNT: 'EMBARK_MOUNT', + FETCH: 'EMBARK_FETCH', + STORE: 'EMBARK_STORE', + CHANGE: 'EMBARK_CHANGE', + SUBMIT: 'EMBARK_SUBMIT' +} + +export const DEBARK = { + ERROR: 'DEBARK_ERROR', + ROUTE: 'DEBARK_ROUTE', + MOUNT: 'DEBARK_MOUNT', + FETCH: 'DEBARK_FETCH', + STORE: 'DEBARK_STORE', + CHANGE: 'DEBARK_CHANGE', + SUBMIT: 'DEBARK_SUBMIT' +} + +export const CONFIRM = { + ERROR: 'CONFIRM_ERROR', + ROUTE: 'CONFIRM_ROUTE', + MOUNT: 'CONFIRM_MOUNT', + FETCH: 'CONFIRM_FETCH', + STORE: 'CONFIRM_STORE', + CHANGE: 'CONFIRM_CHANGE', + SUBMIT: 'CONFIRM_SUBMIT' +} + +export default { + ALPHA, + OMEGA, + EMBARK, + DEBARK, + CONFIRM +} diff --git a/test/pantograph/index.spec.mjs b/test/pantograph/index.spec.mjs index 9507ba17..b354a65f 100644 --- a/test/pantograph/index.spec.mjs +++ b/test/pantograph/index.spec.mjs @@ -28,9 +28,9 @@ import Pantograph, { chai.use(sinonChai) describe('shinkansen-pantograph/pantograph', () => { - it('is a function', () => { + it('is an object', () => { return expect(Pantograph) - .to.be.a('function') + .to.be.an('object') }) describe('`Pantograph.ALPHA`', () => { @@ -512,9 +512,9 @@ describe('shinkansen-pantograph/pantograph', () => { }) }) - describe('`Pantograph.graphite`', () => { + describe('`graphite`', () => { it('is a function', () => { - return expect(Pantograph.graphite) + return expect(graphite) .to.be.a('function') }) })