From 9f9167c9c780e975c228c18419698bfaf01743fe Mon Sep 17 00:00:00 2001 From: Michel Jonathan Schmitz Date: Wed, 13 May 2020 08:47:30 +0200 Subject: [PATCH] test: update test files --- test/client.spec.ts | 47 ++++++++++++++++++++++++++--------- test/connector-client.spec.ts | 20 +++++++++++---- test/plugin-client.spec.ts | 8 ++++-- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/test/client.spec.ts b/test/client.spec.ts index fd4fefb2..9ef973f8 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -98,7 +98,7 @@ export class ClientSpec { } @test - async constructWithVersion() { + async constructWithHeaders() { sandbox.on(httpClient, 'request', invokeIndexRoute); expect(httpClient.request).not.to.have.been.first.called(); @@ -109,6 +109,7 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {}, headers: { + 'Content-Type': 'application/json', 'X-StApps-Version': 'foo.foo.foo', }, method: indexRoute.method, @@ -156,7 +157,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: feedback, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: feedbackRoute.method, url: new URL('http://localhost' + feedbackRoute.getUrlFragment()), }); @@ -214,7 +217,9 @@ export class ClientSpec { }, size: 1, }, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: searchRoute.method, url: new URL('http://localhost' + searchRoute.getUrlFragment()), }); @@ -302,7 +307,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: indexRoute.method, url: new URL('http://localhost' + indexRoute.getUrlFragment()), }); @@ -330,7 +337,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: undefined, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: indexRoute.method, url: new URL('http://localhost' + indexRoute.getUrlFragment()), }); @@ -389,7 +398,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {a: {size: 1}, b: {size: 1}}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: multiSearchRoute.method, url: new URL('http://localhost' + multiSearchRoute.getUrlFragment()), }); @@ -437,13 +448,17 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {foo: {size: 0}, bar: {size: 0}}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: multiSearchRoute.method, url: new URL('http://localhost' + multiSearchRoute.getUrlFragment()), }); expect(httpClient.request).to.have.been.second.called.with({ body: {foo: {size: 1000}, bar: {size: 500}, foobar: {size: 30}}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: multiSearchRoute.method, url: new URL('http://localhost' + multiSearchRoute.getUrlFragment()), }); @@ -504,7 +519,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {size: 1}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: searchRoute.method, url: new URL('http://localhost' + searchRoute.getUrlFragment()), }); @@ -540,7 +557,9 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {from: 30, size: 30}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: searchRoute.method, url: new URL('http://localhost' + searchRoute.getUrlFragment()), }); @@ -574,13 +593,17 @@ export class ClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: {size: 0}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: searchRoute.method, url: new URL('http://localhost' + searchRoute.getUrlFragment()), }); expect(httpClient.request).to.have.been.second.called.with({ body: {size: 1000}, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: searchRoute.method, url: new URL('http://localhost' + searchRoute.getUrlFragment()), }); diff --git a/test/connector-client.spec.ts b/test/connector-client.spec.ts index cc125c06..6ac87686 100644 --- a/test/connector-client.spec.ts +++ b/test/connector-client.spec.ts @@ -109,7 +109,9 @@ export class ConnectorClientSpec { source: 'foo', type: SCThingType.Message, }, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: bulkRoute.method, url: new URL('http://localhost' + bulkRoute.getUrlFragment()), }); @@ -142,7 +144,9 @@ export class ConnectorClientSpec { source: 'foo', type: SCThingType.Message, }, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: bulkRoute.method, url: new URL('http://localhost' + bulkRoute.getUrlFragment()), }); @@ -223,7 +227,9 @@ export class ConnectorClientSpec { source: 'copy', type: SCThingType.Message, }, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: bulkRoute.method, url: new URL('http://localhost' + bulkRoute.getUrlFragment()), }); @@ -310,7 +316,9 @@ export class ConnectorClientSpec { source: 'stapps-api', type: SCThingType.Message, }, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: bulkRoute.method, url: new URL('http://localhost' + bulkRoute.getUrlFragment()), }); @@ -429,7 +437,9 @@ export class ConnectorClientSpec { expect(httpClient.request).to.have.been.called.with({ body: message, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: thingUpdateRoute.method, url: new URL('http://localhost' + thingUpdateRoute.getUrlFragment({ TYPE: SCThingType.Message, diff --git a/test/plugin-client.spec.ts b/test/plugin-client.spec.ts index a476e79f..b7f33d8b 100644 --- a/test/plugin-client.spec.ts +++ b/test/plugin-client.spec.ts @@ -77,7 +77,9 @@ export class PluginClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: request, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: pluginRegisterRoute.method, url: new URL(`http://localhost${pluginRegisterRoute.getUrlFragment()}`), }); @@ -106,7 +108,9 @@ export class PluginClientSpec { expect(httpClient.request).to.have.been.first.called.with({ body: request, - headers: {}, + headers: { + "Content-Type": "application/json", + }, method: pluginRegisterRoute.method, url: new URL(`http://localhost${pluginRegisterRoute.getUrlFragment()}`), });