Skip to content

Commit

Permalink
Make things work again
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team authored and renovate[bot] committed Jan 25, 2024
1 parent ff339f6 commit 0c38978
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 102 deletions.
3 changes: 2 additions & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
recursive: true,
extension: ['.test.ts'],
require: 'mocha.setup.js',
'node-option': ['loader=ts-node/esm', 'no-warnings'],
require: ['chai/register-expect.js', 'ts-node/register'],
reporter: 'mocha-multi',
'reporter-option': [
'spec=-',
Expand Down
6 changes: 0 additions & 6 deletions mocha.setup.js

This file was deleted.

141 changes: 55 additions & 86 deletions package-lock.json

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

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
"devDependencies": {
"@myrotvorets/eslint-config-myrotvorets-ts": "^2.24.0",
"@types/chai": "^4.3.11",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
"@types/node": ">= 20.11.6",
"c8": "^9.1.0",
"chai": "^5.0.3",
"chai-as-promised": "^7.1.1",
"eslint-formatter-gha": "^1.4.3",
"eslint-plugin-mocha": "^10.2.0",
"mocha": "^10.2.0",
Expand Down
5 changes: 3 additions & 2 deletions test/bufferstream.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { expect } from 'chai';
import { BufferStream, streamToBuffer } from '../lib';

import './types';

describe('BufferStream', function (): void {
it('should convert a Buffer into a ReadableStream', function () {
const buf = Buffer.from('123');
const stream = new BufferStream(buf);

return expect(streamToBuffer(stream)).to.become(buf);
return streamToBuffer(stream).then((result) => expect(result).to.deep.equal(buf));
});
});
10 changes: 7 additions & 3 deletions test/streamtobuffer.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { createReadStream, promises } from 'node:fs';
import { Readable } from 'node:stream';
import { expect } from 'chai';
import { streamToBuffer } from '../lib';

import './types';

const error = new Error('путин - хуйло');

class FailingStream extends Readable {
Expand All @@ -14,12 +15,15 @@ class FailingStream extends Readable {
describe('streamToBuffer', function () {
it('should reject on stream faulres', function () {
const stream = new FailingStream();
return expect(streamToBuffer(stream)).to.be.eventually.rejectedWith(error);
return streamToBuffer(stream).then(
() => expect.fail('should not resolve'),
(err) => expect(err).to.equal(error),
);
});

it('should produce the same result as readFile', async function () {
const expected = await promises.readFile(__filename);
const stream = createReadStream(__filename);
return expect(streamToBuffer(stream)).to.become(expected);
return streamToBuffer(stream).then((result) => expect(result).to.deep.equal(expected));
});
});
5 changes: 5 additions & 0 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {};

declare global {
const expect: typeof chai.expect;
}
3 changes: 1 addition & 2 deletions test/writablebufferstream.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from 'chai';
import { WritableBufferStream } from '../lib';
import { WritableBufferStream } from '../lib/index';

describe('WritableBufferStream', function (): void {
it('should have the initial buffer as null', function () {
Expand Down

0 comments on commit 0c38978

Please sign in to comment.