decentralized-internet
Version:
An NPM library of programs to create decentralized web and distributed computing projects
1 lines • 1.01 kB
JavaScript
;const assert=require("assertthat"),Endpoint=require("../lib/Endpoint");suite("Endpoint",()=>{test("is a function.",t=>{assert.that(Endpoint).is.ofType("function"),t()}),test("throws an error if options are missing.",t=>{assert.that(()=>{new Endpoint}).is.throwing("Options are missing."),t()}),test("throws an error if host is missing.",t=>{assert.that(()=>{new Endpoint({port:3e3})}).is.throwing("Host is missing."),t()}),test("throws an error if port is missing.",t=>{assert.that(()=>{new Endpoint({host:"localhost"})}).is.throwing("Port is missing."),t()}),test("sets the host.",t=>{const s=new Endpoint({host:"localhost",port:3e3});assert.that(s.host).is.equalTo("localhost"),t()}),test("sets the port.",t=>{const s=new Endpoint({host:"localhost",port:3e3});assert.that(s.port).is.equalTo(3e3),t()}),test("calculates the id as SHA1 from the host and the port.",t=>{const s=new Endpoint({host:"localhost",port:3e3});assert.that(s.id).is.equalTo("12a30e3632a51fdab4fedd07bcc219b433e17343"),t()})});