import { wchtoolsFixArguments } from './../src/commands/abstract.wchtools.command'; import { OPTION_SOURCE, OPTION_DATA, OPTION_VERBOSE } from '../src/constants'; import { isEqual } from 'lodash'; import { ensureTrailingSlash } from './../src/utils/wchtools'; describe('wchtools', () => { it('should ensure a trailing slash', () => { expect(ensureTrailingSlash('http://www.example.org/test')).toEqual('http://www.example.org/test/'); expect(ensureTrailingSlash('http://www.example.org/test/')).toEqual('http://www.example.org/test/'); }); it('should fix argument list 1', () => { // arguments: const args = ['push', `--${OPTION_SOURCE}`, 'src', `--${OPTION_DATA}`, 'data']; const fixed = wchtoolsFixArguments(args); expect(fixed).toBeDefined(); expect(fixed.length).toEqual(1); expect(isEqual(fixed, ['push'])).toBeTruthy(); }); it('should fix argument list 2', () => { // arguments: const args = [`--${OPTION_SOURCE}`, 'src', `--${OPTION_DATA}`, 'data', 'pull', `--${OPTION_VERBOSE}`, '-lm']; const fixed = wchtoolsFixArguments(args); expect(fixed).toBeDefined(); expect(fixed.length).toEqual(2); expect(isEqual(fixed, ['pull', '-lm'])).toBeTruthy(); }); });