Skip to content

Commit 3dd988e

Browse files
authored
Merge pull request #2122 from cjihrig/tests
test: support testing transpiled code
2 parents 722b826 + 0d58445 commit 3dd988e

9 files changed

+15
-8
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ jobs:
2525
- run: npm test
2626
- run: npm run lint
2727
- run: npm audit --audit-level=critical
28+
- run: npm run build-with-tests && npm run test-transpiled

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
"lint": "tslint --project \".\" && prettier --check \"./src/**/*.ts\" && tslint --project \"./examples/typescript\"",
2424
"clean": "rm -Rf node_modules/ dist/",
2525
"build": "tsc",
26+
"build-with-tests": "tsc --project tsconfig-with-tests.json && cp 'src/test/echo space.js' dist/test",
2627
"generate": "./generate-client.sh",
2728
"watch": "tsc --watch",
2829
"test": "c8 mocha",
30+
"test-transpiled": "mocha --no-config dist",
2931
"prepare": "npm run build && husky",
3032
"prepack": "npm run build",
3133
"docs": "typedoc src/gen/api"

src/attach_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import WebSocket from 'isomorphic-ws';
33
import { ReadableStreamBuffer, WritableStreamBuffer } from 'stream-buffers';
44
import { anyFunction, anything, capture, instance, mock, verify, when } from 'ts-mockito';
55

6-
import { CallAwaiter, matchBuffer, ResizableWriteableStreamBuffer } from './test';
6+
import { CallAwaiter, matchBuffer, ResizableWriteableStreamBuffer } from './test/index.js';
77
import { Attach } from './attach.js';
88
import { KubeConfig } from './config.js';
99
import { TerminalSize } from './terminal-size-queue.js';

src/config_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import mockfs from 'mock-fs';
1010

1111
import { Headers } from 'node-fetch';
1212
import { HttpMethod } from './index.js';
13-
import { assertRequestAgentsEqual, assertRequestOptionsEqual } from './test/match-buffer';
13+
import { assertRequestAgentsEqual, assertRequestOptionsEqual } from './test/match-buffer.js';
1414
import { CoreV1Api, RequestContext } from './api.js';
1515
import { bufferFromFileOrString, findHomeDir, findObject, KubeConfig, makeAbsolutePath } from './config.js';
1616
import { ActionOnInvalid, Cluster, newClusters, newContexts, newUsers, User } from './config_types.js';

src/cp_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { anything, anyFunction, instance, mock, verify, when } from 'ts-mockito'
22
import querystring from 'node:querystring';
33
import WebSocket from 'isomorphic-ws';
44

5-
import { CallAwaiter } from './test';
5+
import { CallAwaiter } from './test/index.js';
66
import { KubeConfig } from './config.js';
77
import { Exec } from './exec.js';
88
import { Cp } from './cp.js';

src/exec_test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import WebSocket from 'isomorphic-ws';
33
import { ReadableStreamBuffer, WritableStreamBuffer } from 'stream-buffers';
44
import { anyFunction, anything, capture, instance, mock, verify, when } from 'ts-mockito';
55

6-
import { CallAwaiter, matchBuffer, ResizableWriteableStreamBuffer } from './test';
6+
import { CallAwaiter, matchBuffer, ResizableWriteableStreamBuffer } from './test/index.js';
77
import { V1Status } from './api.js';
88
import { KubeConfig } from './config.js';
99
import { Exec } from './exec.js';

src/test/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from './call-awaiter';
2-
export * from './match-buffer';
3-
export * from './resizable-writeable-stream-buffer';
1+
export * from './call-awaiter.js';
2+
export * from './match-buffer.js';
3+
export * from './resizable-writeable-stream-buffer.js';

src/test/match-buffer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22
import { RequestOptions, Agent } from 'node:https';
3-
import { Matcher } from 'ts-mockito/lib/matcher/type/Matcher';
3+
import { Matcher } from 'ts-mockito/lib/matcher/type/Matcher.js';
44

55
export function matchBuffer(channel: number, contents: string): StringBufferMatcher {
66
return new StringBufferMatcher(channel, contents);

tsconfig-with-tests.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": []
4+
}

0 commit comments

Comments
 (0)