Loading __tests__/util.test.ts +65 −1 Changes for __tests__/util.test.ts: 65 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -57,9 +57,73 @@ const { isCacheFeatureAvailable, isGhes, validatePaginationUrl, getLatestMajorVersion getLatestMajorVersion, getBooleanInput } = await import('../src/util.js'); describe('getBooleanInput', () => { let inputs: Record<string, string>; beforeEach(() => { inputs = {}; (core.getInput as jest.Mock).mockImplementation( (name: string) => inputs[name] ?? '' ); }); afterEach(() => { jest.resetAllMocks(); }); it.each([ ['true', true], ['TRUE', true], ['TrUe', true], [' true ', true], ['false', false], ['FALSE', false], ['FaLsE', false], [' false ', false] ])('parses %j as %s', (value: string, expected: boolean) => { inputs['boolean-input'] = value; expect(getBooleanInput('boolean-input')).toBe(expected); }); it.each([ [undefined, false], [false, false], [true, true] ])( 'uses the configured default %s when the input is omitted', (defaultValue: boolean | undefined, expected: boolean) => { expect(getBooleanInput('boolean-input', defaultValue)).toBe(expected); } ); it('uses the configured default for a whitespace-only input', () => { inputs['boolean-input'] = ' '; expect(getBooleanInput('boolean-input', true)).toBe(true); }); it.each([ 'check-latest', 'force-download', 'set-default', 'verify-signature', 'overwrite-settings', 'show-download-progress', 'problem-matcher' ])('rejects an invalid value for %s', inputName => { inputs[inputName] = 'ture'; expect(() => getBooleanInput(inputName)).toThrow( `Invalid value 'ture' for boolean input '${inputName}'. Expected 'true' or 'false'.` ); }); }); describe('isVersionSatisfies', () => { it.each([ ['x', '11.0.0', true], Loading dist/cleanup/index.js +12 −1 Changes for dist/cleanup/index.js: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -97365,7 +97365,18 @@ function getTempDir() { return tempDirectory; } function util_getBooleanInput(inputName, defaultValue = false) { return ((core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'); const inputValue = core.getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`); } function getVersionFromToolcachePath(toolPath) { if (toolPath) { dist/setup/index.js +12 −1 Changes for dist/setup/index.js: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -128364,7 +128364,18 @@ function getTempDir() { return tempDirectory; } function util_getBooleanInput(inputName, defaultValue = false) { return ((getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'); const inputValue = getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`); } function getVersionFromToolcachePath(toolPath) { if (toolPath) { src/util.ts +15 −2 Changes for src/util.ts: 15 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -20,8 +20,21 @@ export function getTempDir() { } export function getBooleanInput(inputName: string, defaultValue = false) { return ( (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE' const inputValue = core.getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error( `Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.` ); } Loading Loading
__tests__/util.test.ts +65 −1 Changes for __tests__/util.test.ts: 65 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -57,9 +57,73 @@ const { isCacheFeatureAvailable, isGhes, validatePaginationUrl, getLatestMajorVersion getLatestMajorVersion, getBooleanInput } = await import('../src/util.js'); describe('getBooleanInput', () => { let inputs: Record<string, string>; beforeEach(() => { inputs = {}; (core.getInput as jest.Mock).mockImplementation( (name: string) => inputs[name] ?? '' ); }); afterEach(() => { jest.resetAllMocks(); }); it.each([ ['true', true], ['TRUE', true], ['TrUe', true], [' true ', true], ['false', false], ['FALSE', false], ['FaLsE', false], [' false ', false] ])('parses %j as %s', (value: string, expected: boolean) => { inputs['boolean-input'] = value; expect(getBooleanInput('boolean-input')).toBe(expected); }); it.each([ [undefined, false], [false, false], [true, true] ])( 'uses the configured default %s when the input is omitted', (defaultValue: boolean | undefined, expected: boolean) => { expect(getBooleanInput('boolean-input', defaultValue)).toBe(expected); } ); it('uses the configured default for a whitespace-only input', () => { inputs['boolean-input'] = ' '; expect(getBooleanInput('boolean-input', true)).toBe(true); }); it.each([ 'check-latest', 'force-download', 'set-default', 'verify-signature', 'overwrite-settings', 'show-download-progress', 'problem-matcher' ])('rejects an invalid value for %s', inputName => { inputs[inputName] = 'ture'; expect(() => getBooleanInput(inputName)).toThrow( `Invalid value 'ture' for boolean input '${inputName}'. Expected 'true' or 'false'.` ); }); }); describe('isVersionSatisfies', () => { it.each([ ['x', '11.0.0', true], Loading
dist/cleanup/index.js +12 −1 Changes for dist/cleanup/index.js: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -97365,7 +97365,18 @@ function getTempDir() { return tempDirectory; } function util_getBooleanInput(inputName, defaultValue = false) { return ((core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'); const inputValue = core.getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`); } function getVersionFromToolcachePath(toolPath) { if (toolPath) {
dist/setup/index.js +12 −1 Changes for dist/setup/index.js: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -128364,7 +128364,18 @@ function getTempDir() { return tempDirectory; } function util_getBooleanInput(inputName, defaultValue = false) { return ((getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'); const inputValue = getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`); } function getVersionFromToolcachePath(toolPath) { if (toolPath) {
src/util.ts +15 −2 Changes for src/util.ts: 15 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -20,8 +20,21 @@ export function getTempDir() { } export function getBooleanInput(inputName: string, defaultValue = false) { return ( (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE' const inputValue = core.getInput(inputName); const normalizedValue = inputValue.trim().toLowerCase(); if (!normalizedValue) { return defaultValue; } if (normalizedValue === 'true') { return true; } if (normalizedValue === 'false') { return false; } throw new Error( `Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.` ); } Loading