Skip to content

Commit 661afa5

Browse files
committed
typescript fix
1 parent 40e35f6 commit 661afa5

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

β€Žsrc/components/Auth.test.tsxβ€Ž

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@ describe('Auth Component πŸŽ‰', () => {
99
beforeEach(() => {
1010
originalLocation = window.location
1111
delete (window as any).location
12-
window.location = { ...originalLocation, reload: jest.fn() } as Location
12+
13+
Object.defineProperty(window, 'location', {
14+
value: {
15+
...originalLocation,
16+
reload: jest.fn(),
17+
assign: jest.fn(),
18+
replace: jest.fn(),
19+
toString: () => originalLocation.toString(),
20+
hostname: 'localhost', // for image path logic
21+
},
22+
writable: true,
23+
})
24+
1325
localStorage.clear()
1426
})
1527

1628
afterEach(() => {
17-
window.location = originalLocation // Restore the original location
29+
Object.defineProperty(window, 'location', {
30+
value: originalLocation,
31+
writable: true,
32+
})
1833
})
1934

2035
it('βœ… should be defined ✨', () => {
@@ -23,6 +38,7 @@ describe('Auth Component πŸŽ‰', () => {
2338

2439
it('🎨 renders the authentication form πŸ“', () => {
2540
render(<Auth />)
41+
2642
expect(screen.getByText('GitHub Authentication')).toBeInTheDocument()
2743
expect(
2844
screen.getByText(
@@ -37,6 +53,7 @@ describe('Auth Component πŸŽ‰', () => {
3753

3854
it('🎯 updates input fields on user input πŸ–ŠοΈ', () => {
3955
render(<Auth />)
56+
4057
const usernameInput = screen.getByLabelText('GitHub Username:')
4158
const tokenInput = screen.getByLabelText('GitHub Personal Access Token:')
4259

@@ -65,6 +82,7 @@ describe('Auth Component πŸŽ‰', () => {
6582

6683
it('πŸ”— contains a link to generate a GitHub token πŸ”‘', () => {
6784
render(<Auth />)
85+
6886
const link = screen.getByRole('link', {
6987
name: 'Click here to generate a New GitHub Personal Access Token',
7088
})

0 commit comments

Comments
Β (0)