Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrading deps #169

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,937 changes: 2,282 additions & 3,655 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "utils-decorators",
"version": "2.0.9",
"version": "2.10.0",
"description": "decorators for reducing repetitive code",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"devDependencies": {
"@babel/core": "^7.23.6",
"@babel/core": "^7.26.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@babel/preset-typescript": "^7.23.3",
"@stryker-mutator/core": "^8.0.0",
"@stryker-mutator/jest-runner": "^8.0.0",
"@babel/plugin-proposal-decorators": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@stryker-mutator/core": "^8.6.0",
"@stryker-mutator/jest-runner": "^8.6.0",
"@stryker-mutator/typescript": "^4.0.0",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.14",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
Expand All @@ -24,7 +24,7 @@
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"jest": "^29.7.0",
"typescript": "^5.3.3"
"typescript": "^5.6.3"
},
"scripts": {
"test": "npm run clean && tsc -p tsconfig.test.json --noEmit && npm run lint && jest --coverage && npm run test:mutation",
Expand Down
10 changes: 5 additions & 5 deletions src/after/after.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('after', () => {
const spyAfter = jest.spyOn(T.prototype, 'after');

t.foo(1);
expect(spyGoo).toBeCalledTimes(1);
expect(spyGoo).toBeCalledWith(1);
expect(spyAfter).toBeCalledTimes(1);
expect(spyGoo).toHaveBeenCalledTimes(1);
expect(spyGoo).toHaveBeenCalledWith(1);
expect(spyAfter).toHaveBeenCalledTimes(1);
});

it('should verify after method invocation when method is provided', () => {
Expand Down Expand Up @@ -80,8 +80,8 @@ describe('after', () => {
const spyGoo = jest.spyOn(T.prototype, 'goo');

t.foo(1);
expect(spyGoo).toBeCalledTimes(1);
expect(spyGoo).toBeCalledWith(1);
expect(spyGoo).toHaveBeenCalledTimes(1);
expect(spyGoo).toHaveBeenCalledWith(1);
expect(afterFunc.mock.calls.length).toBe(1);
});

Expand Down
10 changes: 5 additions & 5 deletions src/before/before.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe('before', () => {
const spyBefore = jest.spyOn(T.prototype, 'before');

t.foo(1);
expect(spyGoo).toBeCalledTimes(1);
expect(spyGoo).toBeCalledWith(1);
expect(spyBefore).toBeCalledTimes(1);
expect(spyGoo).toHaveBeenCalledTimes(1);
expect(spyGoo).toHaveBeenCalledWith(1);
expect(spyBefore).toHaveBeenCalledTimes(1);
});

it('should verify before method invocation when method is provided', () => {
Expand Down Expand Up @@ -79,8 +79,8 @@ describe('before', () => {
const spyGoo = jest.spyOn(T.prototype, 'goo');

t.foo(1);
expect(spyGoo).toBeCalledTimes(1);
expect(spyGoo).toBeCalledWith(1);
expect(spyGoo).toHaveBeenCalledTimes(1);
expect(spyGoo).toHaveBeenCalledWith(1);
expect(beforeFunc.mock.calls.length).toBe(1);
});

Expand Down
47 changes: 47 additions & 0 deletions src/common/data-stractures/queue.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Queue } from './queue';

describe('Queue', () => {
it('should initialize with size 0', () => {
const queue = new Queue<number>();
expect(queue.getSize()).toBe(0);
expect(queue.isEmpty()).toBe(true);
});

it('should enqueue items and update size', () => {
const queue = new Queue<number>();
queue.enqueue(1);
expect(queue.getSize()).toBe(1);
expect(queue.isEmpty()).toBe(false);
queue.enqueue(2);
expect(queue.getSize()).toBe(2);
});

it('should dequeue items in the correct order', () => {
const queue = new Queue<number>();
queue.enqueue(1);
queue.enqueue(2);
expect(queue.dequeue()).toBe(1);
expect(queue.getSize()).toBe(1);
expect(queue.dequeue()).toBe(2);
expect(queue.getSize()).toBe(0);
expect(queue.isEmpty()).toBe(true);
});

it('should return null when dequeue is called on an empty queue', () => {
const queue = new Queue<number>();
expect(queue.dequeue()).toBeNull();
});

it('should handle enqueue and dequeue operations correctly', () => {
const queue = new Queue<number>();
queue.enqueue(1);
queue.enqueue(2);
queue.enqueue(3);
expect(queue.dequeue()).toBe(1);
queue.enqueue(4);
expect(queue.dequeue()).toBe(2);
expect(queue.dequeue()).toBe(3);
expect(queue.dequeue()).toBe(4);
expect(queue.isEmpty()).toBe(true);
});
});
36 changes: 18 additions & 18 deletions src/common/tesk-exec/task-exec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ describe('utils', () => {

await sleep(20);

expect(funA).not.toBeCalled();
expect(funA).not.toHaveBeenCalled();
runner.exec(funB, 40);

await sleep(20);

expect(funA).not.toBeCalled();
expect(funB).not.toBeCalled();
expect(funA).not.toHaveBeenCalled();
expect(funB).not.toHaveBeenCalled();

await sleep(40);

expect(funA).not.toBeCalled();
expect(funB).toBeCalledTimes(1);
expect(funA).not.toHaveBeenCalled();
expect(funB).toHaveBeenCalledTimes(1);

await sleep(100);

expect(funA).toBeCalledTimes(1);
expect(funB).toBeCalledTimes(1);
expect(funA).toHaveBeenCalledTimes(1);
expect(funB).toHaveBeenCalledTimes(1);
expect(val).toBe('BA');
});

Expand All @@ -51,18 +51,18 @@ describe('utils', () => {

await sleep(20);

expect(funA).not.toBeCalled();
expect(funB).not.toBeCalled();
expect(funA).not.toHaveBeenCalled();
expect(funB).not.toHaveBeenCalled();

await sleep(50);

expect(funA).toBeCalled();
expect(funB).not.toBeCalled();
expect(funA).toHaveBeenCalled();
expect(funB).not.toHaveBeenCalled();

await sleep(50);

expect(funA).toBeCalledTimes(1);
expect(funB).toBeCalledTimes(1);
expect(funA).toHaveBeenCalledTimes(1);
expect(funB).toHaveBeenCalledTimes(1);
expect(val).toBe('AB');
});

Expand All @@ -77,14 +77,14 @@ describe('utils', () => {

await sleep(20);

expect(funA).not.toBeCalled();
expect(funB).not.toBeCalled();
expect(funA).not.toHaveBeenCalled();
expect(funB).not.toHaveBeenCalled();
runner.exec(funC, 10);

await sleep(50);

expect(funA).toBeCalledTimes(1);
expect(funB).toBeCalledTimes(1);
expect(funC).toBeCalledTimes(1);
expect(funA).toHaveBeenCalledTimes(1);
expect(funB).toHaveBeenCalledTimes(1);
expect(funC).toHaveBeenCalledTimes(1);
});
});
20 changes: 10 additions & 10 deletions src/debounce/debounce.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ describe('debounce', () => {
const spy = jest.spyOn(T.prototype, 'goo');
t.foo(); // 15

expect(spy).not.toBeCalled();
expect(spy).not.toHaveBeenCalled();

await sleep(10);
expect(spy).toBeCalledTimes(0);
expect(spy).toHaveBeenCalledTimes(0);
t.foo(); // 20

await sleep(20);
expect(spy).toBeCalledTimes(0);
expect(spy).toHaveBeenCalledTimes(0);

await sleep(40);
expect(spy).toBeCalledTimes(1);
expect(spy).toHaveBeenCalledTimes(1);
});

it('should verify method params are passed', (done) => {
Expand Down Expand Up @@ -91,18 +91,18 @@ describe('debounce', () => {
const spy2 = jest.spyOn(t1, 'goo');
t1.foo();

expect(spy1).not.toBeCalled();
expect(spy2).not.toBeCalled();
expect(spy1).not.toHaveBeenCalled();
expect(spy2).not.toHaveBeenCalled();

await sleep(10);
expect(spy1).not.toBeCalled();
expect(spy1).not.toHaveBeenCalled();
t2.foo(); // 20

await sleep(30); // 40
expect(spy1).toBeCalledTimes(1);
expect(spy1).toHaveBeenCalledTimes(1);

await sleep(30); // 70
expect(spy1).toBeCalledTimes(1);
expect(spy2).toBeCalledTimes(1);
expect(spy1).toHaveBeenCalledTimes(1);
expect(spy2).toHaveBeenCalledTimes(1);
});
});
6 changes: 3 additions & 3 deletions src/delay/delay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ describe('delay', () => {
t.foo(1);

await sleep(20);
expect(spy).not.toBeCalled();
expect(spy).not.toHaveBeenCalled();

await sleep(50);

t.foo(2);
expect(spy).toBeCalledTimes(1);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).lastCalledWith(1);

await sleep(75);

expect(spy).toBeCalledTimes(2);
expect(spy).toHaveBeenCalledTimes(2);
});
});
8 changes: 4 additions & 4 deletions src/exec-time/exec-time.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('exec-time', () => {
const t = new T();
t.foo('a');

expect(reporter).toBeCalledTimes(1);
expect(reporter).toHaveBeenCalledTimes(1);
const args: ExactTimeReportData = reporter.mock.calls[0][0];
expect(args.args).toEqual(['a']);
expect(args.result).toEqual('ab');
Expand All @@ -56,7 +56,7 @@ describe('exec-time', () => {
const t = new T();
await t.foo('a');

expect(reporter).toBeCalledTimes(1);
expect(reporter).toHaveBeenCalledTimes(1);
const args: ExactTimeReportData = reporter.mock.calls[0][0];
expect(args.args).toEqual(['a']);
expect(args.result).toEqual('ab');
Expand All @@ -76,7 +76,7 @@ describe('exec-time', () => {

const t = new T();
await t.foo('a');
expect(logSpy).toBeCalledTimes(1);
expect(logSpy).toHaveBeenCalledTimes(1);
const clogSpyArgs = logSpy.mock.calls[0][0];
expect(clogSpyArgs).toBeGreaterThanOrEqual(0);
logSpy.mockRestore();
Expand All @@ -97,7 +97,7 @@ describe('exec-time', () => {
const t = new T();
await t.foo('a');

expect(t.goo).toBeCalledTimes(1);
expect(t.goo).toHaveBeenCalledTimes(1);
const args: ExactTimeReportData = t.goo.mock.calls[0][0];
expect(args.args).toEqual(['a']);
expect(args.result).toEqual('ab');
Expand Down
6 changes: 3 additions & 3 deletions src/memoize-async/memoize-async.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ describe('memozie-async', () => {

setTimeout(() => {
expect(spy).toHaveBeenCalledWith(1, 2);
expect(spy).toBeCalledTimes(1);
expect(spy).toHaveBeenCalledTimes(1);

const resp01 = t.foo(1, 3);

setTimeout(() => {
expect(spy).toHaveBeenCalledWith(1, 3);
expect(spy).toBeCalledTimes(2);
expect(spy).toHaveBeenCalledTimes(2);
}, 0);

setTimeout(async () => {
Expand All @@ -43,7 +43,7 @@ describe('memozie-async', () => {
setTimeout(async () => {
expect(spy).toHaveBeenCalledWith(1, 2);

expect(spy).toBeCalledTimes(3);
expect(spy).toHaveBeenCalledTimes(3);

expect(await resp1).toBe(3);
expect(await resp2).toBe(3);
Expand Down
4 changes: 2 additions & 2 deletions src/memoize/memoize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('memozie', () => {
const resp2 = t.foo(1, 2);
const resp4 = t.foo(1, 3);

expect(spy).toBeCalledTimes(2);
expect(spy).toHaveBeenCalledTimes(2);
expect(spy.mock.calls[0][0]).toBe(1);
expect(spy.mock.calls[0][1]).toBe(2);
expect(spy.mock.calls[1][0]).toBe(1);
Expand All @@ -36,7 +36,7 @@ describe('memozie', () => {
setTimeout(async () => {
const resp3 = t.foo(1, 2);

expect(spy).toBeCalledTimes(3);
expect(spy).toHaveBeenCalledTimes(3);
expect(resp1).toBe(3);
expect(resp2).toBe(3);
expect(resp3).toBe(3);
Expand Down
Loading
Loading