@sprucelabs/spruce-cli 24.0.0 → 24.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/build/InFlightEntertainment.d.ts +2 -2
- package/build/__tests__/behavioral/DeployingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js.map +1 -1
- package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js +2 -2
- package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js.map +1 -1
- package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js +1 -1
- package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js.map +1 -1
- package/build/__tests__/behavioral/conversations/TestingAConversation.test.js +5 -5
- package/build/__tests__/behavioral/conversations/TestingAConversation.test.js.map +1 -1
- package/build/__tests__/behavioral/lint/LintService.test.js.map +1 -1
- package/build/__tests__/behavioral/node/CreatingANodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js.map +1 -1
- package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/CreatingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/RebuildingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.d.ts +11 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js +49 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.d.ts +5 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js +34 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.d.ts +12 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js +88 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.d.ts +13 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js +109 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.d.ts +4 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js +29 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.d.ts +29 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js +300 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.d.ts +26 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js +202 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.d.ts +2 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js +51 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js.map +1 -0
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingANodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingANonSpruceNodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill3.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill4.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill5.test.js.map +1 -1
- package/build/__tests__/behavioral/versions/ResolvingVersions.test.js +0 -3
- package/build/__tests__/behavioral/versions/ResolvingVersions.test.js.map +1 -1
- package/build/__tests__/behavioral/views/WatchingSkillViews.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter2.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter4.test.js.map +1 -1
- package/build/__tests__/implementation/FeatureInstaller.test.js.map +1 -1
- package/build/__tests__/implementation/OrganizationStore.test.js +2 -2
- package/build/__tests__/implementation/OrganizationStore.test.js.map +1 -1
- package/build/__tests__/implementation/PkgService.test.js.map +1 -1
- package/build/__tests__/implementation/StoreFeature.test.js.map +1 -1
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
- package/build/boot.js.map +1 -1
- package/build/features/skill/actions/BootAction.js.map +1 -1
- package/build/features/test/TestRunner.d.ts +2 -2
- package/build/features/test/TestRunner.js.map +1 -1
- package/build/features/test/actions/CreateAction.d.ts +1 -0
- package/build/features/test/actions/CreateAction.js +13 -0
- package/build/features/test/actions/CreateAction.js.map +1 -1
- package/build/features/test/actions/MigrateAction.d.ts +17 -0
- package/build/features/test/actions/MigrateAction.js +42 -0
- package/build/features/test/actions/MigrateAction.js.map +1 -0
- package/build/features/vscode/services/VsCodeService.d.ts +2 -2
- package/build/features/vscode/services/VsCodeService.js.map +1 -1
- package/build/services/BuildService.d.ts +2 -2
- package/build/services/BuildService.js.map +1 -1
- package/build/services/CommandService.d.ts +20 -12
- package/build/services/CommandService.js +4 -4
- package/build/services/CommandService.js.map +1 -1
- package/build/services/GameService.d.ts +2 -2
- package/build/services/GameService.js.map +1 -1
- package/build/services/ImportService.d.ts +2 -2
- package/build/services/ImportService.js.map +1 -1
- package/build/services/LintService.d.ts +1 -1
- package/build/services/PkgService.d.ts +2 -2
- package/build/services/PkgService.js.map +1 -1
- package/build/services/ServiceFactory.d.ts +2 -2
- package/build/services/ServiceFactory.js.map +1 -1
- package/build/tests/AbstractCliTest.js.map +1 -1
- package/build/tests/CommandFaker.js.map +1 -1
- package/build/tests/staticToInstanceMigration/StaticTestFinder.d.ts +8 -0
- package/build/tests/staticToInstanceMigration/StaticTestFinder.js +23 -0
- package/build/tests/staticToInstanceMigration/StaticTestFinder.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.d.ts +61 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js +55 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.d.ts +12 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js +138 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js.map +1 -0
- package/package.json +27 -27
- package/src/InFlightEntertainment.ts +2 -2
- package/src/__tests__/behavioral/DeployingASkill.test.ts +26 -23
- package/src/__tests__/behavioral/EnablingAndDisablingCache.test.ts +13 -13
- package/src/__tests__/behavioral/conversations/CreatingAConversationTopic.test.ts +2 -2
- package/src/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.ts +1 -1
- package/src/__tests__/behavioral/conversations/TestingAConversation.test.ts +5 -5
- package/src/__tests__/behavioral/lint/LintService.test.ts +3 -3
- package/src/__tests__/behavioral/node/CreatingANodeModule.test.ts +2 -2
- package/src/__tests__/behavioral/onboard/StartingOnboarding.test.ts +2 -2
- package/src/__tests__/behavioral/organization/CreatingAnOrg.test.ts +0 -1
- package/src/__tests__/behavioral/skill/CreatingASkill.test.ts +2 -2
- package/src/__tests__/behavioral/skill/RebuildingASkill.test.ts +3 -3
- package/src/__tests__/behavioral/stores/CreatingADataStore.test.ts +3 -3
- package/src/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.ts +77 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.ts +19 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.ts +99 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.ts +72 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.ts +31 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts +310 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.ts +193 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.ts +50 -0
- package/src/__tests__/behavioral/upgrading/UpdatingDependencies2.test.ts +3 -3
- package/src/__tests__/behavioral/upgrading/UpgradingANodeModule.test.ts +6 -6
- package/src/__tests__/behavioral/upgrading/UpgradingANonSpruceNodeModule.test.ts +4 -4
- package/src/__tests__/behavioral/upgrading/UpgradingASkill3.test.ts +9 -9
- package/src/__tests__/behavioral/upgrading/UpgradingASkill4.test.ts +4 -4
- package/src/__tests__/behavioral/upgrading/UpgradingASkill5.test.ts +4 -4
- package/src/__tests__/behavioral/versions/ResolvingVersions.test.ts +1 -3
- package/src/__tests__/behavioral/views/WatchingSkillViews.test.ts +2 -2
- package/src/__tests__/implementation/ActionExecuter2.test.ts +2 -2
- package/src/__tests__/implementation/ActionExecuter4.test.ts +3 -3
- package/src/__tests__/implementation/FeatureInstaller.test.ts +2 -2
- package/src/__tests__/implementation/OrganizationStore.test.ts +6 -2
- package/src/__tests__/implementation/PkgService.test.ts +3 -3
- package/src/__tests__/implementation/StoreFeature.test.ts +2 -2
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
- package/src/boot.ts +2 -2
- package/src/features/skill/actions/BootAction.ts +2 -2
- package/src/features/test/TestRunner.ts +3 -3
- package/src/features/test/actions/CreateAction.ts +17 -0
- package/src/features/test/actions/MigrateAction.ts +44 -0
- package/src/features/vscode/services/VsCodeService.ts +2 -2
- package/src/services/BuildService.ts +3 -3
- package/src/services/CommandService.ts +27 -14
- package/src/services/GameService.ts +3 -3
- package/src/services/ImportService.ts +3 -3
- package/src/services/LintService.ts +1 -1
- package/src/services/PkgService.ts +3 -3
- package/src/services/ServiceFactory.ts +6 -6
- package/src/tests/AbstractCliTest.ts +2 -2
- package/src/tests/CommandFaker.ts +4 -4
- package/src/tests/staticToInstanceMigration/StaticTestFinder.ts +25 -0
- package/src/tests/staticToInstanceMigration/StaticToInstanceMigrator.ts +83 -0
- package/src/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.ts +197 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import AbstractSpruceTest, {
|
|
2
|
+
test,
|
|
3
|
+
assert,
|
|
4
|
+
errorAssert,
|
|
5
|
+
suite,
|
|
6
|
+
} from '@sprucelabs/test-utils'
|
|
7
|
+
import StaticTestFinderImpl from '../../../../tests/staticToInstanceMigration/StaticTestFinder'
|
|
8
|
+
|
|
9
|
+
@suite()
|
|
10
|
+
export default class StaticTestFinderTest extends AbstractSpruceTest {
|
|
11
|
+
private finder: StaticTestFinderImpl = StaticTestFinderImpl.Finder()
|
|
12
|
+
private testPath?: string
|
|
13
|
+
|
|
14
|
+
@test()
|
|
15
|
+
protected async throwsWithMissing() {
|
|
16
|
+
//@ts-ignore
|
|
17
|
+
const err = await assert.doesThrowAsync(() => this.finder.find())
|
|
18
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
19
|
+
parameters: ['lookupDir'],
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@test()
|
|
24
|
+
protected async matchesStaticTests1() {
|
|
25
|
+
this.setTestMigrationDir('static_test_migration_1')
|
|
26
|
+
await this.assertFindResultsEqual([
|
|
27
|
+
'AnotherStaticTest.test.ts',
|
|
28
|
+
'StaticTest1.test.ts',
|
|
29
|
+
])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@test()
|
|
33
|
+
protected async matchesStaticTests2() {
|
|
34
|
+
this.setTestMigrationDir('static_test_migration_2')
|
|
35
|
+
await this.assertFindResultsEqual([
|
|
36
|
+
'AStaticTest.test.ts',
|
|
37
|
+
'AnotherStaticTest1.test.ts',
|
|
38
|
+
])
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@test()
|
|
42
|
+
protected async includesAbstractTestsInOtherDirectories() {
|
|
43
|
+
this.setTestMigrationDir('static_test_migration_3')
|
|
44
|
+
await this.assertFindResultsEqual([
|
|
45
|
+
'AbstractWhateverTest.ts',
|
|
46
|
+
'AStaticTest2.test.ts',
|
|
47
|
+
])
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private async assertFindResultsEqual(files: string[]) {
|
|
51
|
+
const results = await this.find()
|
|
52
|
+
const expected = files.map((file) => this.resolveStaticTestFile(file))
|
|
53
|
+
assert.isEqualDeep(results, expected)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private async find() {
|
|
57
|
+
return await this.finder.find(this.testPath!)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private resolveStaticTestFile(file: string) {
|
|
61
|
+
return this.resolvePath(this.testPath!, 'src', '__tests__', file)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private setTestMigrationDir(dirName: string) {
|
|
65
|
+
this.testPath = this.resolvePath(
|
|
66
|
+
'build',
|
|
67
|
+
'__tests__',
|
|
68
|
+
'testDirsAndFiles',
|
|
69
|
+
dirName
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import { test } from '@sprucelabs/test-utils'
|
|
3
|
+
import AbstractInstanceTest from './AbstractInstanceTest'
|
|
4
|
+
import { generateExpectedStaticTestContents } from './testFileContentsGenerators'
|
|
5
|
+
|
|
6
|
+
export default class StaticTestsWhenAlreadyExistsTest extends AbstractInstanceTest {
|
|
7
|
+
@test()
|
|
8
|
+
protected static async canCreateStaticTestsWhenAlreadyExists() {
|
|
9
|
+
const testFile =
|
|
10
|
+
await this.createTestAndGetCreatedFilePath('AFirstTest')
|
|
11
|
+
|
|
12
|
+
diskUtil.writeFile(
|
|
13
|
+
testFile,
|
|
14
|
+
generateExpectedStaticTestContents('AFirstTest')
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
await this.createTestAndAssertContentsEqual(
|
|
18
|
+
'ASecondTest',
|
|
19
|
+
generateExpectedStaticTestContents('ASecondTest'),
|
|
20
|
+
true
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
diskUtil.deleteFile(testFile)
|
|
24
|
+
|
|
25
|
+
await this.createTestAndAssertContentsEqual(
|
|
26
|
+
'AThirdTest',
|
|
27
|
+
generateExpectedStaticTestContents('AThirdTest'),
|
|
28
|
+
true
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import AbstractSpruceTest, {
|
|
2
|
+
test,
|
|
3
|
+
assert,
|
|
4
|
+
errorAssert,
|
|
5
|
+
suite,
|
|
6
|
+
generateId,
|
|
7
|
+
} from '@sprucelabs/test-utils'
|
|
8
|
+
import {
|
|
9
|
+
CommandService,
|
|
10
|
+
ExecuteCommandOptions,
|
|
11
|
+
} from '../../../../services/CommandService'
|
|
12
|
+
import LintService from '../../../../services/LintService'
|
|
13
|
+
import StaticTestFinderImpl, {
|
|
14
|
+
StaticTestFinder,
|
|
15
|
+
} from '../../../../tests/staticToInstanceMigration/StaticTestFinder'
|
|
16
|
+
import StaticToInstanceMigratorImpl, {
|
|
17
|
+
StaticToInstanceMigrator,
|
|
18
|
+
} from '../../../../tests/staticToInstanceMigration/StaticToInstanceMigrator'
|
|
19
|
+
import StaticToInstanceTestFileMigratorImpl, {
|
|
20
|
+
StaticToInstanceTestFileMigrator,
|
|
21
|
+
} from '../../../../tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator'
|
|
22
|
+
|
|
23
|
+
@suite()
|
|
24
|
+
export default class StaticToInstanceMigratorTest extends AbstractSpruceTest {
|
|
25
|
+
private testFinder: FakeStaticTestFinder
|
|
26
|
+
private testFileMigrator: FakeFileMigrator
|
|
27
|
+
private migrator: StaticToInstanceMigrator
|
|
28
|
+
private readFiles: string[] = []
|
|
29
|
+
private fakedFileContents: Record<string, string> = {}
|
|
30
|
+
private lastWrittenFile?: { destination: string; contents: string }
|
|
31
|
+
private spyCommandService: SpyCommandService
|
|
32
|
+
|
|
33
|
+
public constructor() {
|
|
34
|
+
super()
|
|
35
|
+
|
|
36
|
+
StaticTestFinderImpl.Class = FakeStaticTestFinder
|
|
37
|
+
StaticToInstanceTestFileMigratorImpl.Class = FakeFileMigrator
|
|
38
|
+
|
|
39
|
+
StaticToInstanceMigratorImpl.diskUtil.readFile = (source) => {
|
|
40
|
+
this.readFiles.push(source)
|
|
41
|
+
return this.fakedFileContents[source] ?? generateId()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
StaticToInstanceMigratorImpl.diskUtil.writeFile = (
|
|
45
|
+
destination: string,
|
|
46
|
+
contents: string
|
|
47
|
+
) => {
|
|
48
|
+
this.lastWrittenFile = {
|
|
49
|
+
destination,
|
|
50
|
+
contents,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.testFinder = StaticTestFinderImpl.Finder() as FakeStaticTestFinder
|
|
55
|
+
this.testFileMigrator =
|
|
56
|
+
StaticToInstanceTestFileMigratorImpl.Migrator() as FakeFileMigrator
|
|
57
|
+
this.spyCommandService = new SpyCommandService()
|
|
58
|
+
const lintService = new LintService(
|
|
59
|
+
this.cwd,
|
|
60
|
+
() => this.spyCommandService
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
this.migrator = StaticToInstanceMigratorImpl.Migrator({
|
|
64
|
+
testFinder: this.testFinder,
|
|
65
|
+
testFileMigrator: this.testFileMigrator,
|
|
66
|
+
lintService,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@test()
|
|
71
|
+
protected throwsWithMissing() {
|
|
72
|
+
const err = assert.doesThrow(() =>
|
|
73
|
+
//@ts-ignore
|
|
74
|
+
StaticToInstanceMigratorImpl.Migrator()
|
|
75
|
+
)
|
|
76
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
77
|
+
parameters: ['testFinder', 'testFileMigrator', 'lintService'],
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@test()
|
|
82
|
+
protected async runThrowsWithMissing() {
|
|
83
|
+
//@ts-ignore
|
|
84
|
+
const err = await assert.doesThrowAsync(() => this.migrator.run())
|
|
85
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
86
|
+
parameters: ['lookupDir'],
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@test()
|
|
91
|
+
protected async passesLookupDirToTestFinder() {
|
|
92
|
+
const path = generateId()
|
|
93
|
+
await this.run(path)
|
|
94
|
+
assert.isEqual(this.testFinder.lastLookupDir, path)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@test('returns stats based on 3 tests found', ['a', 'b', 'c'])
|
|
98
|
+
@test('returns stats based on 0 tests found', [])
|
|
99
|
+
protected async returnsStatsBasedOnTestsFound(results: string[]) {
|
|
100
|
+
this.setFakedFinderResults(results)
|
|
101
|
+
const stats = await this.run()
|
|
102
|
+
assert.isEqualDeep(stats, {
|
|
103
|
+
totalTestsUpdated: this.testFinder.fakedResults.length,
|
|
104
|
+
totalTestsSkipped: 0,
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@test('passes one files contents to migrator', 'a')
|
|
109
|
+
@test('passes another files contents to migrator', 'b')
|
|
110
|
+
protected async passesOneFilesContentsToMigrator(filename: string) {
|
|
111
|
+
this.setFakedFinderResults([filename])
|
|
112
|
+
await this.run()
|
|
113
|
+
assert.isEqualDeep(this.readFiles, [filename])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@test()
|
|
117
|
+
protected async passesResultsOfFileToMigrator() {
|
|
118
|
+
this.setFakedFinderResults(['a'])
|
|
119
|
+
this.setFakedFileContents({
|
|
120
|
+
a: generateId(),
|
|
121
|
+
})
|
|
122
|
+
await this.run()
|
|
123
|
+
|
|
124
|
+
this.assertContentsPassedToFileMigratorEquals([
|
|
125
|
+
this.fakedFileContents['a'],
|
|
126
|
+
])
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@test()
|
|
130
|
+
protected async passesResultsOfMultipleFilesToMigrator() {
|
|
131
|
+
const contents1 = generateId()
|
|
132
|
+
const contents2 = generateId()
|
|
133
|
+
|
|
134
|
+
this.setFakedFinderResults(['what', 'the'])
|
|
135
|
+
|
|
136
|
+
this.setFakedFileContents({
|
|
137
|
+
what: contents1,
|
|
138
|
+
the: contents2,
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
await this.run()
|
|
142
|
+
|
|
143
|
+
this.assertContentsPassedToFileMigratorEquals([contents1, contents2])
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@test()
|
|
147
|
+
protected async writesResponseOfMigrate() {
|
|
148
|
+
const filename = generateId()
|
|
149
|
+
|
|
150
|
+
this.setFakedFinderResults([filename])
|
|
151
|
+
this.setFakedFileContents({
|
|
152
|
+
[filename]: generateId(),
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
await this.run()
|
|
156
|
+
|
|
157
|
+
assert.isEqualDeep(this.lastWrittenFile, {
|
|
158
|
+
destination: filename,
|
|
159
|
+
contents: this.testFileMigrator.fakedMigrateResponse,
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@test()
|
|
164
|
+
protected async returnsSkippedIfMigratedIsTheSame() {
|
|
165
|
+
this.setFakedFinderResults(['a'])
|
|
166
|
+
const contents = generateId()
|
|
167
|
+
this.setFakedFileContents({
|
|
168
|
+
a: contents,
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
this.setMigrateFileResponse(contents)
|
|
172
|
+
|
|
173
|
+
const stats = await this.run()
|
|
174
|
+
assert.isEqualDeep(stats, {
|
|
175
|
+
totalTestsUpdated: 0,
|
|
176
|
+
totalTestsSkipped: 1,
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@test()
|
|
181
|
+
protected async countsSkippedAndMatched() {
|
|
182
|
+
const contents1 = generateId()
|
|
183
|
+
const contents2 = generateId()
|
|
184
|
+
|
|
185
|
+
this.setFakedFinderResults(['what', 'the', 'heck'])
|
|
186
|
+
this.setFakedFileContents({
|
|
187
|
+
what: contents1,
|
|
188
|
+
the: contents2,
|
|
189
|
+
heck: generateId(),
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
this.testFileMigrator.fakedMigrateResponsesByContents = {
|
|
193
|
+
[contents1]: contents1,
|
|
194
|
+
[contents2]: contents2,
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const stats = await this.run()
|
|
198
|
+
assert.isEqualDeep(stats, {
|
|
199
|
+
totalTestsUpdated: 1,
|
|
200
|
+
totalTestsSkipped: 2,
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@test()
|
|
205
|
+
protected async doesNotWriteFileThatDidNotChange() {
|
|
206
|
+
this.setFakedFinderResults(['a'])
|
|
207
|
+
const contents = generateId()
|
|
208
|
+
this.setFakedFileContents({
|
|
209
|
+
a: contents,
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
this.setMigrateFileResponse(contents)
|
|
213
|
+
|
|
214
|
+
await this.run()
|
|
215
|
+
assert.isUndefined(this.lastWrittenFile)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@test()
|
|
219
|
+
protected async lintsMigratedFiles() {
|
|
220
|
+
await this.run()
|
|
221
|
+
assert.isTrue(this.spyCommandService.didExecute)
|
|
222
|
+
assert.doesInclude(
|
|
223
|
+
this.spyCommandService.lastCommand,
|
|
224
|
+
`await cli.lintFiles(['**/*.ts'])`
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@test()
|
|
229
|
+
protected async shouldLintAfterMigrating() {
|
|
230
|
+
this.setFakedFinderResults(['match'])
|
|
231
|
+
this.setFakedFileContents({
|
|
232
|
+
match: generateId(),
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
StaticToInstanceMigratorImpl.diskUtil.writeFile = () => {
|
|
236
|
+
assert.isFalse(
|
|
237
|
+
this.spyCommandService.didExecute,
|
|
238
|
+
'Should not lint yet'
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await this.run()
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private setMigrateFileResponse(contents: string) {
|
|
246
|
+
this.testFileMigrator.fakedMigrateResponse = contents
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private assertContentsPassedToFileMigratorEquals(expected: string[]) {
|
|
250
|
+
assert.isEqualDeep(
|
|
251
|
+
this.testFileMigrator.contentsPassedToMigrate,
|
|
252
|
+
expected
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private setFakedFileContents(contents: Record<string, string>) {
|
|
257
|
+
this.fakedFileContents = contents
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private setFakedFinderResults(results: string[]) {
|
|
261
|
+
this.testFinder.fakedResults = results
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private async run(path?: string) {
|
|
265
|
+
return await this.migrator.run(path ?? generateId())
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
class FakeStaticTestFinder implements StaticTestFinder {
|
|
270
|
+
public lastLookupDir?: string
|
|
271
|
+
public fakedResults: string[] = []
|
|
272
|
+
|
|
273
|
+
public async find(lookupDir: string): Promise<string[]> {
|
|
274
|
+
this.lastLookupDir = lookupDir
|
|
275
|
+
return this.fakedResults
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
class FakeFileMigrator implements StaticToInstanceTestFileMigrator {
|
|
280
|
+
public contentsPassedToMigrate: string[] = []
|
|
281
|
+
public fakedMigrateResponse = generateId()
|
|
282
|
+
public fakedMigrateResponsesByContents: Record<string, string> = {}
|
|
283
|
+
|
|
284
|
+
public migrate(contents: string): string {
|
|
285
|
+
this.contentsPassedToMigrate.push(contents)
|
|
286
|
+
return (
|
|
287
|
+
this.fakedMigrateResponsesByContents[contents] ??
|
|
288
|
+
this.fakedMigrateResponse
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
class SpyCommandService implements CommandService {
|
|
294
|
+
public didExecute = false
|
|
295
|
+
public lastCommand?: string
|
|
296
|
+
public async execute(
|
|
297
|
+
cmd: string,
|
|
298
|
+
options?: ExecuteCommandOptions
|
|
299
|
+
): Promise<{ stdout: string }> {
|
|
300
|
+
this.lastCommand = options?.args?.[1] ?? cmd
|
|
301
|
+
this.didExecute = true
|
|
302
|
+
return {
|
|
303
|
+
stdout: generateId(),
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
public kill(): void {}
|
|
307
|
+
public pid(): number | undefined {
|
|
308
|
+
return 0
|
|
309
|
+
}
|
|
310
|
+
}
|
package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import AbstractSpruceTest, {
|
|
3
|
+
test,
|
|
4
|
+
assert,
|
|
5
|
+
errorAssert,
|
|
6
|
+
suite,
|
|
7
|
+
} from '@sprucelabs/test-utils'
|
|
8
|
+
import StaticToInstanceTestFileMigratorImpl, {
|
|
9
|
+
StaticToInstanceTestFileMigrator,
|
|
10
|
+
} from '../../../../tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator'
|
|
11
|
+
|
|
12
|
+
@suite()
|
|
13
|
+
export default class StaticToInstanceTestFileMigratorTest extends AbstractSpruceTest {
|
|
14
|
+
private migrator: StaticToInstanceTestFileMigrator =
|
|
15
|
+
StaticToInstanceTestFileMigratorImpl.Migrator()
|
|
16
|
+
|
|
17
|
+
@test()
|
|
18
|
+
protected throwsWithMissing() {
|
|
19
|
+
//@ts-ignore
|
|
20
|
+
const err = assert.doesThrow(() => this.migrate())
|
|
21
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
22
|
+
parameters: ['contents'],
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@test()
|
|
27
|
+
protected returnsEmptyString() {
|
|
28
|
+
this.assertMigratedEquals('', '')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@test()
|
|
32
|
+
protected fixesStaticFunction() {
|
|
33
|
+
this.assertMigratedEquals(
|
|
34
|
+
`@test()
|
|
35
|
+
protected static myTest() {}`,
|
|
36
|
+
`@test()
|
|
37
|
+
protected myTest() {}`
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@test()
|
|
42
|
+
protected fixesStaticAsyncFunctions() {
|
|
43
|
+
this.assertMigratedEquals(
|
|
44
|
+
`@test()
|
|
45
|
+
protected static async myTest() {}`,
|
|
46
|
+
`@test()
|
|
47
|
+
protected async myTest() {}`
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@test()
|
|
52
|
+
protected doesNotMessWithStaticInVariableName() {
|
|
53
|
+
this.assertMigratedEquals(
|
|
54
|
+
`protected staticInName() {}`,
|
|
55
|
+
`protected staticInName() {}`
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@test()
|
|
60
|
+
protected addsSuiteDecoratorToClassIfNotThere() {
|
|
61
|
+
this.assertMigratedEquals(
|
|
62
|
+
`export default class Test {}`,
|
|
63
|
+
`@suite()\nexport default class Test {}`
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@test()
|
|
68
|
+
protected doesNotAddSuitIfAnotherClassExported() {
|
|
69
|
+
this.assertMigratedEquals(
|
|
70
|
+
`export class Test {}`,
|
|
71
|
+
`export class Test {}`
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@test()
|
|
76
|
+
protected doesNotAddSuiteIfAlreadyThere() {
|
|
77
|
+
this.assertMigratedEquals(
|
|
78
|
+
`@suite()\nexport default class Test {}`,
|
|
79
|
+
`@suite()\nexport default class Test {}`
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@test()
|
|
84
|
+
protected addsImportIfNotThere() {
|
|
85
|
+
this.assertMigratedEquals(
|
|
86
|
+
`import { test } from '@sprucelabs/test-utils'`,
|
|
87
|
+
`import { test, suite } from '@sprucelabs/test-utils'`
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@test()
|
|
92
|
+
protected doesNotMessWithAnythingWithTestInName() {
|
|
93
|
+
this.assertMigratedEquals(
|
|
94
|
+
`protected testing() {}`,
|
|
95
|
+
`protected testing() {}`
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@test()
|
|
100
|
+
protected doesNoIncludeSuiteTwice() {
|
|
101
|
+
this.assertMigratedEquals(
|
|
102
|
+
`import { test, suite } from '@sprucelabs/test-utils'`,
|
|
103
|
+
`import { test, suite } from '@sprucelabs/test-utils'`
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@test()
|
|
108
|
+
protected includesSuiteEvenIfSuiteIsInAMethodName() {
|
|
109
|
+
this.assertMigratedEquals(
|
|
110
|
+
`import { test } from '@sprucelabs/test-utils
|
|
111
|
+
protected suiteMethod() {}`,
|
|
112
|
+
`import { test, suite } from '@sprucelabs/test-utils
|
|
113
|
+
protected suiteMethod() {}`
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@test()
|
|
118
|
+
protected includesSuiteWithMultipleImports() {
|
|
119
|
+
this.assertMigratedEquals(
|
|
120
|
+
`import AbstractSpruceTest, {
|
|
121
|
+
test,
|
|
122
|
+
assert,
|
|
123
|
+
errorAssert,
|
|
124
|
+
} from '@sprucelabs/test-utils'`,
|
|
125
|
+
`import AbstractSpruceTest, {
|
|
126
|
+
test,
|
|
127
|
+
suite,
|
|
128
|
+
assert,
|
|
129
|
+
errorAssert,
|
|
130
|
+
} from '@sprucelabs/test-utils'`
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@test()
|
|
135
|
+
protected canMigrateWholeTest() {
|
|
136
|
+
const before = this.readTestFile('StaticTest.txt')
|
|
137
|
+
const expected = this.readTestFile('InstanceTest.txt')
|
|
138
|
+
|
|
139
|
+
this.assertMigratedEquals(before, expected)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@test()
|
|
143
|
+
protected properlyMigrationsAbstractTests() {
|
|
144
|
+
const before = this.readTestFile('AbstractStaticTest.txt')
|
|
145
|
+
const expected = this.readTestFile('AbstractInstanceTest.txt')
|
|
146
|
+
|
|
147
|
+
this.assertMigratedEquals(before, expected)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@test()
|
|
151
|
+
protected canMigrateMoreComplexTest() {
|
|
152
|
+
const before = this.readTestFile('StaticTest2.txt')
|
|
153
|
+
const expected = this.readTestFile('InstanceTest2.txt')
|
|
154
|
+
|
|
155
|
+
this.assertMigratedEquals(before, expected)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@test()
|
|
159
|
+
protected canMigrateAnotherComplexTest() {
|
|
160
|
+
const before = this.readTestFile('StaticTest3.txt')
|
|
161
|
+
const expected = this.readTestFile('InstanceTest3.txt')
|
|
162
|
+
|
|
163
|
+
this.assertMigratedEquals(before, expected)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private readTestFile(name: string) {
|
|
167
|
+
return diskUtil.readFile(this.resolveTestClassPath(name))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private resolveTestClassPath(name: string) {
|
|
171
|
+
return this.resolvePath(__dirname, 'support', name)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private assertMigratedEquals(contents: string, expected: string) {
|
|
175
|
+
const actual = this.migrate(contents)
|
|
176
|
+
|
|
177
|
+
const cleanedActual = this.cleanString(actual)
|
|
178
|
+
const cleanedExpected = this.cleanString(expected)
|
|
179
|
+
|
|
180
|
+
assert.isTrue(
|
|
181
|
+
cleanedActual == cleanedExpected,
|
|
182
|
+
`${actual}\n\ndoes not equal\n\n${expected}`
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private cleanString(contents: string) {
|
|
187
|
+
return contents.replace(/\s{2,}/g, ' ').trim()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private migrate(contents: string) {
|
|
191
|
+
return this.migrator.migrate(contents)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractSpruceFixtureTest } from '@sprucelabs/spruce-test-fixtures'
|
|
2
|
+
import { assert } from '@sprucelabs/test-utils'
|
|
3
|
+
import HomeIntegrationsStore from '../../stores/HomeIntegrations.store'
|
|
4
|
+
import EventFaker from './EventFaker'
|
|
5
|
+
|
|
6
|
+
export default abstract class AbstractGoogleTest extends AbstractSpruceFixtureTest {
|
|
7
|
+
protected eventFaker!: EventFaker
|
|
8
|
+
private homeIntegrations!: HomeIntegrationsStore
|
|
9
|
+
|
|
10
|
+
protected async beforeEach(): Promise<void> {
|
|
11
|
+
await super.beforeEach()
|
|
12
|
+
this.eventFaker = new EventFaker()
|
|
13
|
+
this.homeIntegrations = await this.stores.getStore('homeIntegrations')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected async getFirstHomeIntegration() {
|
|
17
|
+
const match = await this.homeIntegrations.findOne(
|
|
18
|
+
{},
|
|
19
|
+
{ shouldIncludePrivateFields: true }
|
|
20
|
+
)
|
|
21
|
+
assert.isTruthy(match, 'No home integration found')
|
|
22
|
+
return match
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractSpruceFixtureTest } from '@sprucelabs/spruce-test-fixtures'
|
|
2
|
+
import { assert } from '@sprucelabs/test-utils'
|
|
3
|
+
import HomeIntegrationsStore from '../../stores/HomeIntegrations.store'
|
|
4
|
+
import EventFaker from './EventFaker'
|
|
5
|
+
|
|
6
|
+
export default abstract class AbstractGoogleTest extends AbstractSpruceFixtureTest {
|
|
7
|
+
protected static eventFaker: EventFaker
|
|
8
|
+
private static homeIntegrations: HomeIntegrationsStore
|
|
9
|
+
|
|
10
|
+
protected static async beforeEach(): Promise<void> {
|
|
11
|
+
await super.beforeEach()
|
|
12
|
+
this.eventFaker = new EventFaker()
|
|
13
|
+
this.homeIntegrations = await this.stores.getStore('homeIntegrations')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected static async getFirstHomeIntegration() {
|
|
17
|
+
const match = await this.homeIntegrations.findOne(
|
|
18
|
+
{},
|
|
19
|
+
{ shouldIncludePrivateFields: true }
|
|
20
|
+
)
|
|
21
|
+
assert.isTruthy(match, 'No home integration found')
|
|
22
|
+
return match
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { assertOptions } from '@sprucelabs/schema'
|
|
2
|
+
import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
3
|
+
import AbstractSpruceTest, {
|
|
4
|
+
test,
|
|
5
|
+
suite,
|
|
6
|
+
assert,
|
|
7
|
+
errorAssert,
|
|
8
|
+
} from '@sprucelabs/test-utils'
|
|
9
|
+
|
|
10
|
+
@fake.login()
|
|
11
|
+
@suite()
|
|
12
|
+
export default class StaticTestFinderTest extends AbstractSpruceTest {
|
|
13
|
+
@test()
|
|
14
|
+
protected async throwsWithMissing() {
|
|
15
|
+
const finder = StaticTestFinder.Finder()
|
|
16
|
+
const err = await assert.doesThrowAsync(() => finder.find())
|
|
17
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
18
|
+
parameters: ['lookupDir'],
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@test()
|
|
23
|
+
protected async yourNextTest() {
|
|
24
|
+
assert.isTrue(false)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class StaticTestFinder {
|
|
29
|
+
public static Finder() {
|
|
30
|
+
return new this()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public async find() {
|
|
34
|
+
assertOptions({}, ['lookupDir'])
|
|
35
|
+
}
|
|
36
|
+
}
|