factorio-test 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/README.md +22 -0
- package/index.d.ts +88 -0
- package/package.json +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Factorio Test types
|
|
2
|
+
|
|
3
|
+
Contains types for Factorio Test, for use with [TypescriptToLua](https://github.com/TypescriptToLua/TypescriptToLua)
|
|
4
|
+
and [typed-factorio](https://github.com/GlassBricks/typed-factorio).
|
|
5
|
+
|
|
6
|
+
To use, install the `factorio-test` npm package:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install --save-dev factorio-test
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Add this to your `tsconfig.json`:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"compilerOptions": {
|
|
17
|
+
"types": [
|
|
18
|
+
"factorio-test"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
/// <reference types="luassert-tstl" />
|
|
3
|
+
|
|
4
|
+
declare var test: FactorioTest.TestCreator
|
|
5
|
+
declare var it: FactorioTest.TestCreator
|
|
6
|
+
declare var describe: FactorioTest.DescribeCreator
|
|
7
|
+
declare var before_all: FactorioTest.LifecycleFn
|
|
8
|
+
declare var after_all: FactorioTest.LifecycleFn
|
|
9
|
+
declare var before_each: FactorioTest.LifecycleFn
|
|
10
|
+
declare var after_each: FactorioTest.LifecycleFn
|
|
11
|
+
declare var after_test: FactorioTest.LifecycleFn
|
|
12
|
+
declare function async(timeout?: number): void
|
|
13
|
+
declare function done(): void
|
|
14
|
+
declare function on_tick(func: FactorioTest.OnTickFn): void
|
|
15
|
+
declare function after_ticks(ticks: number, func: FactorioTest.TestFn): void
|
|
16
|
+
declare function ticks_between_tests(ticks: number): void
|
|
17
|
+
declare function tags(...tags: string[]): void
|
|
18
|
+
|
|
19
|
+
/** @noSelf */
|
|
20
|
+
declare namespace FactorioTest {
|
|
21
|
+
interface Config {
|
|
22
|
+
default_timeout: number
|
|
23
|
+
default_ticks_between_tests: number
|
|
24
|
+
|
|
25
|
+
game_speed: number
|
|
26
|
+
|
|
27
|
+
log_passed_tests: boolean
|
|
28
|
+
log_skipped_tests: boolean
|
|
29
|
+
|
|
30
|
+
test_pattern?: string
|
|
31
|
+
tag_whitelist?: string[]
|
|
32
|
+
tag_blacklist?: string[]
|
|
33
|
+
|
|
34
|
+
before_test_run?(): void
|
|
35
|
+
after_test_run?(): void
|
|
36
|
+
|
|
37
|
+
sound_effects: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type TestFn = () => void
|
|
41
|
+
type HookFn = TestFn
|
|
42
|
+
type OnTickFn = (tick: number) => void | boolean
|
|
43
|
+
|
|
44
|
+
/** @noSelf */
|
|
45
|
+
interface TestCreatorBase {
|
|
46
|
+
(name: string, func: TestFn): TestBuilder
|
|
47
|
+
|
|
48
|
+
each<const V extends readonly any[]>(
|
|
49
|
+
values: readonly V[],
|
|
50
|
+
): (name: string, func: (...values: V) => void) => TestBuilder<typeof func>
|
|
51
|
+
each<const T>(values: readonly T[]): (name: string, func: (value: T) => void) => TestBuilder<typeof func>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @noSelf */
|
|
55
|
+
interface TestCreator extends TestCreatorBase {
|
|
56
|
+
skip: TestCreatorBase
|
|
57
|
+
only: TestCreatorBase
|
|
58
|
+
todo(name: string): void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @noSelf */
|
|
62
|
+
export interface TestBuilder<F extends (...args: any) => void = TestFn> {
|
|
63
|
+
after_script_reload(func: F): TestBuilder<F>
|
|
64
|
+
after_mod_reload(func: F): TestBuilder<F>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @noSelf */
|
|
68
|
+
interface DescribeBlockCreatorBase {
|
|
69
|
+
(name: string, func: TestFn): void
|
|
70
|
+
|
|
71
|
+
each<const V extends readonly any[]>(values: readonly V[]): (name: string, func: (...values: V) => void) => void
|
|
72
|
+
each<const T>(values: readonly T[]): (name: string, func: (value: T) => void) => void
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** @noSelf */
|
|
76
|
+
interface DescribeCreator extends DescribeBlockCreatorBase {
|
|
77
|
+
skip: DescribeBlockCreatorBase
|
|
78
|
+
only: DescribeBlockCreatorBase
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type LifecycleFn = (func: HookFn) => void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @noResolution */
|
|
85
|
+
declare module "__factorio-test__/init" {
|
|
86
|
+
function init(this: void, files: string[], config?: Partial<FactorioTest.Config>): void
|
|
87
|
+
export = init
|
|
88
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "factorio-test",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Type definitions for using Factorio Test with TypescriptToLua",
|
|
5
|
+
"files": [
|
|
6
|
+
"index.d.ts"
|
|
7
|
+
],
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"luassert-tstl": ">=0.2.3",
|
|
10
|
+
"typed-factorio": "^1.14.0"
|
|
11
|
+
}
|
|
12
|
+
}
|