@furystack/utils 2.0.2 → 2.0.3
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/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/path-helper.d.ts +1 -36
- package/dist/path-helper.d.ts.map +1 -1
- package/dist/path-helper.js +2 -73
- package/dist/path-helper.js.map +1 -1
- package/dist/path-helper.spec.d.ts.map +1 -1
- package/dist/path-helper.spec.js +2 -82
- package/dist/path-helper.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -2
- package/src/path-helper.spec.ts +2 -101
- package/src/path-helper.ts +2 -77
- package/dist/filter-async.d.ts +0 -20
- package/dist/filter-async.d.ts.map +0 -1
- package/dist/filter-async.js +0 -23
- package/dist/filter-async.js.map +0 -1
- package/dist/filter-async.spec.d.ts +0 -2
- package/dist/filter-async.spec.d.ts.map +0 -1
- package/dist/filter-async.spec.js +0 -25
- package/dist/filter-async.spec.js.map +0 -1
- package/dist/retrier-options.d.ts +0 -50
- package/dist/retrier-options.d.ts.map +0 -1
- package/dist/retrier-options.js +0 -54
- package/dist/retrier-options.js.map +0 -1
- package/dist/retrier.d.ts +0 -52
- package/dist/retrier.d.ts.map +0 -1
- package/dist/retrier.js +0 -103
- package/dist/retrier.js.map +0 -1
- package/dist/retries.spec.d.ts +0 -5
- package/dist/retries.spec.d.ts.map +0 -1
- package/dist/retries.spec.js +0 -93
- package/dist/retries.spec.js.map +0 -1
- package/src/filter-async.spec.ts +0 -25
- package/src/filter-async.ts +0 -29
- package/src/retrier-options.ts +0 -65
- package/src/retrier.ts +0 -105
- package/src/retries.spec.ts +0 -98
package/src/retries.spec.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Retrier } from './retrier'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Retrier tests
|
|
5
|
-
*/
|
|
6
|
-
export const retrierTests = describe('Retrier', () => {
|
|
7
|
-
describe('Counter', () => {
|
|
8
|
-
it('Should be able to count to 3', async () => {
|
|
9
|
-
let count = 0
|
|
10
|
-
await Retrier.create(async () => {
|
|
11
|
-
count = count + 1
|
|
12
|
-
return count === 3
|
|
13
|
-
}).run()
|
|
14
|
-
expect(count).toBe(3)
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('events', () => {
|
|
19
|
-
it('should trigger onSuccess on success', async () => {
|
|
20
|
-
let triggered = false
|
|
21
|
-
await Retrier.create(async () => true)
|
|
22
|
-
.setup({
|
|
23
|
-
onSuccess: () => {
|
|
24
|
-
triggered = true
|
|
25
|
-
},
|
|
26
|
-
})
|
|
27
|
-
.run()
|
|
28
|
-
|
|
29
|
-
expect(triggered).toBe(true)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should trigger onTimeout on timeout', async () => {
|
|
33
|
-
let triggered = false
|
|
34
|
-
await Retrier.create(async () => false)
|
|
35
|
-
.setup({
|
|
36
|
-
onFail: () => {
|
|
37
|
-
triggered = true
|
|
38
|
-
},
|
|
39
|
-
timeoutMs: 1,
|
|
40
|
-
})
|
|
41
|
-
.run()
|
|
42
|
-
|
|
43
|
-
expect(triggered).toBe(true)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should trigger onTry on each try', async () => {
|
|
47
|
-
let triggered = false
|
|
48
|
-
await Retrier.create(async () => true)
|
|
49
|
-
.setup({
|
|
50
|
-
onTry: () => {
|
|
51
|
-
triggered = true
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
.run()
|
|
55
|
-
expect(triggered).toBe(true)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should work with an example test', async () => {
|
|
60
|
-
const funcToRetry: () => Promise<boolean> = async () => {
|
|
61
|
-
const hasSucceeded = false
|
|
62
|
-
// ...
|
|
63
|
-
// custom logic
|
|
64
|
-
// ...
|
|
65
|
-
return hasSucceeded
|
|
66
|
-
}
|
|
67
|
-
const retrierSuccess = await Retrier.create(funcToRetry)
|
|
68
|
-
.setup({
|
|
69
|
-
Retries: 3,
|
|
70
|
-
RetryIntervalMs: 1,
|
|
71
|
-
timeoutMs: 1000,
|
|
72
|
-
})
|
|
73
|
-
.run()
|
|
74
|
-
|
|
75
|
-
expect(retrierSuccess).toBe(false)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('should throw error when started twice', async () => {
|
|
79
|
-
const retrier = Retrier.create(async () => false)
|
|
80
|
-
retrier.run()
|
|
81
|
-
try {
|
|
82
|
-
await retrier.run()
|
|
83
|
-
throw Error('Should have been failed')
|
|
84
|
-
} catch (error) {
|
|
85
|
-
// ignore
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('should throw an error when trying to set up after started', () => {
|
|
90
|
-
const retrier = Retrier.create(async () => false)
|
|
91
|
-
retrier.run()
|
|
92
|
-
expect(() => {
|
|
93
|
-
retrier.setup({
|
|
94
|
-
Retries: 2,
|
|
95
|
-
})
|
|
96
|
-
}).toThrow()
|
|
97
|
-
})
|
|
98
|
-
})
|