2022-06-19 00:25:21 +00:00
|
|
|
import {expect} from "chai";
|
|
|
|
import Helper from "../../server/helper";
|
2016-11-19 18:32:47 +00:00
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
describe("HexIP", function () {
|
|
|
|
it("should correctly convert IPv4 to hex", function () {
|
2016-11-19 18:32:47 +00:00
|
|
|
expect(Helper.ip2hex("66.124.160.150")).to.equal("427ca096");
|
|
|
|
expect(Helper.ip2hex("127.0.0.1")).to.equal("7f000001");
|
|
|
|
expect(Helper.ip2hex("0.0.0.255")).to.equal("000000ff");
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("unsupported addresses return default", function () {
|
2016-11-19 18:32:47 +00:00
|
|
|
expect(Helper.ip2hex("0.0.0.999")).to.equal("00000000");
|
|
|
|
expect(Helper.ip2hex("localhost")).to.equal("00000000");
|
|
|
|
expect(Helper.ip2hex("::1")).to.equal("00000000");
|
|
|
|
expect(Helper.ip2hex("2606:2800:220:1:248:1893:25c8:1946")).to.equal("00000000");
|
|
|
|
});
|
|
|
|
});
|