diff options
author | 2023-04-19 20:30:45 +0200 | |
---|---|---|
committer | 2023-04-19 20:30:45 +0200 | |
commit | df989e24b3937876f094301e33762677d604888a (patch) | |
tree | 672ea49abff8e3b1a33fcb41bdfbeade0227ee0f /src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts | |
parent | 6d2202597c269925422af02a862c64d1b0548093 (diff) | |
download | it-tools-df989e24b3937876f094301e33762677d604888a.tar.gz it-tools-df989e24b3937876f094301e33762677d604888a.tar.zst it-tools-df989e24b3937876f094301e33762677d604888a.zip |
feat(ipv4-range-expander): expands a given IPv4 start and end address to a valid IPv4 subnet (#366)
* feat(ipv4-range-expander): expands a given IPv4 start and end address to a valid IPv4 subnet
* feat(ipv4-range-expander): remove old component copyable-ip-like.vue
* feat(ipv4-range-expander): fix sonar findings
* feat(ipv4-range-expander): changes due to review
* feat(ipv4-range-expander): only show n-alert if both ipv4 addresses are valid
Diffstat (limited to 'src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts')
-rw-r--r-- | src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts b/src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts new file mode 100644 index 0000000..66a9137 --- /dev/null +++ b/src/tools/ipv4-range-expander/ipv4-range-expander.service.test.ts @@ -0,0 +1,21 @@ +import { expect, describe, it } from 'vitest'; +import { calculateCidr } from './ipv4-range-expander.service'; + +describe('ipv4RangeExpander', () => { + describe('when there are two valid ipv4 addresses given', () => { + it('should calculate valid cidr for given addresses', () => { + const result = calculateCidr({ startIp: '192.168.1.1', endIp: '192.168.7.255' }); + + expect(result).toBeDefined(); + expect(result?.oldSize).toEqual(1791); + expect(result?.newSize).toEqual(2048); + expect(result?.newStart).toEqual('192.168.0.0'); + expect(result?.newEnd).toEqual('192.168.7.255'); + expect(result?.newCidr).toEqual('192.168.0.0/21'); + }); + + it('should return empty result for invalid input', () => { + expect(calculateCidr({ startIp: '192.168.7.1', endIp: '192.168.6.255' })).not.toBeDefined(); + }); + }); +}); |