-
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.
upgraded jest, typescript and fixed tests
- Loading branch information
darausi
committed
Sep 7, 2023
1 parent
e66f7fc
commit c7a02d0
Showing
8 changed files
with
976 additions
and
2,238 deletions.
There are no files selected for viewing
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
55 changes: 34 additions & 21 deletions
55
src/components/AutoSuggestion/tests/AutoSuggestion.test.tsx
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,37 +1,50 @@ | ||
import React from "react"; | ||
import "@testing-library/jest-dom"; | ||
import {render} from "@testing-library/react"; | ||
import AutoSuggestion, {AutoSuggestionProps} from "../AutoSuggestion" | ||
import { render } from "@testing-library/react"; | ||
import AutoSuggestion, { AutoSuggestionProps } from "../AutoSuggestion"; | ||
|
||
describe("AutoSuggestion", () => { | ||
let props: AutoSuggestionProps | ||
let props: AutoSuggestionProps; | ||
|
||
beforeAll(() => { | ||
document.createRange = () => { | ||
const range = new Range(); | ||
range.getBoundingClientRect = jest.fn(); | ||
range.getClientRects = () => { | ||
return { | ||
item: () => null, | ||
length: 0, | ||
[Symbol.iterator]: jest.fn(), | ||
}; | ||
}; | ||
return range; | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
props = { | ||
label: "test value path", | ||
initialValue: "", | ||
onChange: jest.fn((value) => { | ||
}), | ||
onChange: jest.fn((value) => {}), | ||
fetchSuggestions: jest.fn((inputString, cursorPosition) => undefined), | ||
checkInput: jest.fn(inputString => ({ | ||
valid: true | ||
checkInput: jest.fn((inputString) => ({ | ||
valid: true, | ||
})), | ||
onInputChecked: jest.fn(validInput => { | ||
}), | ||
onInputChecked: jest.fn((validInput) => {}), | ||
validationErrorText: "", | ||
clearIconText: "", | ||
onFocusChange: jest.fn(hasFocus => { | ||
}), | ||
id: "test-auto-suggestion" | ||
} | ||
}) | ||
onFocusChange: jest.fn((hasFocus) => {}), | ||
id: "test-auto-suggestion", | ||
}; | ||
}); | ||
|
||
it("should render properly", () => { | ||
const {container} = render(<AutoSuggestion {...props} />) | ||
expect(container).not.toBeEmptyDOMElement() | ||
}) | ||
const { container } = render(<AutoSuggestion {...props} />); | ||
expect(container).not.toBeEmptyDOMElement(); | ||
}); | ||
|
||
it("should set label prop properly", () => { | ||
const {getByText} = render(<AutoSuggestion {...props}/>) | ||
expect(getByText(props.label!!)).toBeTruthy() | ||
}) | ||
}) | ||
const { getByText } = render(<AutoSuggestion {...props} />); | ||
expect(getByText(props.label!!)).toBeTruthy(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.