-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Jest unit tests for checkCliVersion.ts
- Loading branch information
1 parent
b2aced9
commit 7a93ee6
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/salesforcedx-utils/test/jest/cli/checkCliVersion.test.ts
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,53 @@ | ||
import { CheckCliVersion } from '../../../src'; | ||
|
||
describe('CheckCliVersion unit tests.', () => { | ||
|
||
const validSFVersion = '@salesforce/cli/2.15.9 darwin-arm64 node-v18.17.1'; | ||
const validSFDXVersion = 'sfdx-cli/7.209.6 win32-x64 node-v18.15.0'; | ||
const outdatedSFVersion = '@salesforce/cli/1.87.0 darwin-arm64 node-v18.17.1'; | ||
const outdatedSFDXVersion = 'sfdx-cli/7.183.1 darwin-arm64 node-v16.19.1'; | ||
const emptyString = ''; | ||
const dummyText = 'dummy text'; | ||
|
||
it('Should create instance.', () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
expect(checkCliVersion).toBeInstanceOf(CheckCliVersion); | ||
}); | ||
|
||
it('SF v2 should be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(validSFVersion); | ||
expect(result).toBe(1); | ||
}); | ||
|
||
it('SF v1 should NOT be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(outdatedSFVersion); | ||
expect(result).toBe(2); | ||
}); | ||
|
||
it('SFDX >=v1.193.2 should be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(validSFDXVersion); | ||
expect(result).toBe(1); | ||
}); | ||
|
||
it('SFDX <v1.193.2 should NOT be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(outdatedSFDXVersion); | ||
expect(result).toBe(2); | ||
}); | ||
|
||
it('Empty string should NOT be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(emptyString); | ||
expect(result).toBe(3); | ||
}); | ||
|
||
it('Dummy text should NOT be a valid CLI version', async () => { | ||
const checkCliVersion = new CheckCliVersion(); | ||
const result = await checkCliVersion.validateCliVersion(dummyText); | ||
expect(result).toBe(3); | ||
}); | ||
|
||
}); |