Skip to content

Commit

Permalink
Adds E2E tests for single responsive prop
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Jan 10, 2020
1 parent 31317d8 commit 43373e6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/atomic-layout/examples/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ describe('Recipes', () => {
*/
describe('Regression tests', () => {
require('./regression/StylesUndefined.test')
require('./regression/SingleResponsiveProp.test')
})
5 changes: 4 additions & 1 deletion packages/atomic-layout/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@ storiesOf('Recipes|All', module).add('Iterative areas', IterativeAreas)
* Bugfixes
*/
import StylesUndefined from './regression/StylesUndefined'
import SingleResponsiveProp from './regression/SingleResponsiveProp'

storiesOf('Regression|All', module).add('Styles undefined', StylesUndefined)
storiesOf('Regression|All', module)
.add('Styles undefined', StylesUndefined)
.add('Single responsive prop', SingleResponsiveProp)
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
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)
})
})
})

0 comments on commit 43373e6

Please sign in to comment.