import { describe, expect, it } from 'vitest' import { FIREFOX_EXTENSION_ID, firefoxManifest, transformManifest } from './manifest-target.mjs' const CHROME = { manifest_version: 3, name: 'substandard', key: 'not-a-real-key', minimum_chrome_version: '110', background: { service_worker: 'background.js', type: 'module' }, permissions: ['storage', 'offscreen'], host_permissions: ['http://*/*', 'https://*/*'], } describe('firefoxManifest', () => { it('replaces the service worker with a module event page', () => { expect(firefoxManifest(CHROME).background).toEqual({ scripts: ['background.js'], type: 'module', }) }) it('drops the Chrome-only fields and offscreen permission', () => { const manifest = firefoxManifest(CHROME) expect(manifest.key).toBeUndefined() expect(manifest.minimum_chrome_version).toBeUndefined() expect(manifest.permissions).toEqual(['storage']) }) it('declares the gecko id, minimum version and data collection policy', () => { expect(firefoxManifest(CHROME).browser_specific_settings).toEqual({ gecko: { id: FIREFOX_EXTENSION_ID, strict_min_version: '121.0', data_collection_permissions: { required: ['none'] }, }, }) }) it('leaves the input manifest untouched', () => { firefoxManifest(CHROME) expect(CHROME.background).toEqual({ service_worker: 'background.js', type: 'module' }) expect(CHROME.key).toBe('not-a-real-key') }) }) describe('transformManifest', () => { it('returns the Chrome manifest unchanged for any other target', () => { expect(transformManifest(CHROME, 'chrome')).toEqual(CHROME) }) it('routes firefox through the Firefox transform', () => { expect(transformManifest(CHROME, 'firefox').background.scripts).toEqual(['background.js']) }) })