Skip to content

Commit

Permalink
Migrate test from japa to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu89 committed Aug 30, 2022
1 parent de7259b commit 72ab0af
Show file tree
Hide file tree
Showing 6 changed files with 536 additions and 558 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
dist/
coverage/
11 changes: 0 additions & 11 deletions bin/japaTypes.ts

This file was deleted.

36 changes: 0 additions & 36 deletions bin/test.ts

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
"clean": "rimraf dist",
"prepublishOnly": "npm run build",
"build": "npm run clean && tsup src/index.ts --format esm,cjs",
"test": "node --loader=ts-node/esm bin/test.ts"
"test": "vitest run",
"test:watch": "vitest",
"coverage": "vitest run --coverage"
},
"author": "zerologin",
"license": "MIT",
"dependencies": {
"bech32": "^2.0.0"
},
"devDependencies": {
"@japa/expect": "^1.1.4",
"@japa/runner": "^2.0.8",
"@japa/spec-reporter": "^1.1.12",
"@types/node": "^17.0.35",
"@vitest/coverage-c8": "^0.22.1",
"rimraf": "^3.0.2",
"ts-node": "^10.7.0",
"tsup": "^5.12.8",
"typescript": "^4.6.4"
"typescript": "^4.6.4",
"vitest": "^0.22.1"
},
"repository": {
"url": "http://github.com/zerologin/lnurl",
Expand All @@ -35,4 +36,4 @@
"files": [
"dist/"
]
}
}
46 changes: 22 additions & 24 deletions tests/lnurl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { test } from "@japa/runner";
import { test } from 'vitest'
import { encode, decode } from "../src/index.js";

test.group("LNURL", () => {
test("can encode", ({ expect }) => {
const unencoded =
"https://service.com/lnurl/auth?tag=login&k1=e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281&hmac=cae3ce867242f32a738ac6d0c60eeefd18df0618c6c0ab7eb4d833ddd584a161";
const encoded = encode(unencoded);
test("can encode", ({ expect }) => {
const unencoded =
"https://service.com/lnurl/auth?tag=login&k1=e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281&hmac=cae3ce867242f32a738ac6d0c60eeefd18df0618c6c0ab7eb4d833ddd584a161";
const encoded = encode(unencoded);

const expected =
"LNURL1DP68GURN8GHJ7UM9WFMXJCM99E3K7MF0D3H82UNV9ASH2ARG8A6XZEEAD3HKW6TWYE4NZ0T9XY6R2WTYX3JNZCEJV56NGDTP8QUKGWRYVE3RWEF4VDNRVCMP8YCXZVNY8PNRVETYXGCNWDEJXFJK2VEJX5UXXCNZVVMRYVPKXGURZFNGD4SKX0TRV9JNXCM98QMRWV35XFNRXVNPXUENSCTRXEJRQCEKXPJK2ETXVSCNSERXXQMRZWRRXE3NQCTZXAJKYDRY8QENXERYVS6NSDRPXYMRZAJXAKZ";
expect(encoded).toEqual(expected);
});
const expected =
"LNURL1DP68GURN8GHJ7UM9WFMXJCM99E3K7MF0D3H82UNV9ASH2ARG8A6XZEEAD3HKW6TWYE4NZ0T9XY6R2WTYX3JNZCEJV56NGDTP8QUKGWRYVE3RWEF4VDNRVCMP8YCXZVNY8PNRVETYXGCNWDEJXFJK2VEJX5UXXCNZVVMRYVPKXGURZFNGD4SKX0TRV9JNXCM98QMRWV35XFNRXVNPXUENSCTRXEJRQCEKXPJK2ETXVSCNSERXXQMRZWRRXE3NQCTZXAJKYDRY8QENXERYVS6NSDRPXYMRZAJXAKZ";
expect(encoded).toEqual(expected);
});

test("can decode", ({ expect }) => {
const encoded =
"lnurl1dp68gurn8ghj7um9wfmxjcm99e3k7mf0d3h82unv9ash2arg8a6xzeead3hkw6twye4nz0t9xy6r2wtyx3jnzcejv56ngdtp8qukgwryve3rwef4vdnrvcmp8ycxzvny8pnrvetyxgcnwdejxfjk2vejx5uxxcnzvvmryvpkxgurzfngd4skx0trv9jnxcm98qmrwv35xfnrxvnpxuensctrxejrqcekxpjk2etxvscnserxxqmrzwrrxe3nqctzxajkydry8qenxeryvs6nsdrpxymrzajxakz";
const decoded = decode(encoded);
test("can decode", ({ expect }) => {
const encoded =
"lnurl1dp68gurn8ghj7um9wfmxjcm99e3k7mf0d3h82unv9ash2arg8a6xzeead3hkw6twye4nz0t9xy6r2wtyx3jnzcejv56ngdtp8qukgwryve3rwef4vdnrvcmp8ycxzvny8pnrvetyxgcnwdejxfjk2vejx5uxxcnzvvmryvpkxgurzfngd4skx0trv9jnxcm98qmrwv35xfnrxvnpxuensctrxejrqcekxpjk2etxvscnserxxqmrzwrrxe3nqctzxajkydry8qenxeryvs6nsdrpxymrzajxakz";
const decoded = decode(encoded);

const expected =
{
decoded: "https://service.com/lnurl/auth?tag=login&k1=e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281&hmac=cae3ce867242f32a738ac6d0c60eeefd18df0618c6c0ab7eb4d833ddd584a161",
domain: "service.com",
action: "",
k1: "e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281",
tag: "login"
};
expect(decoded).toEqual(expected);
});
const expected =
{
decoded: "https://service.com/lnurl/auth?tag=login&k1=e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281&hmac=cae3ce867242f32a738ac6d0c60eeefd18df0618c6c0ab7eb4d833ddd584a161",
domain: "service.com",
action: "",
k1: "e1459d4e1c2e545a89d8dfb7e5cf6ca90a2d8f6ed217722ee3258cbbc6206281",
tag: "login"
};
expect(decoded).toEqual(expected);
});
Loading

0 comments on commit 72ab0af

Please sign in to comment.