@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
55 lines (42 loc) • 1.66 kB
text/typescript
import { test, assert } from '@sprucelabs/test-utils'
import { errorAssert } from '@sprucelabs/test-utils'
import AbstractSchemaTest from '../../tests/AbstractSchemaTest'
export default class FeatureCommandExecuterTest extends AbstractSchemaTest {
()
protected static async canInstantiateExecuter() {
const executer = this.Action('schema', 'create', {
shouldAutoHandleDependencies: true,
})
assert.isTruthy(executer)
}
()
protected static async throwWhenExecutingWhenMissingDependencies() {
const err = await assert.doesThrowAsync(() =>
this.Action('skill', 'create').execute({})
)
errorAssert.assertError(err, 'FEATURE_NOT_INSTALLED')
}
()
protected static async shouldAskAllQuestionsOfFeature() {
const executer = this.Action('skill', 'create', {
shouldAutoHandleDependencies: true,
})
const promise = executer.execute({})
await this.waitForInput()
await this.ui.sendInput('My new skill')
await this.ui.sendInput('So great!')
await promise
await this.assertHealthySkillNamed('my-new-skill')
}
()
protected static async shouldNotAskAlreadyAnsweredQuestions() {
const executer = this.Action('skill', 'create', {
shouldAutoHandleDependencies: true,
})
const promise = executer.execute({ description: 'go team!' })
await this.waitForInput()
void this.ui.sendInput('Already answered skill')
await promise
await this.assertHealthySkillNamed('already-answered-skill')
}
}