From 4a853395c31aa2fb400b3e784100e3e4741e4b4c Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Sat, 24 Oct 2020 13:58:14 +0200 Subject: [PATCH] Start on itemshandler test --- packages/sdk-js/tests/handlers/items.ts | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 packages/sdk-js/tests/handlers/items.ts diff --git a/packages/sdk-js/tests/handlers/items.ts b/packages/sdk-js/tests/handlers/items.ts new file mode 100644 index 0000000000..dc8eb095de --- /dev/null +++ b/packages/sdk-js/tests/handlers/items.ts @@ -0,0 +1,40 @@ +import { ItemsHandler } from '../../src/handlers/items'; +import axios, { AxiosInstance } from 'axios'; +import sinon, { SinonSandbox } from 'sinon'; +import chai, { expect } from 'chai'; +import sinonChai from 'sinon-chai'; + +chai.use(sinonChai); + +describe('ItemsHandler', () => { + let sandbox: SinonSandbox; + let axiosInstance: AxiosInstance; + let handler: ItemsHandler; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + axiosInstance = axios.create(); + handler = new ItemsHandler('test', axiosInstance); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('constructor', () => { + it('Sets the passed collection to this.collection', () => { + const handler = new ItemsHandler('test', axiosInstance); + expect(handler['collection']).to.equal('test'); + }); + }); + + // describe('specs.oas', () => { + // it('Calls the /server/specs/oas endpoint', async () => { + // const stub = sandbox + // .stub(handler['axios'], 'get') + // .returns(Promise.resolve({ data: '' })); + // await handler.specs.oas(); + // expect(stub).to.have.been.calledWith('/server/specs/oas'); + // }); + // }); +});