-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from jrTilak/satnize/count
chore: sanitize count
- Loading branch information
Showing
9 changed files
with
4,244 additions
and
3,424 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 9 additions & 10 deletions
19
src/www/src/registry/functions/functional/count/count.example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import count from "." | ||
import count from "."; | ||
|
||
const add =(a:number, b:number)=>{ | ||
return a+b; | ||
} | ||
const add = (a: number, b: number) => { | ||
return a + b; | ||
}; | ||
|
||
const countAddFn = count(add); | ||
countAddFn(1, 2); | ||
countAddFn(3, 4); | ||
|
||
const countAddFn = count(add); | ||
countAddFn(1,2); | ||
// Expected Output: Original function called 1 times | ||
countAddFn(3,4); | ||
// Expected Output: Original function called 2 times | ||
console.log(countAddFn.getCount()); | ||
// Expected Output: 2 | ||
// Expected Output: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 27 additions & 30 deletions
57
src/www/src/registry/functions/functional/count/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
import { expect, test, describe } from 'vitest' | ||
import count from "." | ||
import { expect, test, describe } from "vitest"; | ||
import count from "."; | ||
|
||
describe('count', () => { | ||
//Test case 1: Testing the wrapper function | ||
test('calls the function passed and returns the result', ()=>{ | ||
const mockFunction = (a: number, b: number): number => { | ||
return a + b; | ||
}; | ||
const countedFunction = count(mockFunction); | ||
expect(countedFunction(1,2)).toBe(3); | ||
}) | ||
describe("count", () => { | ||
//Test case 1: Testing the wrapper function | ||
test("calls the function passed and returns the result", () => { | ||
const mockFunction = (a: number, b: number): number => { | ||
return a + b; | ||
}; | ||
const countedFunction = count(mockFunction); | ||
expect(countedFunction(1, 2)).toBe(3); | ||
}); | ||
|
||
|
||
// Test case 2: Testing the getCount function | ||
test('resturns the count of function calls', ()=>{ | ||
const mockFunction = (a: number, b: number): number => { | ||
return Math.abs(a - b); | ||
}; | ||
const countedFunction = count(mockFunction); | ||
countedFunction(4,6); | ||
countedFunction(10,6); | ||
countedFunction(4,5); | ||
countedFunction(4,13); | ||
countedFunction(155,6); | ||
countedFunction(109,126); | ||
// Test case 2: Testing the getCount function | ||
test("returns the count of function calls", () => { | ||
const mockFunction = (a: number, b: number): number => { | ||
return Math.abs(a - b); | ||
}; | ||
const countedFunction = count(mockFunction); | ||
countedFunction(4, 6); | ||
countedFunction(10, 6); | ||
countedFunction(4, 5); | ||
countedFunction(4, 13); | ||
countedFunction(155, 6); | ||
countedFunction(109, 126); | ||
|
||
//test the getCount method | ||
expect(countedFunction.getCount()).toBe(6) | ||
}) | ||
|
||
|
||
}) | ||
//test the getCount method | ||
expect(countedFunction.getCount()).toBe(6); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters