-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffd4a87
commit 58fbc9f
Showing
14 changed files
with
1,357 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// babel.config.js | ||
module.exports = { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { | ||
node: "current" | ||
} | ||
} | ||
], | ||
"@babel/preset-typescript" | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://jestjs.io/docs/en/configuration.html | ||
|
||
module.exports = { | ||
// The test environment that will be used for testing | ||
testEnvironment: "jsdom", | ||
|
||
// A map from regular expressions to paths to transformers | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
testMatch: ["**/*.test.ts"] | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// import { arbitraryQuery } from "../output/output"; | ||
import * as Codegen from "./convert"; | ||
|
||
describe("includesOneOf", () => { | ||
it("Makes any sense whatsoever", () => { | ||
expect(Codegen.includesOneOf("dog", ["dog"])).toBeTruthy(); | ||
}); | ||
it("Works with multiple", () => { | ||
expect(Codegen.includesOneOf("dog", ["log", "dog"])).toBeTruthy(); | ||
}); | ||
it("Works with multiple even with nonsense everywhere", () => { | ||
expect(Codegen.includesOneOf("_____dog___", ["log", "dog"])).toBeTruthy(); | ||
}); | ||
it("Doesn't find something that's not there", () => { | ||
expect(Codegen.includesOneOf("dog", ["log"])).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe("sortASTs", () => { | ||
it("Puts mentions later", () => { | ||
const stable: Codegen.NamedType = [ | ||
"Object", | ||
"Stable" as Codegen.TypeName, | ||
"fc.record({horse: arbitraryHorse })" | ||
]; | ||
const horse: Codegen.NamedType = [ | ||
"Object", | ||
"Horse" as Codegen.TypeName, | ||
"fc.record({saddle: arbitrarySaddle})" | ||
]; | ||
const saddle: Codegen.NamedType = [ | ||
"Object", | ||
"Saddle" as Codegen.TypeName, | ||
"fc.record({chair: arbitraryChair})" | ||
]; | ||
const things: Codegen.NamedType = [ | ||
"Union", | ||
"Things" as Codegen.TypeName, | ||
"fc.oneof(arbitraryStable, arbitrarySaddle)" | ||
]; | ||
const expectedOrder = [saddle, horse, stable, things]; | ||
expect(Codegen.sortASTs([things, stable, horse, saddle])).toStrictEqual( | ||
expectedOrder | ||
); | ||
expect(Codegen.sortASTs([stable, horse, saddle, things])).toStrictEqual( | ||
expectedOrder | ||
); | ||
}); | ||
|
||
it("Does the twitter ones", () => { | ||
const Query: Codegen.NamedType = [ | ||
"Object", | ||
"Query" as Codegen.TypeName, | ||
`fc.record({Tweet: arbitraryTweet,Tweets: fc.array(arbitraryTweet),TweetsMeta: arbitraryMeta,User: arbitraryUser,Notifications: fc.array(arbitraryNotification),NotificationsMeta: arbitraryMeta})` | ||
]; | ||
const Tweet: Codegen.NamedType = [ | ||
"Object", | ||
"Tweet" as Codegen.TypeName, | ||
`fc.record({id: arbitraryID,body: arbitraryString,date: arbitraryDate,Author: arbitraryUser,Stats: arbitraryStat})` | ||
]; | ||
const User: Codegen.NamedType = [ | ||
"Object", | ||
"User" as Codegen.TypeName, | ||
`fc.record({id: arbitraryID,username: arbitraryString,first_name: arbitraryString,last_name: arbitraryString,full_name: arbitraryString,name: arbitraryString,avatar_url: arbitraryUrl})` | ||
]; | ||
const Stat: Codegen.NamedType = [ | ||
"Object", | ||
"Stat" as Codegen.TypeName, | ||
`fc.record({views: arbitraryInt,likes: arbitraryInt,retweets: arbitraryInt,responses: arbitraryInt})` | ||
]; | ||
const Meta: Codegen.NamedType = [ | ||
"Object", | ||
"Meta" as Codegen.TypeName, | ||
`fc.record({count: arbitraryInt})` | ||
]; | ||
const Notification: Codegen.NamedType = [ | ||
"Object", | ||
"Notification" as Codegen.TypeName, | ||
`fc.record({id: arbitraryID,date: arbitraryDate,type: arbitraryString})` | ||
]; | ||
const Mutation: Codegen.NamedType = [ | ||
"Object", | ||
"Mutation" as Codegen.TypeName, | ||
`fc.record({createTweet: arbitraryTweet,deleteTweet: arbitraryTweet,markTweetRead: arbitraryBoolean})` | ||
]; | ||
const StatOrNotification: Codegen.NamedType = [ | ||
"Union", | ||
"StatOrNotification" as Codegen.TypeName, | ||
`fc.oneof(arbitraryStat, arbitraryNotification)` | ||
]; | ||
|
||
const expectedTweetOrder = [ | ||
User, | ||
Stat, | ||
Tweet, | ||
Meta, | ||
Notification, | ||
Query, | ||
Mutation, | ||
StatOrNotification | ||
]; | ||
expect( | ||
Codegen.sortASTs([ | ||
Query, | ||
Tweet, | ||
User, | ||
Stat, | ||
Meta, | ||
Notification, | ||
Mutation, | ||
StatOrNotification | ||
]) | ||
).toStrictEqual(expectedTweetOrder); | ||
}); | ||
}); |
Oops, something went wrong.