Skip to content

Commit

Permalink
feat: remove test server code from sdk repo, and fix tests (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeocodes authored Oct 16, 2023
1 parent 4dc4125 commit 5ef5a1e
Show file tree
Hide file tree
Showing 35 changed files with 31 additions and 823 deletions.
41 changes: 0 additions & 41 deletions Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions fly.toml

This file was deleted.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
"build:module": "tsc -p tsconfig.module.json",
"build:umd": "webpack --mode=production",
"watch": "nodemon -e ts --watch src --exec \"npm run build\"",
"test:server:build": "tsc -p tsconfig.testServer.json",
"test:server": "nodemon -e ts --watch src --watch test --exec \"ts-node test/testServer.ts\"",
"test": "mocha -r ts-node/register test/*test.ts test/**/*test.ts --insect || :",
"test": "mocha -r ts-node/register test/*test.ts test/**/*test.ts --insect --timeout 5000 || :",
"test:coverage": "nyc --reporter=lcovonly --reporter=text --reporter=text-summary npm run test",
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals"
Expand All @@ -60,17 +58,12 @@
"@faker-js/faker": "^8.0.2",
"@flydotio/dockerfile": "^0.4.10",
"@types/chai": "^4.3.5",
"@types/express-ws": "^3.0.2",
"@types/mocha": "^9.1.1",
"@types/ws": "^8.5.6",
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"express-ws": "^5.0.2",
"fetch-mock": "^9.11.0",
"husky": "^4.3.0",
"mocha": "^9.2.2",
"mock-socket": "^9.2.1",
"nock": "^13.3.2",
"nodemon": "^3.0.1",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
Expand All @@ -86,10 +79,6 @@
"webpack-cli": "^4.9.2",
"ws": "^8.13.0"
},
"peerDependencies": {
"@types/express": "^4.17.17",
"express": "^4.18.2"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged",
Expand Down
22 changes: 17 additions & 5 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { faker } from "@faker-js/faker";
import { stripTrailingSlash } from "../src/lib/helpers";
import DeepgramClient from "../src/DeepgramClient";
import { ListenClient } from "../src/packages/ListenClient";
import { customDomain } from "./mocks";

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

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

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

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

expect(client).is.instanceOf(DeepgramClient);
expect(url).to.equal(customDomain);
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
});

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

expect(client).is.instanceOf(DeepgramClient);
expect(url).to.equal(stripTrailingSlash(domain));
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
});

it("it should still work when provided a URL without a protocol", () => {
const domain = `deepgram-mock-api-server.fly.dev`;
const client = createClient(faker.string.alphanumeric(40), {
global: { url: domain },
});

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

expect(client).is.instanceOf(DeepgramClient);
expect(url).to.equal("deepgram-mock-api-server.fly.dev");
});

it("it should allow for the supply of a custom header", () => {
Expand Down
8 changes: 0 additions & 8 deletions test/mocks/asyncConfirmation.ts

This file was deleted.

10 changes: 0 additions & 10 deletions test/mocks/bufferSource.ts

This file was deleted.

5 changes: 0 additions & 5 deletions test/mocks/customDomain.ts

This file was deleted.

26 changes: 0 additions & 26 deletions test/mocks/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions test/mocks/liveMetadata.ts

This file was deleted.

35 changes: 0 additions & 35 deletions test/mocks/liveTranscription.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/mocks/message.ts

This file was deleted.

19 changes: 0 additions & 19 deletions test/mocks/newOnpremCredential.ts

This file was deleted.

13 changes: 0 additions & 13 deletions test/mocks/newProjectKey.ts

This file was deleted.

18 changes: 0 additions & 18 deletions test/mocks/onpremCredential.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/mocks/onpremCredentials.ts

This file was deleted.

10 changes: 0 additions & 10 deletions test/mocks/project.ts

This file was deleted.

11 changes: 0 additions & 11 deletions test/mocks/projectBalance.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/mocks/projectBalances.ts

This file was deleted.

13 changes: 0 additions & 13 deletions test/mocks/projectInvites.ts

This file was deleted.

Loading

0 comments on commit 5ef5a1e

Please sign in to comment.