Skip to content

Commit

Permalink
Merge pull request #2167 from cjihrig/assert
Browse files Browse the repository at this point in the history
test: replace chai with node:assert
  • Loading branch information
k8s-ci-robot authored Jan 20, 2025
2 parents 95fe749 + 36d208b commit 8416822
Show file tree
Hide file tree
Showing 27 changed files with 821 additions and 1,128 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ Run `npm run lint` or install an editor plugin.

# Testing

Tests are written using the [Chai](http://chaijs.com/) library. See
Tests are written using the [Mocha](https://mochajs.org/) test runner and
[`node:assert`](https://nodejs.org/api/assert.html) assertion library. See
[`config_test.ts`](./src/config_test.ts) for an example.

To run tests, execute the following:
Expand Down
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default tseslint.config(
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
},
},
Expand Down
174 changes: 0 additions & 174 deletions package-lock.json

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

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,9 @@
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@types/chai": "^5.0.0",
"@types/chai-as-promised": "^8.0.1",
"@types/mocha": "^10.0.1",
"@types/mock-fs": "^4.13.1",
"c8": "^10.0.0",
"chai": "^5.1.2",
"chai-as-promised": "^8.0.0",
"eslint": "^9.18.0",
"husky": "^9.0.6",
"mocha": "^11.0.1",
Expand Down
12 changes: 6 additions & 6 deletions src/attach_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { strictEqual } from 'node:assert';
import WebSocket from 'isomorphic-ws';
import { ReadableStreamBuffer, WritableStreamBuffer } from 'stream-buffers';
import { anyFunction, anything, capture, instance, mock, verify, when } from 'ts-mockito';
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Attach', () => {
await attach.attach(namespace, pod, container, osStream, errStream, isStream, false);
const [, , outputFn] = capture(fakeWebSocketInterface.connect).last();

expect(outputFn).to.not.be.null;
strictEqual(typeof outputFn, 'function');

// this is redundant but needed for the compiler, sigh...
if (!outputFn) {
Expand All @@ -83,18 +83,18 @@ describe('Attach', () => {
let buffer = Buffer.alloc(1024, 10);

outputFn(WebSocketHandler.StdoutStream, buffer);
expect(osStream.size()).to.equal(1024);
strictEqual(osStream.size(), 1024);
let buff = osStream.getContents() as Buffer;
for (let i = 0; i < 1024; i++) {
expect(buff[i]).to.equal(10);
strictEqual(buff[i], 10);
}

buffer = Buffer.alloc(1024, 20);
outputFn(WebSocketHandler.StderrStream, buffer);
expect(errStream.size()).to.equal(1024);
strictEqual(errStream.size(), 1024);
buff = errStream.getContents() as Buffer;
for (let i = 0; i < 1024; i++) {
expect(buff[i]).to.equal(20);
strictEqual(buff[i], 20);
}

const initialTerminalSize: TerminalSize = { height: 0, width: 0 };
Expand Down
Loading

0 comments on commit 8416822

Please sign in to comment.