-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds E2E tests for single responsive prop
- Loading branch information
1 parent
31317d8
commit 43373e6
Showing
4 changed files
with
98 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
packages/atomic-layout/examples/regression/SingleResponsiveProp.jsx
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,25 @@ | ||
import React from 'react' | ||
import { Composition } from 'atomic-layout' | ||
import Square from '@stories/Square' | ||
|
||
const SingleResponsiveProp = () => ( | ||
<Composition | ||
id="composition" | ||
areasMd="left right" | ||
paddingMdDown={15} | ||
gutterLgOnly={10} | ||
> | ||
{(Areas) => ( | ||
<> | ||
<Areas.Left data-area="left"> | ||
<Square>Left</Square> | ||
</Areas.Left> | ||
<Areas.Right data-area="right"> | ||
<Square>Right</Square> | ||
</Areas.Right> | ||
</> | ||
)} | ||
</Composition> | ||
) | ||
|
||
export default SingleResponsiveProp |
68 changes: 68 additions & 0 deletions
68
packages/atomic-layout/examples/regression/SingleResponsiveProp.test.js
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,68 @@ | ||
describe('Single responsive prop', () => { | ||
before(() => { | ||
cy.loadStory(['regression', 'all'], ['single-responsive-prop']) | ||
}) | ||
|
||
describe('Given "up" behavior', () => { | ||
it('Renders no areas on unmatched breakpoints', () => { | ||
const shouldRenderNothing = () => { | ||
cy.get('[data-area="left"]').should('not.be.visible') | ||
cy.get('[data-area="right"]').should('not.be.visible') | ||
} | ||
|
||
cy.setBreakpoint('xs').then(shouldRenderNothing) | ||
cy.setBreakpoint('sm').then(shouldRenderNothing) | ||
}) | ||
|
||
it('Renders areas on matched breakpoint and up', () => { | ||
const shouldRenderAreas = () => { | ||
cy.get('#composition').assertAreas([['left', 'right']]) | ||
} | ||
|
||
cy.setBreakpoint('md').then(shouldRenderAreas) | ||
cy.setBreakpoint('lg').then(shouldRenderAreas) | ||
cy.setBreakpoint('xl').then(shouldRenderAreas) | ||
}) | ||
}) | ||
|
||
describe('Given "down" behavior', () => { | ||
it('Has no padding on unmatched breakpoints', () => { | ||
const shouldHaveNoPadding = () => { | ||
cy.get('#composition').should('have.css', 'padding', '0px') | ||
} | ||
|
||
cy.setBreakpoint('lg').then(shouldHaveNoPadding) | ||
cy.setBreakpoint('xl').then(shouldHaveNoPadding) | ||
}) | ||
|
||
it('Has padding on matched breakpoints', () => { | ||
const shouldHavePadding = () => { | ||
cy.get('#composition').should('have.css', 'padding', '15px') | ||
} | ||
|
||
cy.setBreakpoint('xs').then(shouldHavePadding) | ||
cy.setBreakpoint('sm').then(shouldHavePadding) | ||
cy.setBreakpoint('md').then(shouldHavePadding) | ||
}) | ||
}) | ||
|
||
describe('Given "only" behavior', () => { | ||
it('Has no gap on unmatched breakpoints', () => { | ||
const shouldHaveNoGap = () => { | ||
cy.get('#composition').should('have.css', 'grid-gap', 'normal normal') | ||
} | ||
|
||
cy.setBreakpoint('xs').then(shouldHaveNoGap) | ||
cy.setBreakpoint('sm').then(shouldHaveNoGap) | ||
cy.setBreakpoint('md').then(shouldHaveNoGap) | ||
}) | ||
|
||
it('Has a gap on a matched breakpoint', () => { | ||
const shouldHaveGap = () => { | ||
cy.get('#composition').should('have.css', 'grid-gap', '10px 10px') | ||
} | ||
|
||
cy.setBreakpoint('lg').then(shouldHaveGap) | ||
}) | ||
}) | ||
}) |