refactor: monorepo+pnpm (removed husky)

This commit is contained in:
Andrew Bastin
2021-09-10 00:28:28 +05:30
parent 917550ff4d
commit b28f82a881
445 changed files with 81301 additions and 63752 deletions

View File

@@ -0,0 +1,38 @@
import debounce from "../debounce"
describe("debounce", () => {
test("doesn't call function right after calling", () => {
const fn = jest.fn()
const debFunc = debounce(fn, 100)
debFunc()
expect(fn).not.toHaveBeenCalled()
})
test("calls the function after the given timeout", () => {
const fn = jest.fn()
jest.useFakeTimers()
const debFunc = debounce(fn, 100)
debFunc()
jest.runAllTimers()
expect(fn).toHaveBeenCalled()
// expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 100)
})
test("calls the function only one time within the timeframe", () => {
const fn = jest.fn()
const debFunc = debounce(fn, 1000)
for (let i = 0; i < 100; i++) debFunc()
jest.runAllTimers()
expect(fn).toHaveBeenCalledTimes(1)
})
})