forked from gusgard/react-native-swiper-flatlist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more code examples and tests for Detox (gusgard#98)
* Update Readme and add more examples for tests * rename variables
- Loading branch information
Showing
8 changed files
with
250 additions
and
110 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 |
---|---|---|
|
@@ -15,4 +15,4 @@ For an Android device `yarn android` | |
For an iOS device `yarn ios` | ||
|
||
|
||
"react-native-swiper-flatlist": "git+ssh://[email protected]:gusgard/react-native-swiper-flatlist.git#2035e86de1b68ff9ae51d19437501c558ff5421d" | ||
<!-- "react-native-swiper-flatlist": "git+ssh://[email protected]:gusgard/react-native-swiper-flatlist.git#2035e86de1b68ff9ae51d19437501c558ff5421d" --> |
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,84 @@ | ||
const { device, expect, element, by } = require('detox'); | ||
|
||
// const TEXT_IN_SCREENS = { | ||
// zero: 'Item at index 0', | ||
// one: 'Item at index 1', | ||
// two: 'Item at index 2', | ||
// three: 'Item at index 3', | ||
// fourth: 'Item at index 4', | ||
// }; | ||
const SCREENS = { | ||
zero: 'container_swiper_renderItem_screen_0', | ||
one: 'container_swiper_renderItem_screen_1', | ||
two: 'container_swiper_renderItem_screen_2', | ||
three: 'container_swiper_renderItem_screen_3', | ||
fourth: 'container_swiper_renderItem_screen_4', | ||
}; | ||
// const PAGINATION = { | ||
// zero: 'container_swiper_renderItem_pagination_0', | ||
// one: 'container_swiper_renderItem_pagination_1', | ||
// two: 'container_swiper_renderItem_pagination_2', | ||
// three: 'container_swiper_renderItem_pagination_3', | ||
// fourth: 'container_swiper_renderItem_pagination_4', | ||
// }; | ||
|
||
const DELAY = 2 * 1000; | ||
|
||
describe('example with renderItems and data', () => { | ||
beforeEach(async () => { | ||
await device.reloadReactNative(); | ||
// TODO: add menu with steps! | ||
// await element(by.id('renderItem')).tap(); | ||
}); | ||
|
||
it('should see screen', async () => { | ||
await expect(element(by.id('container_swiper_renderItem'))).toBeVisible(); | ||
}); | ||
|
||
it('should execute autoplay every 2.0s', async () => { | ||
// 0s => screen with zero | ||
await expect(element(by.id(SCREENS.zero))).toBeVisible(); | ||
await expect(element(by.id(SCREENS.one))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.two))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.three))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.fourth))).toBeNotVisible(); | ||
|
||
// after 2s => screen with one | ||
await new Promise((_) => setTimeout(_, DELAY)); | ||
|
||
await expect(element(by.id(SCREENS.zero))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.one))).toBeVisible(); | ||
await expect(element(by.id(SCREENS.two))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.three))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.fourth))).toBeNotVisible(); | ||
|
||
// after 4s => screen with two | ||
await new Promise((_) => setTimeout(_, DELAY)); | ||
|
||
await expect(element(by.id(SCREENS.zero))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.one))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.two))).toBeVisible(); | ||
await expect(element(by.id(SCREENS.three))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.fourth))).toBeNotVisible(); | ||
|
||
// after 6s => screen with three | ||
await new Promise((_) => setTimeout(_, DELAY)); | ||
|
||
await expect(element(by.id(SCREENS.zero))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.one))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.two))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.three))).toBeVisible(); | ||
await expect(element(by.id(SCREENS.fourth))).toBeNotVisible(); | ||
|
||
// after 8s => screen with fourth | ||
await new Promise((_) => setTimeout(_, DELAY)); | ||
|
||
await expect(element(by.id(SCREENS.zero))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.one))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.two))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.three))).toBeNotVisible(); | ||
await expect(element(by.id(SCREENS.fourth))).toBeVisible(); | ||
}); | ||
|
||
// https://github.com/wix/Detox/blob/master/docs/APIRef.ActionsOnElement.md#swipedirection-speed-percentage | ||
}); |
Oops, something went wrong.