@neurodevs/node-tdd 0.2.5 → 1.0.0
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/.vscode/launch.json +52 -57
- package/.vscode/settings.json +61 -66
- package/.vscode/tasks.json +98 -129
- package/README.md +1 -0
- package/build/.spruce/settings.json +3 -10
- package/build/__tests__/MockFetch.d.ts +18 -0
- package/build/__tests__/MockFetch.js +55 -0
- package/build/__tests__/MockFetch.js.map +1 -0
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.d.ts +2 -3
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.js +3 -12
- package/build/__tests__/behavioral/AbstractModuleTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js +34 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Assert.test.d.ts +45 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js +645 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js +23 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js +211 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js +46 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js +32 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js +19 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js +127 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.d.ts +12 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js +68 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js +289 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.d.ts +9 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js +118 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js +78 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js +23 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js +24 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js +20 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.d.ts +18 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js +267 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +16 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js +227 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.d.ts +15 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js +99 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +13 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js +99 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js.map +1 -0
- package/build/__tests__/mock-terminal-kit.d.ts +79 -0
- package/build/__tests__/mock-terminal-kit.js +103 -0
- package/build/__tests__/mock-terminal-kit.js.map +1 -0
- package/build/__tests__/support/AbstractForInstanceTest.d.ts +4 -0
- package/build/__tests__/support/AbstractForInstanceTest.js +9 -0
- package/build/__tests__/support/AbstractForInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelOneTest.d.ts +3 -0
- package/build/__tests__/support/AbstractLevelOneTest.js +4 -0
- package/build/__tests__/support/AbstractLevelOneTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelTwoTest.d.ts +7 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js +14 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js.map +1 -0
- package/build/__tests__/support/AbstractStaticTest.d.ts +7 -0
- package/build/__tests__/support/AbstractStaticTest.js +14 -0
- package/build/__tests__/support/AbstractStaticTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.d.ts +22 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js +23 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.d.ts +26 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js +59 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js.map +1 -0
- package/build/__tests__/support/jest.setup.d.ts +1 -0
- package/build/__tests__/support/jest.setup.js +4 -0
- package/build/__tests__/support/jest.setup.js.map +1 -0
- package/build/__tests__/support/onTestFileResult.d.ts +244 -0
- package/build/__tests__/support/onTestFileResult.js +980 -0
- package/build/__tests__/support/onTestFileResult.js.map +1 -0
- package/build/impl/AbstractModuleTest.d.ts +18 -4
- package/build/impl/AbstractModuleTest.js +47 -9
- package/build/impl/AbstractModuleTest.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.js +4 -4
- package/build/index.js.map +1 -1
- package/build/utilities/AssertionError.d.ts +3 -0
- package/build/utilities/AssertionError.js +12 -0
- package/build/utilities/AssertionError.js.map +1 -0
- package/build/utilities/StackCleaner.d.ts +4 -0
- package/build/utilities/StackCleaner.js +10 -0
- package/build/utilities/StackCleaner.js.map +1 -0
- package/build/utilities/TestDecoratorResolver.d.ts +35 -0
- package/build/utilities/TestDecoratorResolver.js +93 -0
- package/build/utilities/TestDecoratorResolver.js.map +1 -0
- package/build/utilities/assert.d.ts +49 -0
- package/build/utilities/assert.js +255 -0
- package/build/utilities/assert.js.map +1 -0
- package/build/utilities/assert.utility.d.ts +28 -0
- package/build/utilities/assert.utility.js +185 -0
- package/build/utilities/assert.utility.js.map +1 -0
- package/build/utilities/decorators.d.ts +9 -0
- package/build/utilities/decorators.js +133 -0
- package/build/utilities/decorators.js.map +1 -0
- package/build/workspace/CommandService.d.ts +49 -0
- package/build/workspace/CommandService.js +179 -0
- package/build/workspace/CommandService.js.map +1 -0
- package/build/workspace/JestJsonParser.d.ts +15 -0
- package/build/workspace/JestJsonParser.js +149 -0
- package/build/workspace/JestJsonParser.js.map +1 -0
- package/build/workspace/TKButtonWidget.d.ts +13 -0
- package/build/workspace/TKButtonWidget.js +37 -0
- package/build/workspace/TKButtonWidget.js.map +1 -0
- package/build/workspace/TestLogItemGenerator.d.ts +15 -0
- package/build/workspace/TestLogItemGenerator.js +142 -0
- package/build/workspace/TestLogItemGenerator.js.map +1 -0
- package/build/workspace/TestReporter.d.ts +103 -0
- package/build/workspace/TestReporter.js +677 -0
- package/build/workspace/TestReporter.js.map +1 -0
- package/build/workspace/TestRunner.d.ts +24 -0
- package/build/workspace/TestRunner.js +95 -0
- package/build/workspace/TestRunner.js.map +1 -0
- package/build/workspace/TkBaseWidget.d.ts +37 -0
- package/build/workspace/TkBaseWidget.js +185 -0
- package/build/workspace/TkBaseWidget.js.map +1 -0
- package/build/workspace/TkInputWidget.d.ts +16 -0
- package/build/workspace/TkInputWidget.js +64 -0
- package/build/workspace/TkInputWidget.js.map +1 -0
- package/build/workspace/TkLayoutCellWidget.d.ts +18 -0
- package/build/workspace/TkLayoutCellWidget.js +32 -0
- package/build/workspace/TkLayoutCellWidget.js.map +1 -0
- package/build/workspace/TkLayoutWidget.d.ts +34 -0
- package/build/workspace/TkLayoutWidget.js +130 -0
- package/build/workspace/TkLayoutWidget.js.map +1 -0
- package/build/workspace/TkMenuBarWidget.d.ts +13 -0
- package/build/workspace/TkMenuBarWidget.js +71 -0
- package/build/workspace/TkMenuBarWidget.js.map +1 -0
- package/build/workspace/TkPopupWidget.d.ts +16 -0
- package/build/workspace/TkPopupWidget.js +36 -0
- package/build/workspace/TkPopupWidget.js.map +1 -0
- package/build/workspace/TkProgressBarWidget.d.ts +10 -0
- package/build/workspace/TkProgressBarWidget.js +39 -0
- package/build/workspace/TkProgressBarWidget.js.map +1 -0
- package/build/workspace/TkTextWidget.d.ts +20 -0
- package/build/workspace/TkTextWidget.js +115 -0
- package/build/workspace/TkTextWidget.js.map +1 -0
- package/build/workspace/TkWindowWidget.d.ts +22 -0
- package/build/workspace/TkWindowWidget.js +88 -0
- package/build/workspace/TkWindowWidget.js.map +1 -0
- package/build/workspace/WidgetFactory.d.ts +6 -0
- package/build/workspace/WidgetFactory.js +21 -0
- package/build/workspace/WidgetFactory.js.map +1 -0
- package/build/workspace/button.types.d.ts +15 -0
- package/build/workspace/button.types.js +6 -0
- package/build/workspace/button.types.js.map +1 -0
- package/build/workspace/duration.utility.d.ts +4 -0
- package/build/workspace/duration.utility.js +26 -0
- package/build/workspace/duration.utility.js.map +1 -0
- package/build/workspace/factory.types.d.ts +89 -0
- package/build/workspace/factory.types.js +37 -0
- package/build/workspace/factory.types.js.map +1 -0
- package/build/workspace/input.types.d.ts +18 -0
- package/build/workspace/input.types.js +7 -0
- package/build/workspace/input.types.js.map +1 -0
- package/build/workspace/keySelectChoices.d.ts +517 -0
- package/build/workspace/keySelectChoices.js +2 -0
- package/build/workspace/keySelectChoices.js.map +1 -0
- package/build/workspace/layout.types.d.ts +33 -0
- package/build/workspace/layout.types.js +2 -0
- package/build/workspace/layout.types.js.map +1 -0
- package/build/workspace/menuBar.types.d.ts +19 -0
- package/build/workspace/menuBar.types.js +6 -0
- package/build/workspace/menuBar.types.js.map +1 -0
- package/build/workspace/popup.types.d.ts +13 -0
- package/build/workspace/popup.types.js +6 -0
- package/build/workspace/popup.types.js.map +1 -0
- package/build/workspace/progressBar.types.d.ts +10 -0
- package/build/workspace/progressBar.types.js +2 -0
- package/build/workspace/progressBar.types.js.map +1 -0
- package/build/workspace/table.types.d.ts +6 -0
- package/build/workspace/table.types.js +2 -0
- package/build/workspace/table.types.js.map +1 -0
- package/build/workspace/termKit.utility.d.ts +12 -0
- package/build/workspace/termKit.utility.js +128 -0
- package/build/workspace/termKit.utility.js.map +1 -0
- package/build/workspace/test.types.d.ts +24 -0
- package/build/workspace/test.types.js +2 -0
- package/build/workspace/test.types.js.map +1 -0
- package/build/workspace/testRunner.cli.d.ts +1 -0
- package/build/workspace/testRunner.cli.js +149 -0
- package/build/workspace/testRunner.cli.js.map +1 -0
- package/build/workspace/text.types.d.ts +20 -0
- package/build/workspace/text.types.js +7 -0
- package/build/workspace/text.types.js.map +1 -0
- package/build/workspace/widget.utilities.d.ts +5 -0
- package/build/workspace/widget.utilities.js +20 -0
- package/build/workspace/widget.utilities.js.map +1 -0
- package/build/workspace/widgets.types.d.ts +66 -0
- package/build/workspace/widgets.types.js +2 -0
- package/build/workspace/widgets.types.js.map +1 -0
- package/build/workspace/window.types.d.ts +18 -0
- package/build/workspace/window.types.js +9 -0
- package/build/workspace/window.types.js.map +1 -0
- package/eslint.config.js +3 -0
- package/package.json +30 -37
- package/prettier.config.js +3 -0
- package/src/.spruce/settings.json +3 -10
- package/src/__tests__/MockFetch.ts +100 -0
- package/src/__tests__/behavioral/AbstractModuleTest.test.ts +15 -0
- package/src/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.ts +31 -0
- package/src/__tests__/behavioral/utilities/Assert.test.ts +826 -0
- package/src/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/MockFetch.test.ts +240 -0
- package/src/__tests__/behavioral/utilities/StackCleaner.test.ts +46 -0
- package/src/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.ts +34 -0
- package/src/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.ts +11 -0
- package/src/__tests__/behavioral/utilities/Stringify.test.ts +169 -0
- package/src/__tests__/behavioral/utilities/TestDecoratorResolver.test.ts +51 -0
- package/src/__tests__/behavioral/utilities/TestOnBasic.test.ts +62 -0
- package/src/__tests__/behavioral/utilities/TestOnInstance.test.ts +439 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.ts +237 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.ts +85 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.ts +16 -0
- package/src/__tests__/behavioral/utilities/TestResolver.test.ts +48 -0
- package/src/__tests__/behavioral/utilities/TestResolverOnStatic.test.ts +12 -0
- package/src/__tests__/behavioral/workspace/JestJsonParser.test.ts +357 -0
- package/src/__tests__/behavioral/workspace/TestReporter.test.ts +257 -0
- package/src/__tests__/behavioral/workspace/TestRunner.test.ts +87 -0
- package/src/__tests__/behavioral/workspace/Widgets.test.ts +90 -0
- package/src/__tests__/mock-terminal-kit.ts +115 -0
- package/src/__tests__/support/AbstractForInstanceTest.ts +12 -0
- package/src/__tests__/support/AbstractLevelOneTest.ts +3 -0
- package/src/__tests__/support/AbstractLevelTwoTest.ts +16 -0
- package/src/__tests__/support/AbstractStaticTest.ts +16 -0
- package/src/__tests__/support/AbstractTestOnInstanceTest.ts +30 -0
- package/src/__tests__/support/AbstractTestOnInstanceWithHooks.ts +138 -0
- package/src/__tests__/support/jest.setup.ts +2 -0
- package/src/__tests__/support/onTestFileResult.ts +1008 -0
- package/src/impl/AbstractModuleTest.ts +59 -10
- package/src/index.ts +4 -4
- package/src/utilities/AssertionError.ts +14 -0
- package/src/utilities/StackCleaner.ts +14 -0
- package/src/utilities/TestDecoratorResolver.ts +118 -0
- package/src/utilities/assert.ts +583 -0
- package/src/utilities/assert.utility.ts +295 -0
- package/src/utilities/decorators.ts +167 -0
- package/src/workspace/CommandService.ts +256 -0
- package/src/workspace/JestJsonParser.ts +255 -0
- package/src/workspace/TKButtonWidget.ts +54 -0
- package/src/workspace/TestLogItemGenerator.ts +184 -0
- package/src/workspace/TestReporter.ts +865 -0
- package/src/workspace/TestRunner.ts +128 -0
- package/src/workspace/TkBaseWidget.ts +249 -0
- package/src/workspace/TkInputWidget.ts +83 -0
- package/src/workspace/TkLayoutCellWidget.ts +46 -0
- package/src/workspace/TkLayoutWidget.ts +181 -0
- package/src/workspace/TkMenuBarWidget.ts +95 -0
- package/src/workspace/TkPopupWidget.ts +47 -0
- package/src/workspace/TkProgressBarWidget.ts +54 -0
- package/src/workspace/TkTextWidget.ts +158 -0
- package/src/workspace/TkWindowWidget.ts +122 -0
- package/src/workspace/WidgetFactory.ts +33 -0
- package/src/workspace/button.types.ts +19 -0
- package/src/workspace/duration.utility.ts +34 -0
- package/src/workspace/factory.types.ts +101 -0
- package/src/workspace/input.types.ts +22 -0
- package/src/workspace/keySelectChoices.ts +134 -0
- package/src/workspace/layout.types.ts +40 -0
- package/src/workspace/menuBar.types.ts +24 -0
- package/src/workspace/popup.types.ts +17 -0
- package/src/workspace/progressBar.types.ts +13 -0
- package/src/workspace/table.types.ts +9 -0
- package/src/workspace/termKit.utility.ts +130 -0
- package/src/workspace/terminal-kit.d.ts +28 -0
- package/src/workspace/test.types.ts +34 -0
- package/src/workspace/testRunner.cli.ts +159 -0
- package/src/workspace/text.types.ts +26 -0
- package/src/workspace/widget.utilities.ts +35 -0
- package/src/workspace/widgets.types.ts +102 -0
- package/src/workspace/window.types.ts +22 -0
- package/tsconfig.json +23 -27
- package/build/__tests__/AbstractPackageTest.d.ts +0 -4
- package/build/__tests__/AbstractPackageTest.js +0 -7
- package/build/__tests__/AbstractPackageTest.js.map +0 -1
- package/build/__tests__/functions/assertFunction.test.d.ts +0 -5
- package/build/__tests__/functions/assertFunction.test.js +0 -23
- package/build/__tests__/functions/assertFunction.test.js.map +0 -1
- package/build/__tests__/functions/testFunction.test.d.ts +0 -5
- package/build/__tests__/functions/testFunction.test.js +0 -23
- package/build/__tests__/functions/testFunction.test.js.map +0 -1
- package/build/__tests__/impl/AbstractModuleTest.test.js.map +0 -1
- package/build/functions/assert.d.ts +0 -3
- package/build/functions/assert.js +0 -4
- package/build/functions/assert.js.map +0 -1
- package/build/functions/test.d.ts +0 -3
- package/build/functions/test.js +0 -4
- package/build/functions/test.js.map +0 -1
- package/eslint.config.mjs +0 -3
- package/src/__tests__/AbstractPackageTest.ts +0 -7
- package/src/__tests__/functions/assertFunction.test.ts +0 -22
- package/src/__tests__/functions/testFunction.test.ts +0 -22
- package/src/__tests__/impl/AbstractModuleTest.test.ts +0 -34
- package/src/functions/assert.ts +0 -4
- package/src/functions/test.ts +0 -4
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
import generateId from '@neurodevs/generate-id'
|
|
2
|
+
|
|
3
|
+
import assert from '../../../utilities/assert.js'
|
|
4
|
+
import test from '../../../utilities/decorators.js'
|
|
5
|
+
import AbstractModuleTest from '../../../impl/AbstractModuleTest.js'
|
|
6
|
+
|
|
7
|
+
interface ICustomObj {
|
|
8
|
+
testStr: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class AssertTest extends AbstractModuleTest {
|
|
12
|
+
@test()
|
|
13
|
+
protected static async canHandleAsyncThrows() {
|
|
14
|
+
let hitError = false
|
|
15
|
+
|
|
16
|
+
await assert.doesThrowAsync(
|
|
17
|
+
async () =>
|
|
18
|
+
new Promise(() => {
|
|
19
|
+
hitError = true
|
|
20
|
+
throw new Error('should catch')
|
|
21
|
+
})
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
assert.isTrue(hitError)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@test()
|
|
28
|
+
protected static async canDetectNoErrorThrown() {
|
|
29
|
+
let hitCallback = true
|
|
30
|
+
let detectedNoThrow = false
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
assert.doesThrow(async () => {
|
|
34
|
+
hitCallback = true
|
|
35
|
+
})
|
|
36
|
+
} catch (err) {
|
|
37
|
+
detectedNoThrow = true
|
|
38
|
+
assert.isTruthy(err)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
assert.isTrue(hitCallback)
|
|
42
|
+
assert.isTrue(detectedNoThrow)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@test()
|
|
46
|
+
protected static isEqual() {
|
|
47
|
+
assert.doesThrow(() => assert.isEqual('hello', 'world'), /expected/)
|
|
48
|
+
assert.isEqual(1, 1)
|
|
49
|
+
assert.isEqual(1, 1, 'works with error message')
|
|
50
|
+
assert.isEqual('testing', 'testing', 'works with error message')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@test()
|
|
54
|
+
protected static isAbove() {
|
|
55
|
+
assert.isAbove(10, 5)
|
|
56
|
+
assert.doesThrow(() => assert.isAbove(5, 10), /is not above/)
|
|
57
|
+
assert.doesThrow(() => assert.isAbove(undefined, 10), /is not a number/)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@test()
|
|
61
|
+
protected static async isBelow() {
|
|
62
|
+
assert.isBelow(5, 10)
|
|
63
|
+
assert.doesThrow(() => assert.isBelow(10, 5), /is not below/)
|
|
64
|
+
assert.doesThrow(() => assert.isBelow(undefined, 5), /is not a number/)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@test()
|
|
68
|
+
protected static async typeTests() {
|
|
69
|
+
assert.isType<string>('string')
|
|
70
|
+
assert.isType<number>(123)
|
|
71
|
+
|
|
72
|
+
const myCustomObj: ICustomObj = {
|
|
73
|
+
testStr: 'blah',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
assert.isType<ICustomObj>(myCustomObj)
|
|
77
|
+
assert.areSameType(true, true)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@test()
|
|
81
|
+
protected static async canMatchErrorByString() {
|
|
82
|
+
assert.doesThrow(() => {
|
|
83
|
+
throw new Error('Match on string')
|
|
84
|
+
}, 'on string')
|
|
85
|
+
|
|
86
|
+
assert.doesThrow(() => {
|
|
87
|
+
throw new Error(
|
|
88
|
+
'crudAssert.beforeEach(this.views) is is here with dots and parentheses'
|
|
89
|
+
)
|
|
90
|
+
}, 'crudAssert.beforeEach(this.views)')
|
|
91
|
+
|
|
92
|
+
await assert.doesThrowAsync(async () => {
|
|
93
|
+
throw new Error('canMatchErrorByString: Match on string')
|
|
94
|
+
}, 'on string')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@test()
|
|
98
|
+
protected static async doesNotMatchErrorByBadString() {
|
|
99
|
+
let errorThrown = false
|
|
100
|
+
try {
|
|
101
|
+
assert.doesThrow(() => {
|
|
102
|
+
throw new Error('doesNotMatchErrorByBadString: Match on string')
|
|
103
|
+
}, 'on string2')
|
|
104
|
+
} catch {
|
|
105
|
+
errorThrown = true
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
assert.isTrue(errorThrown)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@test()
|
|
112
|
+
protected static async throwMatchesErrorByRegex() {
|
|
113
|
+
assert.doesThrow(() => {
|
|
114
|
+
throw new Error('Match on string')
|
|
115
|
+
}, /on STRING/i)
|
|
116
|
+
|
|
117
|
+
await assert.doesThrowAsync(async () => {
|
|
118
|
+
throw new Error('Match on string')
|
|
119
|
+
}, /on STRING/i)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@test()
|
|
123
|
+
protected static async throwReturnsTheError() {
|
|
124
|
+
const err = assert.doesThrow(() => {
|
|
125
|
+
throw new Error('Match on string')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
assert.isEqual(err.message, 'Match on string')
|
|
129
|
+
|
|
130
|
+
const err2 = await assert.doesThrowAsync(async () => {
|
|
131
|
+
throw new Error('Match on string')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
assert.isEqual(err2.message, 'Match on string')
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@test()
|
|
138
|
+
protected static async doesNotMatchErrorByBadRegex() {
|
|
139
|
+
let errorThrown = false
|
|
140
|
+
try {
|
|
141
|
+
assert.doesThrow(() => {
|
|
142
|
+
throw new Error('Match on string')
|
|
143
|
+
}, /on string2/)
|
|
144
|
+
} catch {
|
|
145
|
+
errorThrown = true
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
assert.isTrue(errorThrown)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@test()
|
|
152
|
+
protected static async doesNotMatchErrorByBadRegexAsync() {
|
|
153
|
+
let errorThrown = false
|
|
154
|
+
try {
|
|
155
|
+
await assert.doesThrowAsync(async () => {
|
|
156
|
+
throw new Error('Match on string')
|
|
157
|
+
}, /on string2/)
|
|
158
|
+
} catch {
|
|
159
|
+
errorThrown = true
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
assert.isTrue(errorThrown)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@test('asserts is string (test will pass, types will fail)')
|
|
166
|
+
protected static async assertIsString() {
|
|
167
|
+
const path = ((): string | undefined => {
|
|
168
|
+
return 'test'
|
|
169
|
+
})()
|
|
170
|
+
|
|
171
|
+
assert.isString(path)
|
|
172
|
+
assert.isType<string>(path)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@test('include uses string to match string', 'hello world', 'world')
|
|
176
|
+
@test('assert regex on string', 'hello world', /world/gi)
|
|
177
|
+
@test(
|
|
178
|
+
'assert regex obj on string',
|
|
179
|
+
'hello world',
|
|
180
|
+
new RegExp('world', 'gis')
|
|
181
|
+
)
|
|
182
|
+
@test(
|
|
183
|
+
'include uses partial and matches 0th level',
|
|
184
|
+
{ hello: 'world', taco: 'bell' },
|
|
185
|
+
{ taco: 'bell' }
|
|
186
|
+
)
|
|
187
|
+
@test(
|
|
188
|
+
'include can find string as value on 0th level',
|
|
189
|
+
{ hello: 'world', taco: 'bell' },
|
|
190
|
+
'bell'
|
|
191
|
+
)
|
|
192
|
+
@test(
|
|
193
|
+
'include can find scalar on 1st level',
|
|
194
|
+
{
|
|
195
|
+
hello: 'world',
|
|
196
|
+
taco: 'bell',
|
|
197
|
+
flavor: { cheese: true, buffalo: true },
|
|
198
|
+
},
|
|
199
|
+
{ 'flavor.cheese': true }
|
|
200
|
+
)
|
|
201
|
+
@test(
|
|
202
|
+
'include can find scalar on 2nd level',
|
|
203
|
+
{
|
|
204
|
+
hello: 'world',
|
|
205
|
+
taco: 'bell',
|
|
206
|
+
flavor: { cheese: { size: 'large', buffalo: true } },
|
|
207
|
+
},
|
|
208
|
+
{ 'flavor.cheese.size': 'large' }
|
|
209
|
+
)
|
|
210
|
+
@test(
|
|
211
|
+
'include can find object on 2nd level',
|
|
212
|
+
{
|
|
213
|
+
hello: 'world',
|
|
214
|
+
taco: 'bell',
|
|
215
|
+
flavor: { cheese: { size: 'large', buffalo: { wing: true } } },
|
|
216
|
+
},
|
|
217
|
+
{ 'flavor.cheese.buffalo': { wing: true } }
|
|
218
|
+
)
|
|
219
|
+
@test(
|
|
220
|
+
'include can search inside array with index',
|
|
221
|
+
{
|
|
222
|
+
flavors: [{ cheese: true }, { peperoni: true }],
|
|
223
|
+
},
|
|
224
|
+
{ 'flavors[0].cheese': true }
|
|
225
|
+
)
|
|
226
|
+
@test(
|
|
227
|
+
'include can search inside array without index',
|
|
228
|
+
{
|
|
229
|
+
flavors: [{ cheese: true }, { peperoni: true }],
|
|
230
|
+
},
|
|
231
|
+
{ 'flavors[].peperoni': true }
|
|
232
|
+
)
|
|
233
|
+
@test(
|
|
234
|
+
'include can search inside array without index',
|
|
235
|
+
{
|
|
236
|
+
flavors: [
|
|
237
|
+
{ size: 'large', toppings: [{ meat: true }, { cheese: true }] },
|
|
238
|
+
{ size: 'small' },
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{ 'flavors[].toppings[].meat': true }
|
|
242
|
+
)
|
|
243
|
+
@test(
|
|
244
|
+
'include can search array without index',
|
|
245
|
+
[{ cheese: true }, { meat: true }],
|
|
246
|
+
{ meat: true }
|
|
247
|
+
)
|
|
248
|
+
@test(
|
|
249
|
+
'include can match on partial object',
|
|
250
|
+
{ cheese: true, meat: true },
|
|
251
|
+
{
|
|
252
|
+
meat: true,
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
@test(
|
|
256
|
+
'include can search array without index',
|
|
257
|
+
[{ cheese: true }, { meat: true }],
|
|
258
|
+
{ '[].meat': true }
|
|
259
|
+
)
|
|
260
|
+
@test(
|
|
261
|
+
'include can search array without index',
|
|
262
|
+
[{ cheese: true }, { meat: true }],
|
|
263
|
+
{ meat: true }
|
|
264
|
+
)
|
|
265
|
+
@test(
|
|
266
|
+
'include matches partial object in array',
|
|
267
|
+
[
|
|
268
|
+
{
|
|
269
|
+
name: 'schemas.types.ts',
|
|
270
|
+
description:
|
|
271
|
+
'Every schema you need based on all your contracts',
|
|
272
|
+
path: '/example/schemas.types.ts',
|
|
273
|
+
action: 'updated',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
{
|
|
277
|
+
action: 'updated',
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
@test(
|
|
281
|
+
'include matches deep equal on object with nested object in array',
|
|
282
|
+
[
|
|
283
|
+
{
|
|
284
|
+
name: 'schemas.types.ts',
|
|
285
|
+
description:
|
|
286
|
+
'Every schema you need based on all your contracts',
|
|
287
|
+
path: '/example/schemas.types.ts',
|
|
288
|
+
action: 'updated',
|
|
289
|
+
deep: {
|
|
290
|
+
foo: 'bar',
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
{
|
|
295
|
+
name: 'schemas.types.ts',
|
|
296
|
+
description: 'Every schema you need based on all your contracts',
|
|
297
|
+
path: '/example/schemas.types.ts',
|
|
298
|
+
action: 'updated',
|
|
299
|
+
deep: {
|
|
300
|
+
foo: 'bar',
|
|
301
|
+
},
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
@test(
|
|
305
|
+
'include matches deep equal on nested object in array',
|
|
306
|
+
[
|
|
307
|
+
{
|
|
308
|
+
name: 'schemas.types.ts',
|
|
309
|
+
description:
|
|
310
|
+
'Every schema you need based on all your contracts',
|
|
311
|
+
path: '/example/schemas.types.ts',
|
|
312
|
+
action: 'updated',
|
|
313
|
+
deep: {
|
|
314
|
+
foo: 'bar',
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
{
|
|
319
|
+
name: 'schemas.types.ts',
|
|
320
|
+
deep: {
|
|
321
|
+
foo: 'bar',
|
|
322
|
+
},
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
@test(
|
|
326
|
+
'include matches object props',
|
|
327
|
+
{
|
|
328
|
+
results: {
|
|
329
|
+
errors: [new Error('test'), new Error('test2')],
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
'results.errors[].stack': 'test2',
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
@test(
|
|
337
|
+
'include matches object props against regex',
|
|
338
|
+
{
|
|
339
|
+
results: {
|
|
340
|
+
errors: [new Error('test'), new Error('test2')],
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
'results.errors[].stack': /test[1|2]/,
|
|
345
|
+
}
|
|
346
|
+
)
|
|
347
|
+
@test(
|
|
348
|
+
'include matches when passed an array and matching against object with numbers',
|
|
349
|
+
[6, 7],
|
|
350
|
+
7
|
|
351
|
+
)
|
|
352
|
+
@test(
|
|
353
|
+
'include matches object with array property in array of objects',
|
|
354
|
+
[
|
|
355
|
+
{
|
|
356
|
+
methodName: 'use',
|
|
357
|
+
args: [null],
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
methodName: 'on',
|
|
361
|
+
args: ['confirm-pin', null],
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
methodName: 'on',
|
|
365
|
+
args: ['who-am-i', null],
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
methodName: 'on',
|
|
369
|
+
args: ['authenticate', null],
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
methodName: 'on',
|
|
373
|
+
args: ['can-listen', null],
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
methodName: 'emit',
|
|
377
|
+
args: ['test.what-an-event', null],
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
{
|
|
381
|
+
methodName: 'emit',
|
|
382
|
+
args: ['test.what-an-event', null],
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
protected static includeAndDoesNotInclude(haystack: any, needle: any) {
|
|
386
|
+
assert.doesInclude(haystack, needle)
|
|
387
|
+
assert.doesThrow(() => assert.doesNotInclude(haystack, needle))
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@test(
|
|
391
|
+
'include fails as expected with strings',
|
|
392
|
+
'taco',
|
|
393
|
+
'bravo',
|
|
394
|
+
/could not find(.*?)"bravo"/gis
|
|
395
|
+
)
|
|
396
|
+
@test(
|
|
397
|
+
'include fails as expected with regex obj on string',
|
|
398
|
+
'hello world',
|
|
399
|
+
new RegExp('cheeseball', 'gis')
|
|
400
|
+
)
|
|
401
|
+
@test(
|
|
402
|
+
'include fails as expected matching string against object',
|
|
403
|
+
{ hello: 'world' },
|
|
404
|
+
'taco',
|
|
405
|
+
/Could not find(.*?)taco/gis
|
|
406
|
+
)
|
|
407
|
+
@test(
|
|
408
|
+
'include fails as expected matching string against object with array',
|
|
409
|
+
{
|
|
410
|
+
flavors: [
|
|
411
|
+
{ size: 'large', toppings: [{ meat: true }, { cheese: true }] },
|
|
412
|
+
{ size: 'small' },
|
|
413
|
+
],
|
|
414
|
+
},
|
|
415
|
+
{ 'flavors[].toppings[].meat': false },
|
|
416
|
+
/could not find match(.*?)false(.*?)at(.*?)toppings\[\]\.meat/gis
|
|
417
|
+
)
|
|
418
|
+
@test(
|
|
419
|
+
'include fails as expected matching string against nested object',
|
|
420
|
+
{
|
|
421
|
+
cheese: { size: 'large', toppings: { meat: true } },
|
|
422
|
+
},
|
|
423
|
+
{ 'cheese.toppings.stink': false },
|
|
424
|
+
/the path(.*?)cheese.toppings.stink(.*?)was not found in/gis
|
|
425
|
+
)
|
|
426
|
+
@test(
|
|
427
|
+
'include fails as expected by not showing full object if path matches but value differs',
|
|
428
|
+
{
|
|
429
|
+
cheese: { size: 'large', toppings: { meat: true } },
|
|
430
|
+
},
|
|
431
|
+
{ 'cheese.toppings.meat': false },
|
|
432
|
+
/expected(.*?)false(.*?)but found(.*?)true(.*?)at(.*?)cheese.toppings.meat/gis
|
|
433
|
+
)
|
|
434
|
+
@test(
|
|
435
|
+
"include fails when can't find in an array",
|
|
436
|
+
[
|
|
437
|
+
{
|
|
438
|
+
name: 'schemas.types.ts',
|
|
439
|
+
description:
|
|
440
|
+
'Every schema you need based on all your contracts',
|
|
441
|
+
path: '/example/schemas.types.ts',
|
|
442
|
+
action: 'updated',
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
{
|
|
446
|
+
action: 'star',
|
|
447
|
+
},
|
|
448
|
+
/could not find(.*?)"action": "star"/gis
|
|
449
|
+
)
|
|
450
|
+
@test(
|
|
451
|
+
"include fails when can't find in an array",
|
|
452
|
+
[
|
|
453
|
+
{
|
|
454
|
+
name: 'schemas.types.ts',
|
|
455
|
+
description:
|
|
456
|
+
'Every schema you need based on all your contracts',
|
|
457
|
+
path: '/example/schemas.types.ts',
|
|
458
|
+
action: 'updated',
|
|
459
|
+
},
|
|
460
|
+
],
|
|
461
|
+
{
|
|
462
|
+
name: 'schemas.types.ts',
|
|
463
|
+
action: '2',
|
|
464
|
+
},
|
|
465
|
+
/could not find(.*?)"name": "schemas.types.ts"/gis
|
|
466
|
+
)
|
|
467
|
+
@test(
|
|
468
|
+
'include fails object props against regex',
|
|
469
|
+
{
|
|
470
|
+
results: {
|
|
471
|
+
errors: [new Error('test'), new Error('test2')],
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
'results.errors[].stack': /test3/,
|
|
476
|
+
},
|
|
477
|
+
/could not find match/i
|
|
478
|
+
)
|
|
479
|
+
@test(
|
|
480
|
+
'include fails when passed an array and matching against object',
|
|
481
|
+
['hey', 'there'],
|
|
482
|
+
{ name: 'hey', foo: 'bar' },
|
|
483
|
+
/could not find/i
|
|
484
|
+
)
|
|
485
|
+
@test(
|
|
486
|
+
'include fails when passed an array and matching against object with numbers',
|
|
487
|
+
[6, 7],
|
|
488
|
+
{ name: 7, foo: 6 },
|
|
489
|
+
/could not find/i
|
|
490
|
+
)
|
|
491
|
+
@test(
|
|
492
|
+
'include matches when passed an array and matching against numbers',
|
|
493
|
+
[6, 7],
|
|
494
|
+
9
|
|
495
|
+
)
|
|
496
|
+
@test(
|
|
497
|
+
'include fails when searching an object for a regex',
|
|
498
|
+
{ foo: 'bar', taco: 'bravo' },
|
|
499
|
+
/yummy/
|
|
500
|
+
)
|
|
501
|
+
protected static doesIncludeThrowsAsExpected(
|
|
502
|
+
haystack: any,
|
|
503
|
+
needle: any,
|
|
504
|
+
matcher: any
|
|
505
|
+
) {
|
|
506
|
+
const err = assert.doesThrow(
|
|
507
|
+
() => assert.doesInclude(haystack, needle),
|
|
508
|
+
matcher
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
assert.doesNotInclude(err.message, 'undefined')
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
@test()
|
|
515
|
+
protected static hasAllFunctionsAndPasses() {
|
|
516
|
+
const obj = { func1: () => {}, func2() {}, foo: 'bar' }
|
|
517
|
+
assert.hasAllFunctions(obj, ['func1', 'func2'])
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@test()
|
|
521
|
+
protected static hasAllFunctionsAndFails() {
|
|
522
|
+
const obj = { func1: () => {}, func2() {}, foo: 'bar' }
|
|
523
|
+
let errorHit = false
|
|
524
|
+
try {
|
|
525
|
+
assert.hasAllFunctions(obj, ['func1', 'func3'])
|
|
526
|
+
} catch (err: any) {
|
|
527
|
+
errorHit = true
|
|
528
|
+
assert.doesInclude(err.message, 'func3')
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
assert.isTrue(errorHit)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
@test()
|
|
535
|
+
protected static isTruthy() {
|
|
536
|
+
const run = (): string | undefined => {
|
|
537
|
+
return 'test'
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const value = run()
|
|
541
|
+
assert.isTruthy(value)
|
|
542
|
+
|
|
543
|
+
assert.isType<string>(value)
|
|
544
|
+
|
|
545
|
+
assert.doesThrow(() => assert.isTruthy(false), /is not truthy/)
|
|
546
|
+
assert.doesThrow(() => assert.isTruthy(undefined), /is not truthy/)
|
|
547
|
+
assert.doesThrow(() => assert.isTruthy(null), /is not truthy/)
|
|
548
|
+
assert.doesThrow(() => assert.isTruthy(0), /is not truthy/)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
@test()
|
|
552
|
+
protected static isFalsy() {
|
|
553
|
+
assert.isFalsy(null)
|
|
554
|
+
assert.isFalsy(0)
|
|
555
|
+
assert.isFalsy(undefined)
|
|
556
|
+
assert.isFalsy(false)
|
|
557
|
+
|
|
558
|
+
assert.doesThrow(() => assert.isFalsy(1), /is not falsy/)
|
|
559
|
+
assert.doesThrow(() => assert.isFalsy('undefined'), /is not falsy/)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
@test()
|
|
563
|
+
protected static isString() {
|
|
564
|
+
assert.isString('test')
|
|
565
|
+
assert.doesThrow(() => assert.isString(true), 'not a string')
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
@test()
|
|
569
|
+
protected static isTrue() {
|
|
570
|
+
assert.isTrue(true)
|
|
571
|
+
assert.doesThrow(() => assert.isTrue(false))
|
|
572
|
+
assert.doesThrow(() => assert.isTrue(undefined))
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
@test()
|
|
576
|
+
protected static isFalse() {
|
|
577
|
+
assert.isFalse(false)
|
|
578
|
+
assert.doesThrow(() => assert.isFalse(true))
|
|
579
|
+
assert.doesThrow(() => assert.isFalse(undefined))
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
@test()
|
|
583
|
+
protected static deepEqual() {
|
|
584
|
+
assert.isEqualDeep({ test: true }, { test: true })
|
|
585
|
+
assert.doesThrow(() =>
|
|
586
|
+
assert.isNotEqualDeep({ test: true }, { test: true })
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
assert.doesThrow(
|
|
590
|
+
() => assert.isEqualDeep({ test: true }, { test: false }),
|
|
591
|
+
/true => false/
|
|
592
|
+
)
|
|
593
|
+
assert.isNotEqualDeep({ test: true }, { test: false })
|
|
594
|
+
|
|
595
|
+
assert.doesThrow(
|
|
596
|
+
() => assert.isEqualDeep({ test: '1' }, { test: 1 }),
|
|
597
|
+
/"1" => 1/
|
|
598
|
+
)
|
|
599
|
+
|
|
600
|
+
assert.doesThrow(() =>
|
|
601
|
+
assert.isNotEqualDeep(
|
|
602
|
+
{ test: true, hello: 'world' },
|
|
603
|
+
{
|
|
604
|
+
test: true,
|
|
605
|
+
hello: 'world',
|
|
606
|
+
}
|
|
607
|
+
)
|
|
608
|
+
)
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
@test()
|
|
612
|
+
protected static isUndefined() {
|
|
613
|
+
assert.isUndefined(undefined)
|
|
614
|
+
assert.doesThrow(() => assert.isUndefined(true), /not undefined/)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
@test()
|
|
618
|
+
protected static isNotEqual() {
|
|
619
|
+
assert.isNotEqual(true, false)
|
|
620
|
+
assert.doesThrow(
|
|
621
|
+
() => assert.isNotEqual('do', 'do'),
|
|
622
|
+
/should not equal/
|
|
623
|
+
)
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
@test()
|
|
627
|
+
protected static fail() {
|
|
628
|
+
assert.doesThrow(() => assert.fail('waka waka'), 'waka waka')
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
@test()
|
|
632
|
+
protected static isObject() {
|
|
633
|
+
assert.isObject({ test: true })
|
|
634
|
+
assert.doesThrow(() => assert.isObject(true), /not an object/gi)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
@test()
|
|
638
|
+
protected static isLength() {
|
|
639
|
+
assert.isLength([], 0)
|
|
640
|
+
assert.isLength(['test'], 1)
|
|
641
|
+
assert.doesThrow(
|
|
642
|
+
() => assert.isLength(['test'], 4),
|
|
643
|
+
/expected length/gi
|
|
644
|
+
)
|
|
645
|
+
assert.doesThrow(() => assert.isLength(undefined, 4), /undefined/gi)
|
|
646
|
+
assert.doesThrow(() => assert.isLength(null, 4), /null/gi)
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
@test()
|
|
650
|
+
protected static isNull() {
|
|
651
|
+
assert.isNull(null)
|
|
652
|
+
assert.doesThrow(() => assert.isNull(false))
|
|
653
|
+
assert.doesThrow(() => assert.isNull(undefined))
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@test()
|
|
657
|
+
protected static isExactType() {
|
|
658
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
659
|
+
const test: 'first' | 'last' | null = null
|
|
660
|
+
assert.isExactType<typeof test, null>(true)
|
|
661
|
+
|
|
662
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
663
|
+
let test2: 'first' | 'last' | undefined
|
|
664
|
+
assert.isExactType<typeof test2, 'first' | 'last' | undefined>(true)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
@test()
|
|
668
|
+
protected static isArray() {
|
|
669
|
+
assert.isArray([])
|
|
670
|
+
assert.doesThrow(() => assert.isArray(true), /is not an array/)
|
|
671
|
+
|
|
672
|
+
let couldBeArray: number[] | undefined
|
|
673
|
+
couldBeArray = []
|
|
674
|
+
|
|
675
|
+
function test() {
|
|
676
|
+
assert.isArray(couldBeArray)
|
|
677
|
+
assert.isExactType<typeof couldBeArray, number[]>(true)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
test()
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
@test()
|
|
684
|
+
protected static isNumber() {
|
|
685
|
+
assert.doesThrow(() => assert.isNumber('test'))
|
|
686
|
+
assert.doesThrow(() => assert.isNumber('1'))
|
|
687
|
+
assert.isNumber(1)
|
|
688
|
+
assert.isNumber(2)
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
@test()
|
|
692
|
+
protected static canAssertIstanceOf() {
|
|
693
|
+
class Test {
|
|
694
|
+
public test = true
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
class Test2 {
|
|
698
|
+
public test = false
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const test = new Test()
|
|
702
|
+
const test2: any = true
|
|
703
|
+
const test3: any = { hello: 'world' }
|
|
704
|
+
const test4 = new Test2()
|
|
705
|
+
|
|
706
|
+
assert.doesThrow(() => assert.isInstanceOf(test2, Test))
|
|
707
|
+
assert.doesThrow(() => assert.isInstanceOf(test3, Test))
|
|
708
|
+
assert.doesThrow(() => assert.isInstanceOf(test4, Test))
|
|
709
|
+
assert.doesThrow(() => assert.isInstanceOf(test, Test2))
|
|
710
|
+
assert.isInstanceOf(test, Test)
|
|
711
|
+
// assert.isInstanceOf(test4, Test)
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
@test.skip('Example of pretty print. Remove skip() to see. Always fails.')
|
|
715
|
+
protected static printsNiceDiff() {
|
|
716
|
+
// assert.isEqualDeep(
|
|
717
|
+
// { test: true, taco: 'bell' },
|
|
718
|
+
// { test: false, burger: 'king' }
|
|
719
|
+
// )
|
|
720
|
+
|
|
721
|
+
// assert.isFalsy([new Error('yay')])
|
|
722
|
+
assert.isEqual('actual: string one', 'expected: string two')
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
@test.skip(
|
|
726
|
+
'Example of pretty print with does include. Remove only() to see. Always fails.'
|
|
727
|
+
)
|
|
728
|
+
protected static printsNiceDiffWithDoesInclude() {
|
|
729
|
+
this.simpleDoesIncludePrettyPrint()
|
|
730
|
+
|
|
731
|
+
assert.doesInclude(
|
|
732
|
+
[
|
|
733
|
+
{
|
|
734
|
+
body: generateId(),
|
|
735
|
+
classification: 'transactional',
|
|
736
|
+
source: {
|
|
737
|
+
isCore: true,
|
|
738
|
+
},
|
|
739
|
+
target: {
|
|
740
|
+
personId: generateId(),
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
body: generateId(),
|
|
745
|
+
classification: 'transactional',
|
|
746
|
+
source: {
|
|
747
|
+
isCore: true,
|
|
748
|
+
},
|
|
749
|
+
target: {
|
|
750
|
+
personId: generateId(),
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
],
|
|
754
|
+
{
|
|
755
|
+
target: {
|
|
756
|
+
address: '+1 555 555 5555',
|
|
757
|
+
personId: generateId(),
|
|
758
|
+
},
|
|
759
|
+
}
|
|
760
|
+
)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
private static simpleDoesIncludePrettyPrint() {
|
|
764
|
+
assert.doesInclude({ test: true, taco: 'bell' }, { test: false })
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
@test()
|
|
768
|
+
protected static async doesThrowMatchIsCaseInsensitive() {
|
|
769
|
+
assert.doesThrow(() => {
|
|
770
|
+
throw new Error('Match on string')
|
|
771
|
+
}, 'on STRING')
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
@test()
|
|
775
|
+
protected static async doesNotThrowRegexErrorIfStringNotFound() {
|
|
776
|
+
const err = assert.doesThrow(() => {
|
|
777
|
+
assert.doesInclude('hello', '+1 555 555 5555')
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
assert.doesNotInclude(err.message, 'Invalid regular')
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
@test()
|
|
784
|
+
protected static async canFindInBetween() {
|
|
785
|
+
assert.doesThrow(() => assert.isBetween(1, 2, 3))
|
|
786
|
+
assert.isBetween(3, 0, 5)
|
|
787
|
+
assert.doesThrow(() => assert.isBetween(3, 0, 3))
|
|
788
|
+
assert.isBetween(4, 3, 5)
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
@test()
|
|
792
|
+
protected static async isBetweenInclusive() {
|
|
793
|
+
assert.doesThrow(() => assert.isBetweenInclusive(1, 2, 3))
|
|
794
|
+
assert.isBetweenInclusive(3, 0, 5)
|
|
795
|
+
assert.isBetweenInclusive(1, 1, 1)
|
|
796
|
+
assert.doesThrow(() => assert.isBetweenInclusive(3, 0, 2))
|
|
797
|
+
assert.isBetweenInclusive(4, 3, 4)
|
|
798
|
+
assert.isBetweenInclusive(4, 4, 4)
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
@test()
|
|
802
|
+
protected static async doesThrowDoesNotCheckErrorStack() {
|
|
803
|
+
const err = new Error('taco')
|
|
804
|
+
err.stack = 'one two three'
|
|
805
|
+
|
|
806
|
+
assert.doesThrow(() => {
|
|
807
|
+
throw err
|
|
808
|
+
}, 'taco')
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
@test()
|
|
812
|
+
protected static async doesIncludeThrowsWithExpectedError() {
|
|
813
|
+
const haystack = [{ taco: 'breath' }]
|
|
814
|
+
const needle = [{ burrito: true }]
|
|
815
|
+
|
|
816
|
+
assert.doesThrow(
|
|
817
|
+
() =>
|
|
818
|
+
assert.doesInclude(
|
|
819
|
+
haystack,
|
|
820
|
+
needle,
|
|
821
|
+
`Oh no! I checked the map and could not find that pin anywhere! Try 'this.mapVc.addPin(...)'!`
|
|
822
|
+
),
|
|
823
|
+
'could not find that'
|
|
824
|
+
)
|
|
825
|
+
}
|
|
826
|
+
}
|