-
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.
- Loading branch information
1 parent
d5dfbdf
commit 8f05407
Showing
4 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/scrapers/news/sections/newsContent/nodes/__tests__/__snapshots__/span.test.ts.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`span node Span should parse and render 1`] = `"'''test'''"`; |
13 changes: 13 additions & 0 deletions
13
src/scrapers/news/sections/newsContent/nodes/__tests__/span.test.ts
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 @@ | ||
import { MediaWikiBuilder } from "@osrs-wiki/mediawiki-builder"; | ||
import parse from "node-html-parser"; | ||
|
||
import spanParser from "../span"; | ||
|
||
describe("span node", () => { | ||
test("Span should parse and render", () => { | ||
const root = parse("<span><b>test</b></span>"); | ||
const builder = new MediaWikiBuilder(); | ||
builder.addContents([spanParser(root.firstChild)].flat()); | ||
expect(builder.build()).toMatchSnapshot(); | ||
}); | ||
}); |
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,10 @@ | ||
import textParser from "./text"; | ||
import { ContentNodeParser } from "../types"; | ||
|
||
export const spanParser: ContentNodeParser = (node, options) => { | ||
const children = textParser(node, options); | ||
const childrenNodes = Array.isArray(children) ? children : [children]; | ||
return childrenNodes; | ||
}; | ||
|
||
export default spanParser; |