-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
19ac63b
commit 03d4f48
Showing
4 changed files
with
102 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'regenerator-runtime/runtime'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import LeadingActions from '../LeadingActions'; | ||
import SwipeAction from '../SwipeAction'; | ||
import SwipeableListItem from '../SwipeableListItem'; | ||
|
||
describe('LeadingActions', () => { | ||
test('should render the action', () => { | ||
render( | ||
<SwipeableListItem | ||
leadingActions={ | ||
<LeadingActions> | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
</LeadingActions> | ||
} | ||
/> | ||
); | ||
|
||
expect(screen.getByText('Left swipe content')).toBeInTheDocument(); | ||
}); | ||
|
||
test.each([0, 1, 2])('should render %i number of items', itemsCount => { | ||
render( | ||
<SwipeableListItem | ||
leadingActions={ | ||
<LeadingActions> | ||
{itemsCount >= 1 && ( | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
)} | ||
{itemsCount === 2 && ( | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
)} | ||
</LeadingActions> | ||
} | ||
/> | ||
); | ||
|
||
expect(screen.queryAllByText('Left swipe content')).toHaveLength( | ||
itemsCount | ||
); | ||
}); | ||
}); |
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,50 @@ | ||
import 'regenerator-runtime/runtime'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import TrailingActions from '../TrailingActions'; | ||
import SwipeAction from '../SwipeAction'; | ||
import SwipeableListItem from '../SwipeableListItem'; | ||
|
||
describe('TrailingActions', () => { | ||
test('should render the action', () => { | ||
render( | ||
<SwipeableListItem | ||
trailingActions={ | ||
<TrailingActions> | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
</TrailingActions> | ||
} | ||
/> | ||
); | ||
|
||
expect(screen.getByText('Left swipe content')).toBeInTheDocument(); | ||
}); | ||
|
||
test.each([0, 1, 2])('should render %i number of items', itemsCount => { | ||
render( | ||
<SwipeableListItem | ||
trailingActions={ | ||
<TrailingActions> | ||
{itemsCount >= 1 && ( | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
)} | ||
{itemsCount === 2 && ( | ||
<SwipeAction onClick={jest.fn()}> | ||
<span>Left swipe content</span> | ||
</SwipeAction> | ||
)} | ||
</TrailingActions> | ||
} | ||
/> | ||
); | ||
|
||
expect(screen.queryAllByText('Left swipe content')).toHaveLength( | ||
itemsCount | ||
); | ||
}); | ||
}); |