venus-pit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ import { testRandomWord } from "./randomWord.test.js";
2
+ import { testTar } from "./tar.test.js";
3
+ import { testVenusRoot } from "./venusRoot.test.js";
4
+
5
+ const tests = [
6
+ { name: "randomWord", fn: testRandomWord },
7
+ { name: "tar", fn: testTar },
8
+ { name: "venusRoot", fn: testVenusRoot },
9
+ ];
10
+ let allPassed = true;
11
+
12
+ for (const { name, fn } of tests) {
13
+ const result = fn();
14
+ console.log(`${name}: ${result ? "PASS" : "FAIL"}`);
15
+ if (!result) {allPassed = false}
16
+ }
17
+
18
+ if (allPassed) {
19
+ console.log("all unit tests pass")
20
+ }
@@ -0,0 +1,10 @@
1
+ import { randomWord } from "../src/lib/tarpit/words/randomWord.js";
2
+
3
+ function testRandomWord() {
4
+ if (/^[a-z]+$/.test(randomWord().toLowerCase())) {
5
+ return true
6
+ } else {
7
+ return false
8
+ }
9
+ }
10
+ export {testRandomWord}
@@ -0,0 +1,24 @@
1
+ import { parse } from "node-html-parser";
2
+ import { tar } from "../src/lib/tarpit/tar.js";
3
+
4
+ function testTar() {
5
+ const str = tar("/SAMPLE/ROUTE/");
6
+ let worked = false;
7
+
8
+ try {
9
+ const root = parse(str);
10
+ const head = root.querySelector("head");
11
+ const body = root.querySelector("body");
12
+ const title = root.querySelector("title");
13
+ const link = root.querySelector("a[href='/SAMPLE/ROUTE/']");
14
+
15
+ worked = !!head && !!body && !!title && !!link;
16
+
17
+ } catch (e) {
18
+ worked = false;
19
+ }
20
+
21
+ return worked;
22
+ }
23
+
24
+ export { testTar };
@@ -0,0 +1,13 @@
1
+ import { venusRoot } from "../src/lib/venusRoot.js";
2
+
3
+ function testVenusRoot() {
4
+ let vRoot = new venusRoot()
5
+ let custom = new venusRoot("ello")
6
+ // 32 chars long + the two slashes
7
+ if (vRoot.path.length == 34 && custom.path == "/ello/") {
8
+ return true
9
+ }
10
+ return false
11
+ }
12
+
13
+ export {testVenusRoot}
Binary file