Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/picker/Picker.driver.new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ export const PickerDriver = (props: ComponentProps, useDialog: boolean) => {
}
};

const itemDriver = (testID: string) => ButtonDriver({renderTree: props.renderTree, testID});

const selectItem = (testID: string): void => {
const itemDriver = ButtonDriver({renderTree: props.renderTree, testID});
itemDriver.press();
const driver = itemDriver(testID);
driver.press();
};

return {
Expand All @@ -78,6 +80,7 @@ export const PickerDriver = (props: ComponentProps, useDialog: boolean) => {
done,
isOpen,
dismissDialog,
itemDriver,
selectItem
};
};
52 changes: 52 additions & 0 deletions src/components/picker/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,58 @@ describe('Picker', () => {
jest.clearAllMocks();
});

describe('Items', () => {
const testItems = [{key: 'one', value: 1, label: 'One', testID: 'item_one'}, {key: 'two', value: 2, label: 'Two', testID: 'item_two'}];
const testItemExists = (TestCase: () => React.JSX.Element) => {
const renderTree = render(<TestCase/>);
const driver = PickerDriver({renderTree, testID}, false);
driver.open();
const item = driver.itemDriver(testItems[0].testID);
expect(item.exists()).toBeTruthy();
};

it('should render picker items when passing children', () => {
const TestCase = () => {
return (
<Picker testID={testID}>
<Picker.Item {...testItems[0]}/>
<Picker.Item {...testItems[1]}/>
</Picker>
);
};
testItemExists(TestCase);
});

it('should render picker items when passing items', () => {
const TestCase = () => {
return (
<Picker testID={testID} items={testItems}/>
);
};
testItemExists(TestCase);
});

it('should render picker items with one option when passing one child', () => {
const TestCase = () => {
return (
<Picker testID={testID}>
<Picker.Item {...testItems[0]}/>
</Picker>
);
};
testItemExists(TestCase);
});

it('should render picker with one option when passing one item', () => {
const TestCase = () => {
return (
<Picker testID={testID} items={[testItems[0]]}/>
);
};
testItemExists(TestCase);
});
});

describe('Modal', () => {
describe('Test open', () => {
it('Should open when enabled', () => {
Expand Down