Skip to content

Commit

Permalink
fix: unit test for using json file
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp authored Mar 12, 2021
1 parent a9f0300 commit f749fd3
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/commands/auth/sfdxurl/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('auth:sfdxurl:store', async () => {
});

if (!options.fileDoesNotExist) {
$$.SANDBOX.stub(fs, 'readFile').callsFake(async () => {
return 'force://PlatformCLI::[email protected]';
});
$$.SANDBOX.stub(fs, 'readFile').callsFake(
async () => 'force://PlatformCLI::[email protected]'
);
}

if (options.authInfoCreateFails) {
Expand All @@ -58,6 +58,22 @@ describe('auth:sfdxurl:store', async () => {
expect(response.result.username).to.equal(testData.username);
});

test
.do(async () => {
await prepareStubs({ fileDoesNotExist: true });
$$.SANDBOX.stub(fs, 'readFile').callsFake(
async () => '{"sfdxAuthUrl": "force://PlatformCLI::[email protected]"}'
);
})
.stdout()
.command(['auth:sfdxurl:store', '-f', 'path/to/key.json', '--json'])
.it('should return auth fields when passing in a json file', (ctx) => {
const response = parseJson<AuthFields>(ctx.stdout);
expect(response.status).to.equal(0);
expect(response.result).to.deep.equal(authFields);
expect(response.result.username).to.equal(testData.username);
});

test
.do(async () => prepareStubs())
.stdout()
Expand Down

0 comments on commit f749fd3

Please sign in to comment.