Skip to content

Instantly share code, notes, and snippets.

@chimmelb
Last active April 15, 2020 18:02
Show Gist options
  • Save chimmelb/2c4aceef2ce378b20051901732642624 to your computer and use it in GitHub Desktop.
Save chimmelb/2c4aceef2ce378b20051901732642624 to your computer and use it in GitHub Desktop.
/**
* This is the test file that is run by Jest.
* It has the (single) setup for the actionhero instance
*/
import { Process, env, id, specHelper } from 'actionhero'
import createTests from './lib/create'
import updateTests from './lib/update'
const actionhero = new Process()
let api
describe('SmartLoad Templates', () => {
beforeAll(async () => {
await actionhero.start()
})
afterAll(async () => {
await actionhero.stop()
})
describe('Create', createTests)
describe('Update', updateTests)
})
/**
* group of tests just for create
*/
import { Process, env, id, specHelper, api } from 'actionhero'
export default () => {
let globalTemplateId: number
test('global template can be created', async () => {
const { template, error } = await specHelper.runAction('createTemplate', {
type: 'GlobalTemplate',
template: { name: 'K12Template' },
})
expect(error).toBeUndefined()
expect(template).toBeTruthy()
expect(template.id).toBeTruthy()
globalTemplateId = template.id
})
test('global template will error with the same name', async () => {
const { template, error } = await specHelper.runAction('createTemplate', {
type: 'GlobalTemplate',
template: {
name: 'K12Template',
},
})
expect(error).toContain('GlobalTemplate with that name already exists')
expect(template).toBeUndefined()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment