background-navigation-utils-module.test.js 636 B

1234567891011121314151617
  1. const test = require('node:test');
  2. const assert = require('node:assert/strict');
  3. const fs = require('node:fs');
  4. test('background imports navigation utils module', () => {
  5. const source = fs.readFileSync('background.js', 'utf8');
  6. assert.match(source, /background\/navigation-utils\.js/);
  7. });
  8. test('navigation utils module exposes a factory', () => {
  9. const source = fs.readFileSync('background/navigation-utils.js', 'utf8');
  10. const globalScope = {};
  11. const api = new Function('self', `${source}; return self.MultiPageBackgroundNavigationUtils;`)(globalScope);
  12. assert.equal(typeof api?.createNavigationUtils, 'function');
  13. });