Skip to content

Commit

Permalink
test: increase test coverage on config.schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandenaardweg committed Dec 30, 2022
1 parent 09c32dd commit 9c48435
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/config.schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,44 @@ describe('config.schema.json', () => {

expect(schemaValidation).toThrowError(`'some.invalid.ip.address' is not a valid IPv4 address`);
});

it('should error when verboseLogging is not a boolean', () => {
const invalidConfigSchema = {
platform: PLATFORM_NAME,
name: DEFAULT_BRIDGE_NAME,
api: {
ip: '192.168.0.10',
port: 1883,
protocol: 'mqtt',
},
verboseLogging: 'true',
};

const schemaValidation = () => {
configSchema.parse(invalidConfigSchema);
};

expect(schemaValidation).toThrowError("'verboseLogging' must be a boolean");
});

it('should error when device.co2Sensor is not a boolean', () => {
const invalidConfigSchema = {
platform: PLATFORM_NAME,
name: DEFAULT_BRIDGE_NAME,
api: {
ip: '192.168.0.10',
port: 1883,
protocol: 'mqtt',
},
device: {
co2Sensor: 'true',
},
};

const schemaValidation = () => {
configSchema.parse(invalidConfigSchema);
};

expect(schemaValidation).toThrowError("'co2Sensor' must be a boolean");
});
});

0 comments on commit 9c48435

Please sign in to comment.