The test case data structure type looks like this:
export type type User = {
name: UserName;
email: Email;
createdAt: Date;
updatedAt: Date;
subscription: SubscriptionType;
stripeId: StripeId;
visits: Visits;
favouriteColours: Set<Colour>;
profile: Profile;
fileSystem: FileSystemItem;
}
User = {
name: string
name: type UserName = string
UserName;
email: string
email: type Email = string
Email;
createdAt: Date
createdAt: Date;
updatedAt: Date
updatedAt: Date;
subscription: SubscriptionType
subscription: type SubscriptionType = "pro" | "basic" | "free"
SubscriptionType;
stripeId: `cus_${string}`
stripeId: type StripeId = `cus_${string}`
StripeId;
visits: number
visits: type Visits = number
Visits;
favouriteColours: Set<Colour>
favouriteColours: interface Set<T>
Set<type Colour = PresetColours | `#${string}`
Colour>;
profile: Profile
profile: type Profile = {
type: 'listener';
boughtTracks: NonNegativeInteger;
} | {
type: 'artist';
publishedTracks: NonNegativeInteger;
}
Profile;
fileSystem: FileSystemItem
fileSystem: type FileSystemItem = {
name: FileName;
} & ({
type: 'directory';
children: FileSystemItem[];
} | {
type: 'file';
})
FileSystemItem;
};
type type SubscriptionType = "pro" | "basic" | "free"
SubscriptionType = 'pro' | 'basic' | 'free';
type type FileSystemItem = {
name: FileName;
} & ({
type: 'directory';
children: FileSystemItem[];
} | {
type: 'file';
})
FileSystemItem = {
name: string
name: type FileName = string
FileName;
} & (
| {
type: "directory"
type: 'directory';
children: FileSystemItem[]
children: type FileSystemItem = {
name: FileName;
} & ({
type: 'directory';
children: FileSystemItem[];
} | {
type: 'file';
})
FileSystemItem[];
}
| {
type: "file"
type: 'file';
}
);
type type Profile = {
type: 'listener';
boughtTracks: NonNegativeInteger;
} | {
type: 'artist';
publishedTracks: NonNegativeInteger;
}
Profile =
| {
type: "listener"
type: 'listener';
boughtTracks: number
boughtTracks: type NonNegativeInteger = number
NonNegativeInteger;
}
| {
type: "artist"
type: 'artist';
publishedTracks: number
publishedTracks: type NonNegativeInteger = number
NonNegativeInteger;
};
// every type here is to be checked and nominal-typed by validators
type type NonEmptyString = string
NonEmptyString = string;
type type UserName = string
UserName = type NonEmptyString = string
NonEmptyString;
type type Email = string
Email = type NonEmptyString = string
NonEmptyString;
type type StripeId = `cus_${string}`
StripeId = `cus_${string}`;
type type NonNegativeInteger = number
NonNegativeInteger = number;
type type Visits = number
Visits = type NonNegativeInteger = number
NonNegativeInteger;
type type PresetColours = "red" | "green" | "blue"
PresetColours = 'red' | 'green' | 'blue';
type type HexColour = `#${string}`
HexColour = `#${string}`;
type type Colour = PresetColours | `#${string}`
Colour = type PresetColours = "red" | "green" | "blue"
PresetColours | type HexColour = `#${string}`
HexColour;
type type FileName = string
FileName = string;
Most of the tests are performed automatically, the others you have to take my word for it (or check the code). PRs are welcome.
More detailed test case description and more context can be found in my blog post.