-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: react documentation commands can not be in sentence (#355)
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { extractSearchKey, getReactDocsSearchKey } from "./react-docs"; | ||
|
||
describe("React documentation command", () => { | ||
test.each([ | ||
["Hello world, please look into !docs useState Hello", "react/useState"], | ||
["!docs react/useState", "react/useState"], | ||
["Foo !docs react/useState bar", "react/useState"], | ||
["!react-docs react/useState", "react/useState"], | ||
["Foo bar, !react-docs , useState", undefined], | ||
[ | ||
"Hello world, check react dom docs, !docs createPortal hello", | ||
"react-dom/createPortal", | ||
], | ||
["!docs react-dom/createPortal", "react-dom/createPortal"], | ||
])(`should match the command in the message`, (message, expected) => { | ||
const search = extractSearchKey(message); | ||
const searchKey = getReactDocsSearchKey(search); | ||
|
||
expect(searchKey).toBe(expected); | ||
}); | ||
}); |
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