Skip to content
Myr

imports.test.mjs

This file

Path

tests/imports.test.mjs

73 lines · 1.6 KiB · JavaScript

Last changed by

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

History of this file

Take it

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 1–73why, one step back
1import {
2 program,3 Command,4 Option,5 Argument,6 Help,7 CommanderError,8 InvalidArgumentError,9 InvalidOptionArgumentError,10 createCommand,11 createArgument,12 createOption,13} from '../index.js';14import { describe, test } from 'node:test';15import assert from 'node:assert/strict';1617// Do some testing of the default export(s).18// Same tests in imports.test.cjs.1920function checkClass(obj, name) {21 assert.equal(typeof obj, 'object');22 assert.equal(obj.constructor.name, name);23}2425describe('imports from .mjs', () => {26 test('program', () => {27 checkClass(program, 'Command');28 });2930 test('Command', () => {31 checkClass(new Command('name'), 'Command');32 });3334 test('Option', () => {35 checkClass(new Option('-e, --example', 'description'), 'Option');36 });3738 test('Argument', () => {39 checkClass(new Argument('<foo>', 'description'), 'Argument');40 });4142 test('Help', () => {43 checkClass(new Help(), 'Help');44 });4546 test('CommanderError', () => {47 checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');48 });4950 test('InvalidArgumentError', () => {51 checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');52 });5354 test('InvalidOptionArgumentError', () => {55 // Deprecated56 checkClass(57 new InvalidOptionArgumentError('failed'),58 'InvalidArgumentError',59 );60 });6162 test('createCommand', () => {63 checkClass(createCommand('foo'), 'Command');64 });6566 test('createOption', () => {67 checkClass(createOption('-e, --example', 'description'), 'Option');68 });6970 test('createArgument', () => {71 checkClass(createArgument('<foo>', 'description'), 'Argument');72 });73});