Skip to content

Commit

Permalink
fix: fixed maxQueryLimit validation
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Jan 20, 2021
1 parent c294db6 commit 6431065
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { keyBy, set } from '@salesforce/kit';
import { Dictionary, ensure, isNumber, isString } from '@salesforce/ts-types';
import { Dictionary, ensure, isString } from '@salesforce/ts-types';
import { Logger } from '../logger';
import { Crypto } from '../crypto';
import { Messages } from '../messages';
Expand Down Expand Up @@ -181,7 +181,7 @@ export class Config extends ConfigFile<ConfigFile.Options> {
{
key: Config.MAX_QUERY_LIMIT,
input: {
validator: (value) => isNumber(value),
validator: (value) => !isNaN(Number(value)),
get failedMessage() {
return Config.messages?.getMessage('InvalidNumberConfigValue');
},
Expand Down
30 changes: 30 additions & 0 deletions test/unit/config/configTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ describe('Config', () => {
expect(err).to.have.property('name', 'InvalidConfigValue');
}
});
describe('maxQueryLimit', () => {
it('will throw an error', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
try {
config.set('maxQueryLimit', '123abc');
assert.fail('Expected an error to be thrown.');
} catch (err) {
expect(err).to.have.property('name', 'InvalidConfigValue');
}
});
it('will throw an error', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
try {
config.set('maxQueryLimit', 'abc');
assert.fail('Expected an error to be thrown.');
} catch (err) {
expect(err).to.have.property('name', 'InvalidConfigValue');
}
});
it('will set config value', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
const res = config.set('maxQueryLimit', '123');
expect(res.maxQueryLimit).to.equal('123');
});
it('will set config value', async () => {
const config: Config = await Config.create(Config.getDefaultOptions(true));
const res = config.set('maxQueryLimit', 123);
expect(res.maxQueryLimit).to.equal(123);
});
});
});

it('PropertyInput validation', async () => {
Expand Down

0 comments on commit 6431065

Please sign in to comment.