@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
54 lines (43 loc) • 1.76 kB
text/typescript
import { test, assert } from '@sprucelabs/test-utils'
import { errorAssert } from '@sprucelabs/test-utils'
import LintService from '../../../services/LintService'
import AbstractEventTest from '../../../tests/AbstractEventTest'
export default class SkillEmitsBootEventsTest extends AbstractEventTest {
protected static async beforeEach() {
await super.beforeEach()
LintService.enableLinting()
}
()
protected static async skillEmitsWillBootEvents() {
await this.installEventFeature('events')
const version = 'v2020_01_01'
await this.Action('event', 'listen').execute({
namespace: 'skill',
eventName: 'will-boot',
version,
})
await this.Service('build').build()
const response = await this.Action('skill', 'boot').execute({})
assert.isTruthy(response.errors)
errorAssert.assertError(response.errors[0], 'LISTENER_NOT_IMPLEMENTED')
}
()
protected static async skillEmitsDidBootEventsThatErrorAfterBoot() {
await this.installEventFeature('events')
this.disablePermissionSyncing()
const version = 'v2020_01_01'
await this.Action('event', 'listen').execute({
namespace: 'skill',
eventName: 'did-boot',
version,
})
await this.Service('build').build()
const response = await this.Action('skill', 'boot').execute({})
const err = await assert.doesThrowAsync(() => response.meta?.promise)
errorAssert.assertError(err, 'LISTENER_NOT_IMPLEMENTED')
}
private static disablePermissionSyncing() {
const env = this.Service('env')
env.set('SHOULD_REGISTER_PERMISSIONS', 'false')
}
}