|
1 | 1 | import { BuildContext } from '../util/interfaces';
|
2 |
| -import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars } from '../util/config'; |
| 2 | +import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars, hasArg } from '../util/config'; |
3 | 3 | import { addArgv, setAppPackageJsonData, setProcessEnvVar, setProcessArgs, setProcessEnv, setCwd } from '../util/config';
|
4 | 4 | import { resolve } from 'path';
|
5 | 5 |
|
@@ -287,6 +287,47 @@ describe('config', () => {
|
287 | 287 |
|
288 | 288 | });
|
289 | 289 |
|
| 290 | + describe('hasArg function', () => { |
| 291 | + it('should return false when a match is not found', () => { |
| 292 | + const result = hasArg('--full', '-f'); |
| 293 | + expect(result).toBeFalsy(); |
| 294 | + }); |
| 295 | + |
| 296 | + it('should match on a fullname arg', () => { |
| 297 | + addArgv('--full'); |
| 298 | + |
| 299 | + const result = hasArg('--full'); |
| 300 | + expect(result).toBeTruthy(); |
| 301 | + }); |
| 302 | + |
| 303 | + it('should match on a shortname arg', () => { |
| 304 | + addArgv('-f'); |
| 305 | + |
| 306 | + const result = hasArg('--full', '-f'); |
| 307 | + expect(result).toBeTruthy(); |
| 308 | + }); |
| 309 | + |
| 310 | + it('should compare fullnames as case insensitive', () => { |
| 311 | + addArgv('--full'); |
| 312 | + addArgv('--TEST'); |
| 313 | + |
| 314 | + const result = hasArg('--Full'); |
| 315 | + const result2 = hasArg('--test'); |
| 316 | + expect(result).toBeTruthy(); |
| 317 | + expect(result2).toBeTruthy(); |
| 318 | + }); |
| 319 | + |
| 320 | + it('should compare shortnames as case insensitive', () => { |
| 321 | + addArgv('-f'); |
| 322 | + addArgv('-T'); |
| 323 | + |
| 324 | + const result = hasArg('-F'); |
| 325 | + const result2 = hasArg('-t'); |
| 326 | + expect(result).toBeTruthy(); |
| 327 | + expect(result2).toBeTruthy(); |
| 328 | + }) |
| 329 | + }); |
| 330 | + |
290 | 331 | let context: BuildContext;
|
291 | 332 | beforeEach(() => {
|
292 | 333 | setProcessArgs(['node', 'ionic-app-scripts']);
|
|
0 commit comments