Skip to content

Commit 0c1d744

Browse files
committed
Add compile-time type tests for generated loaders
1 parent 524daec commit 0c1d744

File tree

11 files changed

+1497
-1364
lines changed

11 files changed

+1497
-1364
lines changed

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
flow-typed
1+
examples/swapi/swapi-loaders.ts

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@ build: node_modules
1616
# Generate the .d.ts files
1717
node_modules/.bin/tsc --project tsconfig.json --checkJs false --emitDeclarationOnly || true
1818

19+
link-examples: build
20+
yarn link
21+
cd examples/swapi
22+
yarn link dataloader-codegen
23+
24+
build-examples: link-examples
25+
$(MAKE) -C examples/swapi swapi-loaders.ts
26+
$(MAKE) -C examples/swapi build
27+
node examples/swapi/build/swapi-server.js
28+
1929
.PHONY: test
20-
test: build venv node_modules
30+
test: build venv node_modules build-examples
2131
venv/bin/pre-commit install -f --install-hooks
2232
venv/bin/pre-commit run --all-files
2333
yarn test
34+
yarn test:exampleTypes
2435

2536
.PHONY: clean
2637
clean:

__tests__/implementation.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,15 +888,16 @@ test('batch endpoint with isBatchKeyASet handles a response', async () => {
888888

889889
const resources = {
890890
foo: ({ foo_ids, include_extra_info }) => {
891-
if (_.isEqual(foo_ids, [1, 2])) {
891+
expect(foo_ids).toBeInstanceOf(Set);
892+
if (_.isEqual(Array.from(foo_ids), [1, 2])) {
892893
expect(include_extra_info).toBe(false);
893894
return Promise.resolve([
894895
{ foo_id: 1, foo_value: 'hello' },
895896
{ foo_id: 2, foo_value: 'world' },
896897
]);
897898
}
898899

899-
if (_.isEqual(foo_ids, [3])) {
900+
if (_.isEqual(Array.from(foo_ids), [3])) {
900901
expect(include_extra_info).toBe(true);
901902
return Promise.resolve([
902903
{

0 commit comments

Comments
 (0)