argument.required.test.js
This file
Path
tests/argument.required.test.js
34 lines · 1.1 KiB · JavaScript
Last changed by
Feature/argument arg explicit (#1567)John Geebefore adoption6f51e4a
History of this fileTake it
Feature/argument arg explicit (#1567)John Geebefore adoption6f51e4a
lines 1–34why, one step back1const commander = require('../');23// Low-level tests of setting Argument.required.4// Higher level tests of optional/required arguments elsewhere.56test('when name with surrounding <> then argument required', () => {7 const argument = new commander.Argument('<name>');8 expect(argument.required).toBe(true);9});1011test('when name with surrounding [] then argument optional', () => {12 const argument = new commander.Argument('[name]');13 expect(argument.required).toBe(false);14});1516test('when name without surrounding brackets then argument required', () => {17 // default behaviour, allowed from Commander 818 const argument = new commander.Argument('name');19 expect(argument.required).toBe(true);20});2122test('when call .argRequired() then argument required', () => {23 const argument = new commander.Argument('name');24 argument.required = false;25 argument.argRequired();26 expect(argument.required).toBe(true);27});2829test('when call .argOptional() then argument optional', () => {30 const argument = new commander.Argument('name');31 argument.required = true;32 argument.argOptional();33 expect(argument.required).toBe(false);34});