@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
42 lines (36 loc) • 1.49 kB
text/typescript
import { test, assert } from '@sprucelabs/test-utils'
import schemaGeneratorUtil from '../../features/schema/utilities/schemaGenerator.utility'
import AbstractSchemaTest from '../../tests/AbstractSchemaTest'
export default class DeletingOrphanedSchemaDefinitionsTest extends AbstractSchemaTest {
()
protected static async hasFunction() {
assert.isFunction(schemaGeneratorUtil.filterSchemaFilesBySchemaIds)
}
()
protected static async findsAllSchemas() {
const results = await schemaGeneratorUtil.filterSchemaFilesBySchemaIds(
this.resolveTestPath('orphaned_schemas'),
[
{ id: 'one', namespace: 'namespace', version: 'v2020_07_22' },
{ id: 'two' },
// it should camel case the namespace
{ id: 'three', namespace: 'Namespacetwo' },
{
id: 'four',
namespace: 'namespacetwo',
version: 'v2020_07_22',
},
]
)
assert.isEqual(results.length, 0)
}
()
protected static async findsOneMissing() {
const results = await schemaGeneratorUtil.filterSchemaFilesBySchemaIds(
this.resolveTestPath('orphaned_schemas'),
[{ id: 'one', namespace: 'namespace', version: 'v2020_07_22' }]
)
assert.isEqual(results.length, 3)
assert.doesInclude(results[0], /two\.schema\.[t|j]s/gi)
}
}