Skip to content

Commit

Permalink
add basic styling test for addressbook & coin selection modal usage
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Jun 23, 2023
1 parent f187584 commit 7c7f37c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function MyModal({
transparent
animationType={animation}
onRequestClose={close}
testID='testCoinSelectionModal'
>
<KeyboardAvoidingView
style={getCorrectStyle()}
Expand Down
13 changes: 13 additions & 0 deletions test/components/AddressBook.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import AddressBook from '@comps/screens/Addressbook/Book'
import AddressbookModal from '@comps/screens/Addressbook/modal'
import { l } from '@src/logger'
import { act, fireEvent, render, screen } from '@testing-library/react-native'

jest.useFakeTimers()
Expand Down Expand Up @@ -40,6 +43,16 @@ describe('Test the Addressbook page', () => {
fireEvent.press(screen.getByTestId('addPersonal'))
expect(screen.queryByPlaceholderText('Name')).toBeNull()
})
it('Addressbook modal has a specific style applied', () => {
render(
<AddressbookModal
closeModal={() => l('test')}
setInput={() => l('test')}
/>
)
const modal = screen.getByTestId('testCoinSelectionModal')
expect(modal.props.children.props.children.props.style[0].paddingHorizontal).toBe(0)
})
// TODO test the functionality of adding a new contact and rendering it
// eslint-disable-next-line jest/no-commented-out-tests
// it('Render the new contact', async () => {
Expand Down
20 changes: 20 additions & 0 deletions test/components/CoinSelectionModal.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { CoinSelectionModal } from '@screens/Lightning/modal'
import { l } from '@src/logger'
import { render, screen } from '@testing-library/react-native'

describe('Basic styling test of the CoinSelectionModal component', () => {
it('has a specific style applied', () => {
render(
<CoinSelectionModal
lnAmount={1}
disableCS={() => l('test coin selection modal')}
proofs={[]}
setProof={() => l('proofs')}
/>
)
const modal = screen.getByTestId('testCoinSelectionModal')
expect(modal.props.children.props.children.props.style[0].paddingHorizontal).toBe(0)
})
})

0 comments on commit 7c7f37c

Please sign in to comment.