Skip to content

Commit b3ba4a2

Browse files
committed
...
1 parent 0d22485 commit b3ba4a2

File tree

4 files changed

+68
-55
lines changed

4 files changed

+68
-55
lines changed

__tests__/mock.test.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useCompose } from "@olton/hooks";
2+
13
describe(`Mock tests`, () => {
24
it('toHaveBeenCalled', () => {
35
const mockFn = mock()
@@ -21,4 +23,15 @@ describe(`Mock tests`, () => {
2123
mockFn(3)
2224
expect(mockFn).toHaveBeenLastCalledWith([3])
2325
})
26+
it('useCompose - should compose functions correctly', () => {
27+
const funcA = mock((x) => x + 1);
28+
const funcB = mock((x) => x * 2);
29+
30+
const result = useCompose(funcA, funcB)
31+
32+
// Перевіряємо обчислення
33+
expect(result(3)).toBe(7); // (3 * 2) + 1 = 7
34+
expect(funcA).toHaveBeenCalledWith([6]);
35+
expect(funcB).toHaveBeenCalledWith([3]);
36+
});
2437
})

package-lock.json

+47-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@olton/easytest",
3-
"version": "0.41.1",
3+
"version": "0.41.2",
44
"main": "src/index.js",
55
"bin": {
66
"easytest": "cli/easytest.js"
@@ -9,7 +9,7 @@
99
"type": "module",
1010
"scripts": {
1111
"pub": "npm publish --access public",
12-
"test": "tsx cli/easytest.js --dom --coverage --verbose"
12+
"test": "tsx cli/easytest.js --dom --verbose --include='__tests__/mock.test.js'"
1313
},
1414
"keywords": [
1515
"javascript",
@@ -30,16 +30,16 @@
3030
"email": "[email protected]"
3131
},
3232
"dependencies": {
33-
"@happy-dom/global-registrator": "^17.1.3",
33+
"@happy-dom/global-registrator": "^17.4.3",
3434
"chalk": "^5.4.1",
3535
"glob": "^11.0.1",
36-
"happy-dom": "^17.1.3",
37-
"puppeteer": "^24.2.1",
36+
"happy-dom": "^17.4.3",
37+
"puppeteer": "^24.4.0",
3838
"table": "^6.9.0",
3939
"yargs": "^17.7.2"
4040
},
4141
"devDependencies": {
4242
"tsx": "^4.19.3",
43-
"typescript": "^5.7.3"
43+
"typescript": "^5.8.2"
4444
}
4545
}

types/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ export declare function afterEach(fn: () => void): void;
348348
* Mocks a function or object to simulate a specific behavior.
349349
*
350350
* @param {Function} fn - The function to be mocked.
351-
* @return {void} This function does not return any value.
351+
* @return {function}
352352
*/
353-
export declare function mocker(fn: () => void): void;
353+
export declare function mock(fn: () => {}): any;
354354

355355
export declare class ExpectError extends Error{
356356
constructor(message: string, matcher: string, received: any, expected: any)

0 commit comments

Comments
 (0)