-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. MainFAB animation 2. Implemented basic test that tests the callback
- Loading branch information
1 parent
fcc5831
commit 7c1b410
Showing
2 changed files
with
85 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {FAB, FABItem, FABProps} from '../../main'; | ||
import {fireEvent, render, waitFor} from '@testing-library/react-native'; | ||
|
||
import {ReactElement} from 'react'; | ||
import {createComponent} from '../../test/testUtils'; | ||
|
||
const Component = (props: FABProps<FABItem>): ReactElement => | ||
createComponent(<FAB {...props} />); | ||
|
||
describe('[FAB]', () => { | ||
it('should render without crashing', () => { | ||
const testingLib = render( | ||
Component({ | ||
FABList: [{icon: 'bell-solid', id: 'item1'}], | ||
size: 'large', | ||
onPressFABItem: () => {}, | ||
}), | ||
); | ||
|
||
const json = testingLib.toJSON(); | ||
|
||
expect(json).toBeTruthy(); | ||
}); | ||
|
||
it('test mainFAB onPress callback', async () => { | ||
let count = 0; | ||
let item1: FABItem = {icon: 'bell-solid', id: 'item1'}; | ||
let resItem: FABItem; | ||
|
||
const testingLib = render( | ||
Component({ | ||
FABList: [item1], | ||
size: 'large', | ||
onPressFABItem: (item1) => { | ||
count += 1; | ||
resItem = item1; | ||
}, | ||
}), | ||
); | ||
|
||
expect(count).toEqual(0); | ||
fireEvent.press(testingLib.getByTestId('item1')); | ||
expect(count).toEqual(1); | ||
expect(resItem.id).toEqual(item1.id); | ||
}); | ||
}); |