Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
test: add U
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jan 23, 2024
1 parent 199a1fa commit 9c1c08d
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions test/commands/org/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ describe('org api', () => {

let stdoutSpy: sinon.SinonSpy;

const orgLimitsResponse = {
ActiveScratchOrgs: {
Max: 200,
Remaining: 199,
},
};

beforeEach(async () => {
await $$.stubAuths(testOrg);
stdoutSpy = $$.SANDBOX.stub(process.stdout, 'write');
Expand All @@ -26,13 +33,6 @@ describe('org api', () => {
});

it('should request org limits and default to "GET" HTTP method', async () => {
const orgLimitsResponse = {
ActiveScratchOrgs: {
Max: 200,
Remaining: 199,
},
};

nock(testOrg.instanceUrl)
.get('/services/data/v56.0/limits')
.reply(200, orgLimitsResponse);
Expand Down Expand Up @@ -101,4 +101,22 @@ describe('org api', () => {
);
}
});

it('should not follow redirects', async () => {
nock(testOrg.instanceUrl)
.get('/services/data/v56.0/limites')
.reply(301, orgLimitsResponse, {
location: `${testOrg.instanceUrl}/services/data/v56.0/limits`,
});

await OrgApi.run([
'services/data/v56.0/limites',
'--target-org',
'[email protected]',
]);

const output = stripAnsi(stdoutSpy.args.flat().join(''));

expect(JSON.parse(output)).to.deep.equal(orgLimitsResponse);
});
});

0 comments on commit 9c1c08d

Please sign in to comment.