Skip to content

Commit 5ef5a1e

Browse files
authored
feat: remove test server code from sdk repo, and fix tests (#170)
1 parent 4dc4125 commit 5ef5a1e

35 files changed

+31
-823
lines changed

Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

fly.toml

Lines changed: 0 additions & 16 deletions
This file was deleted.

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
"build:module": "tsc -p tsconfig.module.json",
4343
"build:umd": "webpack --mode=production",
4444
"watch": "nodemon -e ts --watch src --exec \"npm run build\"",
45-
"test:server:build": "tsc -p tsconfig.testServer.json",
46-
"test:server": "nodemon -e ts --watch src --watch test --exec \"ts-node test/testServer.ts\"",
47-
"test": "mocha -r ts-node/register test/*test.ts test/**/*test.ts --insect || :",
45+
"test": "mocha -r ts-node/register test/*test.ts test/**/*test.ts --insect --timeout 5000 || :",
4846
"test:coverage": "nyc --reporter=lcovonly --reporter=text --reporter=text-summary npm run test",
4947
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
5048
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals"
@@ -60,17 +58,12 @@
6058
"@faker-js/faker": "^8.0.2",
6159
"@flydotio/dockerfile": "^0.4.10",
6260
"@types/chai": "^4.3.5",
63-
"@types/express-ws": "^3.0.2",
6461
"@types/mocha": "^9.1.1",
6562
"@types/ws": "^8.5.6",
6663
"chai": "^4.3.7",
6764
"cross-env": "^7.0.3",
68-
"express-ws": "^5.0.2",
69-
"fetch-mock": "^9.11.0",
7065
"husky": "^4.3.0",
7166
"mocha": "^9.2.2",
72-
"mock-socket": "^9.2.1",
73-
"nock": "^13.3.2",
7467
"nodemon": "^3.0.1",
7568
"npm-run-all": "^4.1.5",
7669
"nyc": "^15.1.0",
@@ -86,10 +79,6 @@
8679
"webpack-cli": "^4.9.2",
8780
"ws": "^8.13.0"
8881
},
89-
"peerDependencies": {
90-
"@types/express": "^4.17.17",
91-
"express": "^4.18.2"
92-
},
9382
"husky": {
9483
"hooks": {
9584
"pre-commit": "pretty-quick --staged",

test/client.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { faker } from "@faker-js/faker";
55
import { stripTrailingSlash } from "../src/lib/helpers";
66
import DeepgramClient from "../src/DeepgramClient";
77
import { ListenClient } from "../src/packages/ListenClient";
8-
import { customDomain } from "./mocks";
98

109
const deepgram = createClient(faker.string.alphanumeric(40));
1110

@@ -39,18 +38,18 @@ describe("testing creation of a deepgram client object", () => {
3938

4039
it("it should create the client object with a custom domain", () => {
4140
const client = createClient(faker.string.alphanumeric(40), {
42-
global: { url: customDomain },
41+
global: { url: "https://deepgram-mock-api-server.fly.dev" },
4342
});
4443

4544
// @ts-ignore
4645
const url = client.baseUrl.hostname;
4746

4847
expect(client).is.instanceOf(DeepgramClient);
49-
expect(url).to.equal(customDomain);
48+
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
5049
});
5150

5251
it("it should strip trailing slashes off the API URL if they're supplied", () => {
53-
const domain = `${customDomain}/`;
52+
const domain = `https://deepgram-mock-api-server.fly.dev/`;
5453
const client = createClient(faker.string.alphanumeric(40), {
5554
global: { url: domain },
5655
});
@@ -59,7 +58,20 @@ describe("testing creation of a deepgram client object", () => {
5958
const url = client.baseUrl.hostname;
6059

6160
expect(client).is.instanceOf(DeepgramClient);
62-
expect(url).to.equal(stripTrailingSlash(domain));
61+
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
62+
});
63+
64+
it("it should still work when provided a URL without a protocol", () => {
65+
const domain = `deepgram-mock-api-server.fly.dev`;
66+
const client = createClient(faker.string.alphanumeric(40), {
67+
global: { url: domain },
68+
});
69+
70+
// @ts-ignore
71+
const url = client.baseUrl.hostname;
72+
73+
expect(client).is.instanceOf(DeepgramClient);
74+
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
6375
});
6476

6577
it("it should allow for the supply of a custom header", () => {

test/mocks/asyncConfirmation.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/mocks/bufferSource.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/mocks/customDomain.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/mocks/index.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/mocks/liveMetadata.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/mocks/liveTranscription.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/mocks/message.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/mocks/newOnpremCredential.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/mocks/newProjectKey.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/mocks/onpremCredential.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/mocks/onpremCredentials.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/mocks/project.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/mocks/projectBalance.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/mocks/projectBalances.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/mocks/projectInvites.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)