@plugola/test
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@johngeorgewright/test

Test plugola plugins

Example

testPlugin({
  pluginContext(pluginName) {
    return { pluginName }
  },

  testContext() {
    return {
      mung: {},
      $i: new Invokables<{ mung: { args: []; return: unknown } }>(),
    }
  },

  initContext() {
    return {}
  },

  runContext() {
    return {}
  },

  afterRun({ $i }) {
    return $i.start()
  },

  tests: {
    'pluginContext is different for each plugin': [
      // ARRAY OF PLUGINS
      {
        name: 'test',
        run({ pluginName }) {
          expect(pluginName).toBe('test')
        },
      },
      {
        name: 'test 2',
        run({ pluginName }) {
          expect(pluginName).toBe('test 2')
        },
      },
    ],

    'testContext is the same for every plugin': [
      // ARRAY OF PLUGINS
      {
        name: 'test',
        run({ $i, mung }) {
          $i.register('mung', () => mung)
        },
      },
      {
        name: 'test 2',
        async run({ $i, mung }) {
          expect(await $i.invoke('mung')).toBe(mung)
        },
      },
    ],
  },
})

Readme

Keywords

none

Package Sidebar

Install

npm i @plugola/test

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

10.6 kB

Total Files

15

Last publish

Collaborators

  • johngeorgewright