Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/msdynamics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceInfo } from '../commands/general';
import { DeviceInfo } from '../commands/general.js';
import { CallbackData, CallbackParams, PermissionStatusData } from '../types/index.js';
import { addCommandCallback } from '../utils/index.js';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/shareIntoApp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createListener } from '../utils/listener';
import { createListener } from '../utils/listener.js';

export type ShareToAppData = { url: string; subject: string };

Expand Down
47 changes: 32 additions & 15 deletions test/bundle.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/**
* Basic test to verify the rollup IIFE bundle exports Median correctly.
* Basic test to verify the rollup IIFE bundle exports Median correctly,
* and that the package entry point loads for npm consumers.
* Run with: npm test
*/

const fs = require('fs');
const path = require('path');
const { pathToFileURL } = require('url');

const bundlePath = path.join(__dirname, '../dist/median.min.js');
const entryPath = path.join(__dirname, '../dist/index.js');

// Check bundle exists
if (!fs.existsSync(bundlePath)) {
Expand Down Expand Up @@ -43,30 +46,44 @@ const tests = [
{ name: 'Median.appResumed exists', check: () => typeof Median.appResumed === 'object' },
{ name: 'Median.appResumed.addListener is function', check: () => typeof Median.appResumed?.addListener === 'function' },
{ name: 'Median.jsNavigation exists', check: () => typeof Median.jsNavigation === 'object' },

// Package entry point — Node's ESM resolver does no extension guessing, so a
// relative import emitted without `.js` fails the whole graph for npm users.
{
name: 'dist/index.js resolves through the Node ESM loader',
check: async () => {
const module = await import(pathToFileURL(entryPath).href);
return typeof module.default === 'object' && typeof module.default.shareIntoApp === 'object';
},
},
];

let passed = 0;
let failed = 0;

console.log('\n🧪 Testing Median IIFE bundle...\n');

for (const test of tests) {
try {
if (test.check()) {
console.log(` ✅ ${test.name}`);
passed++;
} else {
console.log(` ❌ ${test.name}`);
async function run() {
for (const test of tests) {
try {
if (await test.check()) {
console.log(` ✅ ${test.name}`);
passed++;
} else {
console.log(` ❌ ${test.name}`);
failed++;
}
} catch (err) {
console.log(` ❌ ${test.name} (Error: ${err.message})`);
failed++;
}
} catch (err) {
console.log(` ❌ ${test.name} (Error: ${err.message})`);
failed++;
}
}

console.log(`\n📊 Results: ${passed} passed, ${failed} failed\n`);
console.log(`\n📊 Results: ${passed} passed, ${failed} failed\n`);

if (failed > 0) {
process.exit(1);
if (failed > 0) {
process.exit(1);
}
}

run();