-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: stricter type checking on tag types of events (#24)
- Loading branch information
Showing
9 changed files
with
85 additions
and
47 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
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
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
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
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,36 @@ | ||
import { describe, it } from "../../lib/std/testing.ts"; | ||
import { assertType, Has } from "../../lib/std/testing.ts"; | ||
import { EventInit } from "../../lib/events.ts"; | ||
import "./protocol.d.ts"; | ||
|
||
describe("EventInit<22242>", () => { | ||
it("can be valid", () => { | ||
const init = { | ||
kind: 22242, | ||
content: "", | ||
tags: [ | ||
["relay", "wss://nos.lol", "string"], | ||
["challenge", "string"], | ||
], | ||
} satisfies EventInit<22242>; | ||
assertType<Has<typeof init, EventInit<22242>>>(true); | ||
}); | ||
it("tags should not be empty", () => { | ||
const init = { | ||
kind: 22242, | ||
content: "", | ||
// @ts-expect-error tags should not be empty | ||
tags: [], | ||
} satisfies EventInit<22242>; | ||
assertType<Has<typeof init, EventInit<22242>>>(false); | ||
}); | ||
it('tags should have "relay" and "challenge"', () => { | ||
const init = { | ||
kind: 22242, | ||
content: "", | ||
// @ts-expect-error tags should have "relay" and "challenge" | ||
tags: [["relay", "wss://nos.lol"]], | ||
} satisfies EventInit<22242>; | ||
assertType<Has<typeof init, EventInit<22242>>>(false); | ||
}); | ||
}); |