import { test } from 'node:test'; import assert from 'node:assert/strict'; import { devAppPlan, devExecutable, devProductName } from '../lib/dev-app.js'; const config = { id: 'com.berjon.blastile', name: 'blastile', icon: 'icons/blastile.png', build: { productName: 'Blastile' } }; const plan = (over = {}) => devAppPlan({ config, appDir: '/apps/blastile', electronApp: '/x/dist/Electron.app', electronVersion: '40.0.0', cacheRoot: '/cache', ...over, }); test('the dev name is the product name a build would have', () => { assert.equal(devProductName(config), 'Blastile'); assert.equal(devProductName({ name: 'kavu' }), 'kavu'); }); test('one bundle per app, named for it, with the executable Electron ships', () => { const p = plan(); assert.equal(p.app, '/cache/com.berjon.blastile/Blastile.app'); assert.equal(p.executable, '/cache/com.berjon.blastile/Blastile.app/Contents/MacOS/Electron'); assert.equal(p.bundleId, 'com.berjon.blastile.dev'); assert.equal(p.icon, '/apps/blastile/icons/blastile.png'); }); test('a name that is not a file name still makes one, and only a PNG is an icon', () => { const p = plan({ config: { id: 'a.b', name: 'in/out: yes', icon: 'icon.icns' } }); assert.equal(p.app, '/cache/a.b/in-out- yes.app'); assert.equal(p.name, 'in/out: yes'); assert.equal(p.icon, null); }); test('the stamp changes with the Electron version, the name and the icon', () => { const base = plan().stampFor(1); assert.equal(plan().stampFor(1), base); assert.notEqual(plan({ electronVersion: '41.0.0' }).stampFor(1), base); assert.notEqual(plan({ config: { ...config, build: { productName: 'Other' } } }).stampFor(1), base); assert.notEqual(plan().stampFor(2), base); }); test('off macOS, or when asked, dev runs the stock Electron', async () => { const electron = '/x/dist/Electron.app/Contents/MacOS/Electron'; assert.equal(await devExecutable({ electron, config, appDir: '/a', electronVersion: '40', platform: 'linux' }), electron); assert.equal(await devExecutable({ electron, config, appDir: '/a', electronVersion: '40', platform: 'darwin', env: { MOLLUSC_STOCK_ELECTRON: '1' } }), electron); assert.equal(await devExecutable({ electron: '/usr/bin/electron', config, appDir: '/a', electronVersion: '40', platform: 'darwin', env: {} }), '/usr/bin/electron'); });