The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/settings/server/functions/validateSettings.tests.ts

37 lines
1.5 KiB

/* eslint-disable @typescript-eslint/camelcase */
import { expect } from 'chai';
import { validateSetting } from './validateSetting';
describe('validateSettings', () => {
it('should validate the type string', () => {
expect(() => validateSetting('test', 'string', 'value')).to.not.throw();
});
it('should throw an error expecting string receiving int', () => {
expect(() => validateSetting('test', 'string', 10)).to.throw();
});
it('should validate the type int', () => {
expect(() => validateSetting('test', 'int', 10)).to.not.throw();
});
it('should throw an error expecting int receiving string', () => {
expect(() => validateSetting('test', 'int', '10')).to.throw();
});
it('should validate the type boolean', () => {
expect(() => validateSetting('test', 'boolean', true)).to.not.throw();
});
it('should throw an error expecting boolean receiving string', () => {
expect(() => validateSetting('test', 'boolean', 'true')).to.throw();
});
it('should validate the type date', () => {
expect(() => validateSetting('test', 'date', new Date())).to.not.throw();
});
it('should throw an error expecting date receiving string', () => {
expect(() => validateSetting('test', 'date', '2019-01-01')).to.throw();
});
it('should validate the type multiSelect', () => {
expect(() => validateSetting('test', 'multiSelect', [])).to.not.throw();
});
it('should throw an error expecting multiSelect receiving string', () => {
expect(() => validateSetting('test', 'multiSelect', '[]')).to.throw();
});
});