forked from JedWatson/react-select
-
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.
- Loading branch information
Showing
5 changed files
with
157 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import baseSelectors from '../fixtures/selectors.json'; | ||
|
||
const selector = { | ||
caseDefault: '[data-cy="case-default"]', | ||
caseExpandDown: '[data-cy="case-expand-down"]', | ||
scrollContainer: '[data-cy="scroll-container"]', | ||
}; | ||
// | ||
// const viewport = ['macbook-15', 'iphone-6']; | ||
|
||
Cypress.Screenshot.defaults({ | ||
screenshotOnRunFailure: false, | ||
}); | ||
|
||
describe('Menus', () => { | ||
before(function() { | ||
cy.visit('http://localhost:8000/cypress-menu-tests'); | ||
}); | ||
|
||
it('test page renders successfully', () => { | ||
cy.get('h1').should('contain', 'Test Page for React-Select Menus'); | ||
}); | ||
|
||
describe('Inside scroll containers', () => { | ||
describe('by default', () => { | ||
it('menu should be visible when select is clicked', () => { | ||
cy.get(selector.caseDefault) | ||
.find('.react-select__control') | ||
.click() | ||
.get(selector.caseDefault) | ||
.find(baseSelectors.menu) | ||
.should('be.visible'); | ||
}); | ||
}); | ||
|
||
describe('At bottom of container', () => { | ||
it('menu should be visible when select is clicked', () => { | ||
cy.get(selector.caseExpandDown) | ||
.find('.react-select__control') | ||
.click() | ||
.get(selector.caseExpandDown) | ||
.find(baseSelectors.menu) | ||
.should('be.visible'); | ||
}); | ||
|
||
it('scroll container should expland & scroll to bottom', () => { | ||
cy.get(selector.caseExpandDown) | ||
.find(selector.scrollContainer) | ||
.then(scrollContainer => { | ||
console.log(scrollContainer[0].scrollHeight); | ||
const originalHeight = scrollContainer[0].scrollHeight; | ||
cy.get(selector.caseExpandDown) | ||
.find('.react-select__control') | ||
.click() | ||
.then(() => { | ||
cy.get(selector.caseExpandDown) | ||
.find(selector.scrollContainer) | ||
.its('scrollHeight') | ||
.should('be.gt', originalHeight); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,51 @@ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
import Select from '../src'; | ||
import { stateOptions } from './data'; | ||
import { H1, H2, Note, ScrollContainer } from './styled-components'; | ||
|
||
const defaultSelectProps = { | ||
maxMenuHeight: 250, | ||
classNamePrefix: 'react-select', | ||
placeholder: 'Choose a state…', | ||
options: stateOptions, | ||
}; | ||
|
||
export default function TestsMenu() { | ||
return ( | ||
<div | ||
style={{ | ||
margin: 'auto', | ||
maxWidth: 440, | ||
padding: 20, | ||
}} | ||
> | ||
<H1>Test Page for React-Select Menus</H1> | ||
<H2>Inside scroll containers</H2> | ||
|
||
<div data-cy="case-default"> | ||
<h3>Default, plenty of height</h3> | ||
<ScrollContainer height={defaultSelectProps.maxMenuHeight + 100}> | ||
<Select {...defaultSelectProps} /> | ||
</ScrollContainer> | ||
<Note> | ||
Nothing special going on here, just the base case of opening a menu in | ||
a scroll container | ||
</Note> | ||
</div> | ||
|
||
<div data-cy="case-expand-down"> | ||
<h3>Expand and Scroll Down</h3> | ||
<ScrollContainer height={400}> | ||
<div style={{ height: 300 }} /> | ||
<Select {...defaultSelectProps} /> | ||
</ScrollContainer> | ||
<Note> | ||
If the menu doesn’t have enough room to open down, by default the | ||
container should expand down | ||
</Note> | ||
</div> | ||
</div> | ||
); | ||
} |
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