links-notation 0.25.1 → 0.26.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "links-notation",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "description": "Links Notation parser for JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "index.d.ts",
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "homepage": "https://github.com/link-foundation/links-notation#readme",
34
34
  "devDependencies": {
35
- "bun-types": "^1.4.2",
35
+ "bun-types": "^1.4.3",
36
36
  "eslint": "^10.12.0",
37
37
  "peggy": "^5.1.0",
38
- "prettier": "^3.9.9",
38
+ "prettier": "^3.9.10",
39
39
  "typescript": "^7.0.2"
40
40
  }
41
41
  }
@@ -0,0 +1,27 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { URL } from 'node:url';
3
+ import { expect, test } from 'bun:test';
4
+ import { Parser, StreamParser, formatLinks } from '../src/index.js';
5
+
6
+ const fixtures = JSON.parse(
7
+ readFileSync(
8
+ new URL('../../parity/text-fixtures.json', import.meta.url),
9
+ 'utf8'
10
+ )
11
+ );
12
+ const tree = (links) =>
13
+ links.map((link) => ({ id: link.id, values: tree(link.values) }));
14
+
15
+ test('shared text parity', () => {
16
+ for (const fixture of fixtures) {
17
+ const parsed = new Parser().parse(fixture.input);
18
+ expect(tree(parsed), fixture.id).toEqual(fixture.expected);
19
+ expect(formatLinks(parsed), fixture.id).toBe(fixture.format);
20
+ expect(tree(new Parser().parse(fixture.format)), fixture.id).toEqual(
21
+ fixture.expected
22
+ );
23
+ const stream = new StreamParser();
24
+ for (const character of fixture.input) stream.write(character);
25
+ expect(tree(stream.end()), fixture.id).toEqual(fixture.expected);
26
+ }
27
+ });