From 15f5c44145827b2d0da652c24ff6169373ff9e97 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Wed, 17 Jul 2024 09:56:13 +0200 Subject: [PATCH] fix(wallet-mobile): Show correct theme name for auto (#3404) --- packages/theme/src/ThemeProvider.test.tsx | 35 ++++++++++++++++++----- packages/theme/src/ThemeProvider.tsx | 13 +++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/packages/theme/src/ThemeProvider.test.tsx b/packages/theme/src/ThemeProvider.test.tsx index d945dda224..50ea87c699 100644 --- a/packages/theme/src/ThemeProvider.test.tsx +++ b/packages/theme/src/ThemeProvider.test.tsx @@ -3,16 +3,21 @@ import {render, fireEvent} from '@testing-library/react-native' import {Button, Text} from 'react-native' import {ThemeProvider, useTheme, useThemeColor} from './ThemeProvider' -import {ThemeStorage} from './types' +import {SupportedThemes, ThemeStorage} from './types' import {ErrorBoundary} from '@yoroi/common' describe('ThemeProvider', () => { + let storedValue: SupportedThemes | undefined const mockStorage: ThemeStorage = { key: 'theme-name', - save: jest.fn(), - read: jest.fn(), + save: jest.fn().mockImplementation((v) => (storedValue = v)), + read: jest.fn().mockImplementation(() => storedValue), } + beforeEach(() => { + storedValue = undefined + }) + it('should render children', () => { const {getByText} = render( @@ -35,7 +40,7 @@ describe('ThemeProvider', () => { , ) - expect(getByText('default-light')).toBeTruthy() + expect(getByText('system')).toBeTruthy() }) it('should update the theme when selectThemeName is called', () => { @@ -47,7 +52,15 @@ describe('ThemeProvider', () => { {theme.name}