options.flags.test.js
This file
Path
tests/options.flags.test.js
77 lines · 2.9 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–3why, one step back1import * as commander from '../index.js';2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 4–6why, one step back45// Test the various ways flags can be specified in the first parameter to `.option`6Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 7–13why, one step back7describe('option parsing', () => {8 test('when only short flag defined and not specified then value is undefined', () => {9 const program = new commander.Command();10 program.option('-p', 'add pepper');11 program.parse(['node', 'test']);12 assert.equal(program.opts().p, undefined);13 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 14why, one step back14Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 15–20why, one step back15 test('when only short flag defined and specified then value is true', () => {16 const program = new commander.Command();17 program.option('-p', 'add pepper');18 program.parse(['node', 'test', '-p']);19 assert.equal(program.opts().p, true);20 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 21why, one step back21Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 22–27why, one step back22 test('when only long flag defined and not specified then value is undefined', () => {23 const program = new commander.Command();24 program.option('--pepper', 'add pepper');25 program.parse(['node', 'test']);26 assert.equal(program.opts().pepper, undefined);27 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 28why, one step back28Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 29–34why, one step back29 test('when only long flag defined and specified then value is true', () => {30 const program = new commander.Command();31 program.option('--pepper', 'add pepper');32 program.parse(['node', 'test', '--pepper']);33 assert.equal(program.opts().pepper, true);34 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 35why, one step back35Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 36–41why, one step back36 test('when "short,long" flags defined and short specified then value is true', () => {37 const program = new commander.Command();38 program.option('-p,--pepper', 'add pepper');39 program.parse(['node', 'test', '-p']);40 assert.equal(program.opts().pepper, true);41 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 42why, one step back42Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 43–48why, one step back43 test('when "short,long" flags defined and long specified then value is true', () => {44 const program = new commander.Command();45 program.option('-p,--pepper', 'add pepper');46 program.parse(['node', 'test', '--pepper']);47 assert.equal(program.opts().pepper, true);48 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 49why, one step back49Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 50–55why, one step back50 test('when "short|long" flags defined and short specified then value is true', () => {51 const program = new commander.Command();52 program.option('-p|--pepper', 'add pepper');53 program.parse(['node', 'test', '-p']);54 assert.equal(program.opts().pepper, true);55 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 56why, one step back56Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 57–62why, one step back57 test('when "short|long" flags defined and long specified then value is true', () => {58 const program = new commander.Command();59 program.option('-p|--pepper', 'add pepper');60 program.parse(['node', 'test', '--pepper']);61 assert.equal(program.opts().pepper, true);62 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 63why, one step back63Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 64–69why, one step back64 test('when "short long" flags defined and short specified then value is true', () => {65 const program = new commander.Command();66 program.option('-p --pepper', 'add pepper');67 program.parse(['node', 'test', '-p']);68 assert.equal(program.opts().pepper, true);69 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 70why, one step back70Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 71–76why, one step back71 test('when "short long" flags defined and long specified then value is true', () => {72 const program = new commander.Command();73 program.option('-p --pepper', 'add pepper');74 program.parse(['node', 'test', '--pepper']);75 assert.equal(program.opts().pepper, true);76 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 77why, one step back77});