refactor: typescript support
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
@@ -1,21 +0,0 @@
|
||||
import { parseUrlAndPath } from "../uri"
|
||||
|
||||
describe("parseUrlAndPath", () => {
|
||||
test("has url and path fields", () => {
|
||||
const result = parseUrlAndPath("https://hoppscotch.io/")
|
||||
|
||||
expect(result).toHaveProperty("url")
|
||||
expect(result).toHaveProperty("path")
|
||||
})
|
||||
|
||||
test("parses out URL correctly", () => {
|
||||
const result = parseUrlAndPath("https://hoppscotch.io/test/page")
|
||||
|
||||
expect(result.url).toBe("https://hoppscotch.io")
|
||||
})
|
||||
test("parses out Path correctly", () => {
|
||||
const result = parseUrlAndPath("https://hoppscotch.io/test/page")
|
||||
|
||||
expect(result.path).toBe("/test/page")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user