'use strict'; // #1040: LibreJS license information for the browser bundle - a JS Web Labels // page at /jslicense.html, linked from every page with rel="jslicense". // Run: node tests/jsWebLabels.test.cjs const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const { LICENSES, bundleScripts, renderJsWebLabels, jsLicenseLink } = require('../models/lib/jsWebLabels.js'); const ROOT = path.join(__dirname, '..'); const read = f => fs.readFileSync(path.join(ROOT, f), 'utf8'); const manifest = [ { type: 'js', where: 'client', url: '/abc123.js?meteor_js_resource=true' }, { type: 'css', where: 'client', url: '/def.css?meteor_css_resource=true' }, { type: 'js', where: 'internal', url: '/internal.js' }, { type: 'asset', url: '/x.png' }, ]; // Positive. assert.deepEqual(bundleScripts(manifest), ['/abc123.js?meteor_js_resource=true'], 'scripts only, never css, assets or internal'); assert.deepEqual(bundleScripts(manifest, '/wekan/'), ['/wekan/abc123.js?meteor_js_resource=true'], 'under ROOT_URL\'s path'); const page = renderJsWebLabels({ scripts: bundleScripts(manifest), version: '12.43' }); assert.match(page, /