-
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
5c349cd
commit 71118d6
Showing
4 changed files
with
59 additions
and
14 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,17 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
nim-versions: ['1.0.0', '1.6.6', 'stable'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: jiro4989/setup-nim-action@v2 | ||
with: | ||
nim-version: ${{ matrix.nim-versions }} | ||
- run: nimble test -y |
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 unittest | ||
import htmlparser | ||
import strtabs | ||
import beautifulparser | ||
|
||
|
||
suite "beautifulparser": | ||
let htmlString = """ | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<a href="url">Link</a> | ||
<p class="p">Paragraph</p> | ||
<p class="p">Another paragraph</p> | ||
</body> | ||
</html> | ||
""" | ||
let html = parseHtml(htmlString) | ||
|
||
test "find title": | ||
let title = html.findNode("title") | ||
check title.isSome | ||
check title.get().innerText == "Test" | ||
|
||
test "find link": | ||
let link = html.findNode("a") | ||
check link.isSome | ||
check link.get().innerText == "Link" | ||
check link.get().attrs.getOrDefault("href", "") == "url" | ||
|
||
test "find paragraphs": | ||
let paragraphs = html.findAllNodes("p", {"class": "p"}) | ||
check paragraphs.len == 2 | ||
check paragraphs[0].innerText == "Paragraph" |
This file was deleted.
Oops, something went wrong.