Skip to main content
Glama
utils.test.ts1.84 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { Bot } from '@medplum/fhirtypes'; import { getJsFileExtension } from './utils'; describe('getJsFileExtension', () => { test('returns .cjs for CommonJS code with .cjs extension', () => { const bot = { id: '1', executableCode: { title: 'bot.cjs' } } as Bot; const code = 'module.exports = {};'; expect(getJsFileExtension(bot, code)).toBe('.cjs'); }); test('returns .mjs for ESM code with .mjs extension', () => { const bot = { id: '1', executableCode: { title: 'bot.mjs' } } as Bot; const code = 'export const foo = 42;'; expect(getJsFileExtension(bot, code)).toBe('.mjs'); }); test('returns .mjs for ESM code without extension', () => { const bot = { id: '1', executableCode: { title: 'bot.js' } } as Bot; const code = 'export const foo = 42;'; expect(getJsFileExtension(bot, code)).toBe('.mjs'); }); test('returns .cjs for CommonJS code without extension', () => { const bot = { id: '1', executableCode: { title: 'bot.js' } } as Bot; const code = 'module.exports = {};'; expect(getJsFileExtension(bot, code)).toBe('.cjs'); }); test('returns .mjs for ESM code without filename', () => { const bot = { id: '1' } as Bot; const code = 'export const foo = 42;'; expect(getJsFileExtension(bot, code)).toBe('.mjs'); }); test('returns .cjs for CommonJS code without filename', () => { const bot = { id: '1' } as Bot; const code = 'module.exports = {};'; expect(getJsFileExtension(bot, code)).toBe('.cjs'); }); test('returns .cjs for ambiguous code without filename', () => { const bot = { id: '1' } as Bot; const code = 'const foo = 42;'; expect(getJsFileExtension(bot, code)).toBe('.cjs'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server