-
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.
- Loading branch information
1 parent
d987d65
commit a629769
Showing
43 changed files
with
539 additions
and
295 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
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
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
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
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: 57 additions & 0 deletions
57
...ise-src/react-native/17-offline-support/01-problem/src/screens/Settings/Settings.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { NavigationContainer } from "@react-navigation/native" | ||
import { fireEvent, render, screen } from "@testing-library/react-native" | ||
|
||
import AuthProvider from "../../services/auth/AuthProvider" | ||
|
||
import Settings from "./Settings" | ||
|
||
const mockSetMode = jest.fn() | ||
|
||
jest.mock("../../design/theme", () => ({ | ||
...jest.requireActual("../../design/theme"), | ||
useThemeMode: () => ({ | ||
mode: "light", | ||
setMode: mockSetMode, | ||
}), | ||
})) | ||
|
||
describe("Screens/Settings", () => { | ||
it("renders", async () => { | ||
render( | ||
<AuthProvider> | ||
<NavigationContainer> | ||
<Settings /> | ||
</NavigationContainer> | ||
</AuthProvider>, | ||
) | ||
expect(screen.getByText(/Loading…/i)).not.toBeNull() | ||
}) | ||
|
||
it("switches to dark mode", () => { | ||
render( | ||
<AuthProvider> | ||
<NavigationContainer> | ||
<Settings /> | ||
</NavigationContainer> | ||
</AuthProvider>, | ||
) | ||
|
||
const switchElement = screen.getByRole("switch") | ||
expect(switchElement.props.value).toBe(false) | ||
|
||
fireEvent(switchElement, "onValueChange", true) | ||
expect(mockSetMode).toHaveBeenCalledWith("dark") | ||
}) | ||
|
||
it("displays the correct connection status", () => { | ||
render( | ||
<AuthProvider> | ||
<NavigationContainer> | ||
<Settings /> | ||
</NavigationContainer> | ||
</AuthProvider>, | ||
) | ||
|
||
expect(screen.getByText(/Connection status: Online/i)).not.toBeNull() | ||
}) | ||
}) |
Oops, something went wrong.