generated from homebridge/homebridge-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.spec.ts
28 lines (23 loc) · 877 Bytes
/
config.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import assert from 'assert';
import { isPositiveInteger, isNonEmptyString} from './config';
describe('Config Tests', () => {
it('detect invalid string', async () => {
assert.equal(false, isNonEmptyString(undefined));
assert.equal(false, isNonEmptyString(''));
});
it('detect valid string', async () => {
assert.equal(true, isNonEmptyString('foo'));
assert.equal(true, isNonEmptyString('127.0.0.1'));
});
it('detect invalid number', async () => {
assert.equal(false, isPositiveInteger(undefined));
assert.equal(false, isPositiveInteger(''));
assert.equal(false, isPositiveInteger('0'));
assert.equal(false, isPositiveInteger(0));
assert.equal(false, isPositiveInteger(-1));
});
it('detect valid number', async () => {
assert.equal(true, isPositiveInteger(1));
assert.equal(true, isPositiveInteger(9999));
});
});