background-tab-runtime-module.test.js 606 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 tab runtime module', () => {
  5. const source = fs.readFileSync('background.js', 'utf8');
  6. assert.match(source, /background\/tab-runtime\.js/);
  7. });
  8. test('tab runtime module exposes a factory', () => {
  9. const source = fs.readFileSync('background/tab-runtime.js', 'utf8');
  10. const globalScope = {};
  11. const api = new Function('self', `${source}; return self.MultiPageBackgroundTabRuntime;`)(globalScope);
  12. assert.equal(typeof api?.createTabRuntime, 'function');
  13. });