• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const assert = require('assert');
2const generateLocationInfoParserTests = require('../../../test/utils/generate-location-info-parser-tests');
3const { generateTestsForEachTreeAdapter } = require('../../../test/utils/common');
4const parseChunked = require('./utils/parse-chunked');
5
6generateLocationInfoParserTests(module.exports, 'ParserStream', (input, opts) =>
7    // NOTE: because of performance use bigger chunks here
8    parseChunked(input, opts, 100, 400)
9);
10
11generateTestsForEachTreeAdapter(module.exports, (_test, treeAdapter) => {
12    _test['Regression - location info for the implicitly generated <body>, <html> and <head> (GH-44)'] = function() {
13        const html = '</head><div class="test"></div></body></html>';
14
15        const opts = {
16            treeAdapter: treeAdapter,
17            sourceCodeLocationInfo: true
18        };
19
20        const document = parseChunked(html, opts).node;
21        const htmlEl = treeAdapter.getChildNodes(document)[0];
22        const headEl = treeAdapter.getChildNodes(htmlEl)[0];
23        const bodyEl = treeAdapter.getChildNodes(htmlEl)[1];
24
25        assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(htmlEl), null);
26        assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(headEl), null);
27        assert.strictEqual(treeAdapter.getNodeSourceCodeLocation(bodyEl), null);
28    };
29});
30