This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename generate-vdm command to generate-odata-client (#42)
* rename command * try out remote build * refactor error * put lock file back in * revert yarn.lock changes. * add util test * Change all remaining instances of VDM to OData client * Fix import Co-authored-by: Florian Richter <[email protected]>
- Loading branch information
1 parent
cdc2707
commit 57bc6bf
Showing
8 changed files
with
89 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*! | ||
* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. | ||
*/ | ||
|
||
import { Options } from 'yargs'; | ||
import { toBooleanFlag, toStringFlag } from '../../src/utils/generate-odata-client-util'; | ||
|
||
describe('Generate OData Client Utils', () => { | ||
describe('Boolean option transformation from yarn to oclif.', () => { | ||
it('should translate the description correctly', () => { | ||
let yargsOption: Options = { describe: 'expectedDescription', default: false }; | ||
expect(toBooleanFlag(yargsOption).description).toBe('expectedDescription [default: false].'); | ||
|
||
yargsOption = { describe: 'expectedDescription', default: true }; | ||
expect(toBooleanFlag(yargsOption).description).toBe('expectedDescription [default: true].'); | ||
}); | ||
|
||
it('should translate the alias correctly.', () => { | ||
const yargsOption: Options = { alias: 'expectedAlias' }; | ||
expect(toBooleanFlag(yargsOption).char).toBe(yargsOption.alias); | ||
}); | ||
|
||
it('should translate the required option correctly.', () => { | ||
let yargsOption: Options = { requiresArg: false }; | ||
expect(toBooleanFlag(yargsOption).required).toBe(yargsOption.requiresArg); | ||
|
||
yargsOption = { requiresArg: true }; | ||
expect(toBooleanFlag(yargsOption).required).toBe(yargsOption.requiresArg); | ||
}); | ||
|
||
it('should translate the default and allowNo option correctly.', () => { | ||
let yargsOption: Options = { default: false }; | ||
expect(toBooleanFlag(yargsOption).default).toBe(yargsOption.default); | ||
expect(toBooleanFlag(yargsOption).allowNo).toBe(yargsOption.default); | ||
|
||
yargsOption = { default: true }; | ||
expect(toBooleanFlag(yargsOption).default).toBe(yargsOption.default); | ||
expect(toBooleanFlag(yargsOption).allowNo).toBe(yargsOption.default); | ||
}); | ||
}); | ||
|
||
describe('String option transformation from yarn to oclif.', () => { | ||
it('should translate all string arguments correctly.', () => { | ||
const yargsOption: Options = { alias: 'expectedAlias', description: 'expectedDescription' }; | ||
expect(toStringFlag(yargsOption).char).toBe(yargsOption.alias); | ||
expect(toStringFlag(yargsOption).description).toBe(yargsOption.describe); | ||
}); | ||
|
||
it('should translate the default option correctly.', () => { | ||
let yargsOption: Options = { default: false }; | ||
expect(toBooleanFlag(yargsOption).default).toBe(yargsOption.default); | ||
|
||
yargsOption = { default: true }; | ||
expect(toBooleanFlag(yargsOption).default).toBe(yargsOption.default); | ||
}); | ||
|
||
it('should translate the required option correctly.', () => { | ||
let yargsOption: Options = { requiresArg: false }; | ||
expect(toBooleanFlag(yargsOption).required).toBe(yargsOption.requiresArg); | ||
|
||
yargsOption = { requiresArg: true }; | ||
expect(toBooleanFlag(yargsOption).required).toBe(yargsOption.requiresArg); | ||
}); | ||
}); | ||
}); |