fix(ipv4-range-expander): calculate correct for ip addresses where the first octet is lower than 128 (#405)

This commit is contained in:
cgoIT 2023-05-15 10:23:16 +02:00 committed by GitHub
parent 7aed9c56fd
commit 8c92d56318
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View file

@ -14,6 +14,17 @@ describe('ipv4RangeExpander', () => {
expect(result?.newCidr).toEqual('192.168.0.0/21');
});
it('should calculate valid cidr for given addresses, where first octet is lower than 128', () => {
const result = calculateCidr({ startIp: '10.0.0.1', endIp: '10.0.0.17' });
expect(result).toBeDefined();
expect(result?.oldSize).toEqual(17);
expect(result?.newSize).toEqual(32);
expect(result?.newStart).toEqual('10.0.0.0');
expect(result?.newEnd).toEqual('10.0.0.31');
expect(result?.newCidr).toEqual('10.0.0.0/27');
});
it('should return empty result for invalid input', () => {
expect(calculateCidr({ startIp: '192.168.7.1', endIp: '192.168.6.255' })).not.toBeDefined();
});