Skip to content

Commit 4e2ff8d

Browse files
Merge pull request #1851 from contentstack/fix/rate-limit-test-cases
Fix/rate limit test cases
2 parents 6dbf41b + 9dd7bd7 commit 4e2ff8d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/contentstack-config/test/unit/commands/rate-limit.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ describe('Rate Limit Commands', () => {
9292
},
9393
});
9494
const config = { org: 'test-org-id', utilize: ['70'], 'limit-name': ['getLimit'] };
95-
await handler.setRateLimit(config);
96-
expect(errorMessage).to.include('Error: Unable to set the rate limit');
95+
try {
96+
await handler.setRateLimit(config);
97+
expect.fail('Expected an error to be thrown');
98+
} catch (error) {
99+
expect(error).to.be.an('error');
100+
expect(error.message).to.equal('Error: Client Error');
101+
}
97102
});
98103

99104
it('Set Rate Limit: should handle unauthenticated user', async () => {
@@ -137,7 +142,10 @@ describe('Rate Limit Commands', () => {
137142
it('Get Rate Limit: should print the rate limit for the given organization', async () => {
138143
configHandler.set('rateLimit', rateLimit);
139144
await GetRateLimitCommand.run(['--org', 'test-org-id']);
140-
expect(printMessage).to.include(' test-org-id 10(70%) 0 1(80%) ');
145+
expect(printMessage).to.include('test-org-id');
146+
expect(printMessage).to.include('10(70%)');
147+
expect(printMessage).to.include('0');
148+
expect(printMessage).to.include('1(80%)');
141149
});
142150

143151
it('Get Rate Limit: should throw an error if the organization is not found', async () => {

0 commit comments

Comments
 (0)