@everyonesoftware/common 2.0.0 → 3.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/.github/workflows/publish.yml +54 -36
- package/package.json +6 -2
- package/sources/asyncIterator.ts +436 -436
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
- package/sources/asyncResult.ts +95 -95
- package/sources/byteList.ts +201 -201
- package/sources/byteListStream.ts +120 -120
- package/sources/byteReadStream.ts +23 -23
- package/sources/byteWriteStream.ts +15 -15
- package/sources/characterList.ts +194 -194
- package/sources/characterListStream.ts +150 -150
- package/sources/characterReadStream.ts +80 -80
- package/sources/characterReadStreamIterator.ts +127 -127
- package/sources/concatenateIterable.ts +118 -118
- package/sources/concatenateIterator.ts +164 -164
- package/sources/currentProcess.ts +157 -157
- package/sources/dateTime.ts +129 -129
- package/sources/depthFirstSearch.ts +229 -229
- package/sources/flatMapIterable.ts +103 -103
- package/sources/flatMapIterator.ts +151 -151
- package/sources/generator.ts +250 -250
- package/sources/index.ts +1 -1
- package/sources/iterator.ts +480 -480
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
- package/sources/javascriptSetSet.ts +133 -133
- package/sources/listQueue.ts +61 -61
- package/sources/listStack.ts +61 -61
- package/sources/luxonDateTime.ts +108 -108
- package/sources/mapAsyncIterator.ts +140 -140
- package/sources/mutableMap.ts +291 -291
- package/sources/node.ts +36 -36
- package/sources/promiseAsyncResult.ts +173 -173
- package/sources/queue.ts +48 -48
- package/sources/recreationDotGovClient.ts +258 -258
- package/sources/searchControl.ts +41 -41
- package/sources/set.ts +243 -243
- package/sources/skipAsyncIterator.ts +144 -144
- package/sources/stack.ts +47 -47
- package/sources/syncResult.ts +299 -299
- package/sources/takeAsyncIterator.ts +140 -140
- package/sources/whereAsyncIterator.ts +142 -142
- package/sources/wonderlandTrailClient.ts +1502 -1502
- package/tests/assertTestTests.ts +74 -74
- package/tests/byteListStreamTests.ts +389 -389
- package/tests/byteListTests.ts +26 -26
- package/tests/characterListStreamTests.ts +390 -390
- package/tests/characterListTests.ts +249 -249
- package/tests/dateTimeTests.ts +29 -29
- package/tests/depthFirstSearchTests.ts +105 -105
- package/tests/generatorTests.ts +85 -85
- package/tests/mutableMapTests.ts +153 -153
- package/tests/promiseAsyncResultTests.ts +687 -687
- package/tests/queueTests.ts +28 -28
- package/tests/recreationDotGovClientTests.ts +190 -190
- package/tests/setTests.ts +139 -139
- package/tests/stackTests.ts +65 -65
- package/tests/syncResultTests.ts +1250 -1250
- package/tests/wonderlandTrailClientTests.ts +451 -451
- package/tsup.config.ts +12 -12
package/tests/queueTests.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { EmptyError } from "../sources/emptyError";
|
|
2
|
-
import { ListQueue } from "../sources/listQueue";
|
|
3
|
-
import { Queue } from "../sources/queue";
|
|
4
|
-
import { Test } from "./test";
|
|
5
|
-
import { TestRunner } from "./testRunner";
|
|
6
|
-
|
|
7
|
-
export function test(runner: TestRunner): void
|
|
8
|
-
{
|
|
9
|
-
runner.testFile("queue.ts", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testType("Queue<T>", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.testFunction("create()", (test: Test) =>
|
|
14
|
-
{
|
|
15
|
-
const queue: ListQueue<number> = Queue.create();
|
|
16
|
-
test.assertNotUndefinedAndNotNull(queue);
|
|
17
|
-
test.assertFalse(queue.any().await());
|
|
18
|
-
test.assertThrows(() => queue.remove().await(), new EmptyError());
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
runner.testFunction("add()", (test: Test) =>
|
|
22
|
-
{
|
|
23
|
-
const queue: ListQueue<number> = Queue.create();
|
|
24
|
-
queue.add(20).await();
|
|
25
|
-
test.assertEqual(20, queue.remove().await());
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
1
|
+
import { EmptyError } from "../sources/emptyError";
|
|
2
|
+
import { ListQueue } from "../sources/listQueue";
|
|
3
|
+
import { Queue } from "../sources/queue";
|
|
4
|
+
import { Test } from "./test";
|
|
5
|
+
import { TestRunner } from "./testRunner";
|
|
6
|
+
|
|
7
|
+
export function test(runner: TestRunner): void
|
|
8
|
+
{
|
|
9
|
+
runner.testFile("queue.ts", () =>
|
|
10
|
+
{
|
|
11
|
+
runner.testType("Queue<T>", () =>
|
|
12
|
+
{
|
|
13
|
+
runner.testFunction("create()", (test: Test) =>
|
|
14
|
+
{
|
|
15
|
+
const queue: ListQueue<number> = Queue.create();
|
|
16
|
+
test.assertNotUndefinedAndNotNull(queue);
|
|
17
|
+
test.assertFalse(queue.any().await());
|
|
18
|
+
test.assertThrows(() => queue.remove().await(), new EmptyError());
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
runner.testFunction("add()", (test: Test) =>
|
|
22
|
+
{
|
|
23
|
+
const queue: ListQueue<number> = Queue.create();
|
|
24
|
+
queue.add(20).await();
|
|
25
|
+
test.assertEqual(20, queue.remove().await());
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
29
|
}
|
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
import { HttpClient } from "../sources/httpClient";
|
|
2
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
3
|
-
import { RecreationDotGovClient, RecreationDotGovDivisionAvailability, RecreationDotGovDivisionAvailabilityJson, RecreationDotGovError, RecreationDotGovPermitItineraryJson } from "../sources/recreationDotGovClient";
|
|
4
|
-
import { WonderlandTrailClient, WonderlandTrailLocations } from "../sources/wonderlandTrailClient";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
import { hasNetworkAccess } from "./tests";
|
|
8
|
-
|
|
9
|
-
export function test(runner: TestRunner): void
|
|
10
|
-
{
|
|
11
|
-
runner.testFile("recreationDotGovClient.ts", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.testType("RecreationDotGovClient", () =>
|
|
14
|
-
{
|
|
15
|
-
runner.testFunction("create()", () =>
|
|
16
|
-
{
|
|
17
|
-
function createErrorTest(httpClient: HttpClient, expected: Error): void
|
|
18
|
-
{
|
|
19
|
-
runner.test(`with ${runner.toString(httpClient)}`, (test: Test) =>
|
|
20
|
-
{
|
|
21
|
-
test.assertThrows(() => RecreationDotGovClient.create(httpClient), expected);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
createErrorTest(undefined!, new PreConditionError(
|
|
26
|
-
"Expression: httpClient",
|
|
27
|
-
"Expected: not undefined and not null",
|
|
28
|
-
"Actual: undefined",
|
|
29
|
-
));
|
|
30
|
-
createErrorTest(null!, new PreConditionError(
|
|
31
|
-
"Expression: httpClient",
|
|
32
|
-
"Expected: not undefined and not null",
|
|
33
|
-
"Actual: null",
|
|
34
|
-
));
|
|
35
|
-
|
|
36
|
-
runner.test("with default HttpClient", (test: Test) =>
|
|
37
|
-
{
|
|
38
|
-
const httpClient: HttpClient = HttpClient.create();
|
|
39
|
-
const recreationDotGovClient: RecreationDotGovClient = RecreationDotGovClient.create(httpClient);
|
|
40
|
-
test.assertNotUndefinedAndNotNull(recreationDotGovClient);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
runner.testFunction("getPermitItinerary()", () =>
|
|
45
|
-
{
|
|
46
|
-
function getPermitItineraryErrorTest(itineraryId: string, expected: Error): void
|
|
47
|
-
{
|
|
48
|
-
runner.test(`with ${runner.toString(itineraryId)}`, async (test: Test) =>
|
|
49
|
-
{
|
|
50
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
51
|
-
await test.assertThrowsAsync(async () => await client.getPermitItinerary(itineraryId), expected);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
getPermitItineraryErrorTest(undefined!, new PreConditionError(
|
|
56
|
-
"Expression: permitItineraryId",
|
|
57
|
-
"Expected: not undefined and not null",
|
|
58
|
-
"Actual: undefined",
|
|
59
|
-
));
|
|
60
|
-
getPermitItineraryErrorTest(null!, new PreConditionError(
|
|
61
|
-
"Expression: permitItineraryId",
|
|
62
|
-
"Expected: not undefined and not null",
|
|
63
|
-
"Actual: null",
|
|
64
|
-
));
|
|
65
|
-
getPermitItineraryErrorTest("", new PreConditionError(
|
|
66
|
-
"Expression: permitItineraryId",
|
|
67
|
-
"Expected: not empty",
|
|
68
|
-
"Actual: \"\"",
|
|
69
|
-
));
|
|
70
|
-
|
|
71
|
-
runner.test("with invalid permit itinerary id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
72
|
-
{
|
|
73
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
74
|
-
await test.assertThrowsAsync(
|
|
75
|
-
async () => await client.getPermitItinerary("oopsie!"),
|
|
76
|
-
new RecreationDotGovError(
|
|
77
|
-
`No permit itinerary found for id: "oopsie!"`,
|
|
78
|
-
),
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
runner.test("with valid permit itinerary id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
83
|
-
{
|
|
84
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
85
|
-
const result: RecreationDotGovPermitItineraryJson = await client.getPermitItinerary(WonderlandTrailClient.permitItineraryId);
|
|
86
|
-
test.assertNotUndefinedAndNotNull(result);
|
|
87
|
-
test.assertEqual(result.id, WonderlandTrailClient.permitItineraryId);
|
|
88
|
-
test.assertEqual(result.name, "Mount Rainier National Park Wilderness and Climbing Permits");
|
|
89
|
-
test.assertNotUndefinedAndNotNull(result.divisions);
|
|
90
|
-
test.assertTrue(Object.keys(result.divisions).length > 0);
|
|
91
|
-
for (const division of Object.values(result.divisions))
|
|
92
|
-
{
|
|
93
|
-
test.assertNotUndefinedAndNotNull(division.id);
|
|
94
|
-
test.assertNotUndefinedAndNotNull(division.district);
|
|
95
|
-
test.assertNotUndefinedAndNotNull(division.name);
|
|
96
|
-
test.assertNotUndefinedAndNotNull(division.type);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
runner.testFunction("getDivisionAvailability()", () =>
|
|
102
|
-
{
|
|
103
|
-
function getDivisionAvailabilityErrorTest(itineraryId: string, divisionId: string, month: number, year: number, expected: Error): void
|
|
104
|
-
{
|
|
105
|
-
runner.test(`with ${runner.andList([itineraryId, divisionId, month, year])}`, async (test: Test) =>
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getDivisionAvailabilityErrorTest(undefined!, "fake-division-id", 5, 2026, new PreConditionError(
|
|
112
|
-
"Expression: permitItineraryId",
|
|
113
|
-
"Expected: not undefined and not null",
|
|
114
|
-
"Actual: undefined",
|
|
115
|
-
));
|
|
116
|
-
getDivisionAvailabilityErrorTest(null!, "fake-division-id", 5, 2026, new PreConditionError(
|
|
117
|
-
"Expression: permitItineraryId",
|
|
118
|
-
"Expected: not undefined and not null",
|
|
119
|
-
"Actual: null",
|
|
120
|
-
));
|
|
121
|
-
getDivisionAvailabilityErrorTest("", "fake-division-id", 5, 2026, new PreConditionError(
|
|
122
|
-
"Expression: permitItineraryId",
|
|
123
|
-
"Expected: not empty",
|
|
124
|
-
"Actual: \"\"",
|
|
125
|
-
));
|
|
126
|
-
getDivisionAvailabilityErrorTest("oopsie!", "fake-division-id", 5, 2026, new RecreationDotGovError(
|
|
127
|
-
`No permit itinerary found for id: "oopsie!"`,
|
|
128
|
-
));
|
|
129
|
-
|
|
130
|
-
runner.test("with invalid division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
131
|
-
{
|
|
132
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
133
|
-
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
134
|
-
const divisionId: string = "fake-division-id";
|
|
135
|
-
const month: number = 5;
|
|
136
|
-
const year: number = 2026;
|
|
137
|
-
const earlyAccessPermitLotteryId: string = "";
|
|
138
|
-
|
|
139
|
-
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
140
|
-
|
|
141
|
-
test.assertNotUndefinedAndNotNull(response);
|
|
142
|
-
test.assertNotUndefinedAndNotNull(response.json);
|
|
143
|
-
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
144
|
-
test.assertEqual(0, response.dayAvailabilities.getCount().await());
|
|
145
|
-
test.assertUndefined(response.maximumGroupSize);
|
|
146
|
-
test.assertUndefined(response.minimumGroupSize);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
runner.test("with Sunrise Camp division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
150
|
-
{
|
|
151
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
152
|
-
|
|
153
|
-
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
154
|
-
const divisionId: string = WonderlandTrailLocations.sunriseCamp.divisionId;
|
|
155
|
-
const month: number = 8;
|
|
156
|
-
const year: number = 2026;
|
|
157
|
-
const earlyAccessPermitLotteryId: string = "";
|
|
158
|
-
|
|
159
|
-
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
160
|
-
|
|
161
|
-
test.assertNotUndefinedAndNotNull(response);
|
|
162
|
-
test.assertNotUndefinedAndNotNull(response.json);
|
|
163
|
-
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
164
|
-
test.assertEqual(31, response.dayAvailabilities.getCount().await());
|
|
165
|
-
test.assertNotUndefinedAndNotNull(response.maximumGroupSize);
|
|
166
|
-
test.assertNotUndefinedAndNotNull(response.minimumGroupSize);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
runner.test("with Indian Bar division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
170
|
-
{
|
|
171
|
-
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
172
|
-
|
|
173
|
-
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
174
|
-
const divisionId: string = WonderlandTrailLocations.indianBar.divisionId;
|
|
175
|
-
const month: number = 7;
|
|
176
|
-
const year: number = 2026;
|
|
177
|
-
const earlyAccessPermitLotteryId: string = "";
|
|
178
|
-
|
|
179
|
-
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
180
|
-
|
|
181
|
-
test.assertNotUndefinedAndNotNull(response);
|
|
182
|
-
test.assertNotUndefinedAndNotNull(response.json);
|
|
183
|
-
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
184
|
-
test.assertEqual(31, response.dayAvailabilities.getCount().await());
|
|
185
|
-
test.assertNotUndefinedAndNotNull(response.maximumGroupSize);
|
|
186
|
-
test.assertNotUndefinedAndNotNull(response.minimumGroupSize);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
1
|
+
import { HttpClient } from "../sources/httpClient";
|
|
2
|
+
import { PreConditionError } from "../sources/preConditionError";
|
|
3
|
+
import { RecreationDotGovClient, RecreationDotGovDivisionAvailability, RecreationDotGovDivisionAvailabilityJson, RecreationDotGovError, RecreationDotGovPermitItineraryJson } from "../sources/recreationDotGovClient";
|
|
4
|
+
import { WonderlandTrailClient, WonderlandTrailLocations } from "../sources/wonderlandTrailClient";
|
|
5
|
+
import { Test } from "./test";
|
|
6
|
+
import { TestRunner } from "./testRunner";
|
|
7
|
+
import { hasNetworkAccess } from "./tests";
|
|
8
|
+
|
|
9
|
+
export function test(runner: TestRunner): void
|
|
10
|
+
{
|
|
11
|
+
runner.testFile("recreationDotGovClient.ts", () =>
|
|
12
|
+
{
|
|
13
|
+
runner.testType("RecreationDotGovClient", () =>
|
|
14
|
+
{
|
|
15
|
+
runner.testFunction("create()", () =>
|
|
16
|
+
{
|
|
17
|
+
function createErrorTest(httpClient: HttpClient, expected: Error): void
|
|
18
|
+
{
|
|
19
|
+
runner.test(`with ${runner.toString(httpClient)}`, (test: Test) =>
|
|
20
|
+
{
|
|
21
|
+
test.assertThrows(() => RecreationDotGovClient.create(httpClient), expected);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
createErrorTest(undefined!, new PreConditionError(
|
|
26
|
+
"Expression: httpClient",
|
|
27
|
+
"Expected: not undefined and not null",
|
|
28
|
+
"Actual: undefined",
|
|
29
|
+
));
|
|
30
|
+
createErrorTest(null!, new PreConditionError(
|
|
31
|
+
"Expression: httpClient",
|
|
32
|
+
"Expected: not undefined and not null",
|
|
33
|
+
"Actual: null",
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
runner.test("with default HttpClient", (test: Test) =>
|
|
37
|
+
{
|
|
38
|
+
const httpClient: HttpClient = HttpClient.create();
|
|
39
|
+
const recreationDotGovClient: RecreationDotGovClient = RecreationDotGovClient.create(httpClient);
|
|
40
|
+
test.assertNotUndefinedAndNotNull(recreationDotGovClient);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
runner.testFunction("getPermitItinerary()", () =>
|
|
45
|
+
{
|
|
46
|
+
function getPermitItineraryErrorTest(itineraryId: string, expected: Error): void
|
|
47
|
+
{
|
|
48
|
+
runner.test(`with ${runner.toString(itineraryId)}`, async (test: Test) =>
|
|
49
|
+
{
|
|
50
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
51
|
+
await test.assertThrowsAsync(async () => await client.getPermitItinerary(itineraryId), expected);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getPermitItineraryErrorTest(undefined!, new PreConditionError(
|
|
56
|
+
"Expression: permitItineraryId",
|
|
57
|
+
"Expected: not undefined and not null",
|
|
58
|
+
"Actual: undefined",
|
|
59
|
+
));
|
|
60
|
+
getPermitItineraryErrorTest(null!, new PreConditionError(
|
|
61
|
+
"Expression: permitItineraryId",
|
|
62
|
+
"Expected: not undefined and not null",
|
|
63
|
+
"Actual: null",
|
|
64
|
+
));
|
|
65
|
+
getPermitItineraryErrorTest("", new PreConditionError(
|
|
66
|
+
"Expression: permitItineraryId",
|
|
67
|
+
"Expected: not empty",
|
|
68
|
+
"Actual: \"\"",
|
|
69
|
+
));
|
|
70
|
+
|
|
71
|
+
runner.test("with invalid permit itinerary id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
72
|
+
{
|
|
73
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
74
|
+
await test.assertThrowsAsync(
|
|
75
|
+
async () => await client.getPermitItinerary("oopsie!"),
|
|
76
|
+
new RecreationDotGovError(
|
|
77
|
+
`No permit itinerary found for id: "oopsie!"`,
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
runner.test("with valid permit itinerary id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
83
|
+
{
|
|
84
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
85
|
+
const result: RecreationDotGovPermitItineraryJson = await client.getPermitItinerary(WonderlandTrailClient.permitItineraryId);
|
|
86
|
+
test.assertNotUndefinedAndNotNull(result);
|
|
87
|
+
test.assertEqual(result.id, WonderlandTrailClient.permitItineraryId);
|
|
88
|
+
test.assertEqual(result.name, "Mount Rainier National Park Wilderness and Climbing Permits");
|
|
89
|
+
test.assertNotUndefinedAndNotNull(result.divisions);
|
|
90
|
+
test.assertTrue(Object.keys(result.divisions).length > 0);
|
|
91
|
+
for (const division of Object.values(result.divisions))
|
|
92
|
+
{
|
|
93
|
+
test.assertNotUndefinedAndNotNull(division.id);
|
|
94
|
+
test.assertNotUndefinedAndNotNull(division.district);
|
|
95
|
+
test.assertNotUndefinedAndNotNull(division.name);
|
|
96
|
+
test.assertNotUndefinedAndNotNull(division.type);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
runner.testFunction("getDivisionAvailability()", () =>
|
|
102
|
+
{
|
|
103
|
+
function getDivisionAvailabilityErrorTest(itineraryId: string, divisionId: string, month: number, year: number, expected: Error): void
|
|
104
|
+
{
|
|
105
|
+
runner.test(`with ${runner.andList([itineraryId, divisionId, month, year])}`, async (test: Test) =>
|
|
106
|
+
{
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getDivisionAvailabilityErrorTest(undefined!, "fake-division-id", 5, 2026, new PreConditionError(
|
|
112
|
+
"Expression: permitItineraryId",
|
|
113
|
+
"Expected: not undefined and not null",
|
|
114
|
+
"Actual: undefined",
|
|
115
|
+
));
|
|
116
|
+
getDivisionAvailabilityErrorTest(null!, "fake-division-id", 5, 2026, new PreConditionError(
|
|
117
|
+
"Expression: permitItineraryId",
|
|
118
|
+
"Expected: not undefined and not null",
|
|
119
|
+
"Actual: null",
|
|
120
|
+
));
|
|
121
|
+
getDivisionAvailabilityErrorTest("", "fake-division-id", 5, 2026, new PreConditionError(
|
|
122
|
+
"Expression: permitItineraryId",
|
|
123
|
+
"Expected: not empty",
|
|
124
|
+
"Actual: \"\"",
|
|
125
|
+
));
|
|
126
|
+
getDivisionAvailabilityErrorTest("oopsie!", "fake-division-id", 5, 2026, new RecreationDotGovError(
|
|
127
|
+
`No permit itinerary found for id: "oopsie!"`,
|
|
128
|
+
));
|
|
129
|
+
|
|
130
|
+
runner.test("with invalid division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
131
|
+
{
|
|
132
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
133
|
+
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
134
|
+
const divisionId: string = "fake-division-id";
|
|
135
|
+
const month: number = 5;
|
|
136
|
+
const year: number = 2026;
|
|
137
|
+
const earlyAccessPermitLotteryId: string = "";
|
|
138
|
+
|
|
139
|
+
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
140
|
+
|
|
141
|
+
test.assertNotUndefinedAndNotNull(response);
|
|
142
|
+
test.assertNotUndefinedAndNotNull(response.json);
|
|
143
|
+
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
144
|
+
test.assertEqual(0, response.dayAvailabilities.getCount().await());
|
|
145
|
+
test.assertUndefined(response.maximumGroupSize);
|
|
146
|
+
test.assertUndefined(response.minimumGroupSize);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
runner.test("with Sunrise Camp division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
150
|
+
{
|
|
151
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
152
|
+
|
|
153
|
+
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
154
|
+
const divisionId: string = WonderlandTrailLocations.sunriseCamp.divisionId;
|
|
155
|
+
const month: number = 8;
|
|
156
|
+
const year: number = 2026;
|
|
157
|
+
const earlyAccessPermitLotteryId: string = "";
|
|
158
|
+
|
|
159
|
+
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
160
|
+
|
|
161
|
+
test.assertNotUndefinedAndNotNull(response);
|
|
162
|
+
test.assertNotUndefinedAndNotNull(response.json);
|
|
163
|
+
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
164
|
+
test.assertEqual(31, response.dayAvailabilities.getCount().await());
|
|
165
|
+
test.assertNotUndefinedAndNotNull(response.maximumGroupSize);
|
|
166
|
+
test.assertNotUndefinedAndNotNull(response.minimumGroupSize);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
runner.test("with Indian Bar division id", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
170
|
+
{
|
|
171
|
+
const client: RecreationDotGovClient = RecreationDotGovClient.create(HttpClient.create());
|
|
172
|
+
|
|
173
|
+
const itineraryId: string = WonderlandTrailClient.permitItineraryId;
|
|
174
|
+
const divisionId: string = WonderlandTrailLocations.indianBar.divisionId;
|
|
175
|
+
const month: number = 7;
|
|
176
|
+
const year: number = 2026;
|
|
177
|
+
const earlyAccessPermitLotteryId: string = "";
|
|
178
|
+
|
|
179
|
+
const response: RecreationDotGovDivisionAvailability = await client.getDivisionAvailability(itineraryId, divisionId, month, year, earlyAccessPermitLotteryId);
|
|
180
|
+
|
|
181
|
+
test.assertNotUndefinedAndNotNull(response);
|
|
182
|
+
test.assertNotUndefinedAndNotNull(response.json);
|
|
183
|
+
test.assertNotUndefinedAndNotNull(response.dayAvailabilities);
|
|
184
|
+
test.assertEqual(31, response.dayAvailabilities.getCount().await());
|
|
185
|
+
test.assertNotUndefinedAndNotNull(response.maximumGroupSize);
|
|
186
|
+
test.assertNotUndefinedAndNotNull(response.minimumGroupSize);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
191
|
}
|