-
-
Notifications
You must be signed in to change notification settings - Fork 232
/
location-info.test.ts
29 lines (24 loc) · 1.3 KB
/
location-info.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as assert from 'node:assert';
import { generateLocationInfoParserTests } from 'parse5-test-utils/utils/generate-location-info-parser-tests.js';
import { generateTestsForEachTreeAdapter } from 'parse5-test-utils/utils/common.js';
import { parseChunked } from './utils/parse-chunked.js';
generateLocationInfoParserTests('location-info', (input, opts) =>
// NOTE: because of performance use bigger chunks here
parseChunked({ input }, opts, 100, 400)
);
generateTestsForEachTreeAdapter('location-info', (treeAdapter) => {
test('Regression - location info for the implicitly generated <body>, <html> and <head> (GH-44)', () => {
const html = '</head><div class="test"></div></body></html>';
const opts = {
treeAdapter,
sourceCodeLocationInfo: true,
};
const document = parseChunked({ input: html }, opts).node;
const htmlEl = treeAdapter.getChildNodes(document)[0];
const headEl = treeAdapter.getChildNodes(htmlEl)[0];
const bodyEl = treeAdapter.getChildNodes(htmlEl)[1];
assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(htmlEl), null);
assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(headEl), null);
assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(bodyEl), null);
});
});