UNPKG

@platform/cell.client

Version:

A strongly typed HTTP client for operating with a CellOS service end-point.

31 lines (30 loc) 1.15 kB
import { expect, TypeSystem } from '../test'; import { Client } from '.'; import { HttpClient } from '../HttpClient'; describe('Client', () => { it('Client.Http', () => { expect(Client.Http).to.equal(HttpClient); }); it('Client.Type', () => { expect(Client.Type).to.eql(TypeSystem); }); describe('Client.type', () => { it('creates client', () => { const test = (input, origin) => { const res = Client.type({ http: input }); expect(res.http.origin).to.eql(origin); expect(HttpClient.isClient(res.http)).to.eql(true); }; test(undefined, 'http://localhost:8080'); test(1234, 'http://localhost:1234'); test('domain.com', 'https://domain.com'); test('domain.com:1234', 'https://domain.com:1234'); test({ host: 'foo.com' }, 'https://foo.com'); }); it('uses given [IHttpClient]', () => { const client = HttpClient.create(); const res = Client.type({ http: client }); expect(res.http).to.equal(client); }); }); });