Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds integration test for compound responsive prop #142

Closed
wants to merge 2 commits into from
Closed
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
31 changes: 31 additions & 0 deletions cypress/integration/responsive-props/behavior-down.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
describe('Behavior: "down"', () => {
before(() => {
cy.loadStory(['core'], ['responsive-props', 'compound'])
})

it('with multiple "down" props', () => {
const assertPadding = (values) => {
return cy.get('#composition-down').should('have.css', 'padding', values)
}

assertPadding('10px')
cy.setBreakpoint('sm').then(() => assertPadding('20px'))
cy.setBreakpoint('md').then(() => assertPadding('30px'))
cy.setBreakpoint('lg').then(() => assertPadding('40px'))
cy.setBreakpoint('xl').then(() => assertPadding('50px'))
})

it('when combined with "up" sibling', () => {
const assertTemplateCols = (value) => {
return cy
.get('#composition-combination')
.should('have.css', 'grid-template-columns', value)
}

assertTemplateCols('200px')
cy.setBreakpoint('sm').then(() => assertTemplateCols('100px'))
cy.setBreakpoint('md').then(() => assertTemplateCols('200px'))
cy.setBreakpoint('lg').then(() => assertTemplateCols('200px'))
cy.setBreakpoint('xl').then(() => assertTemplateCols('200px'))
})
})
1 change: 1 addition & 0 deletions cypress/integration/responsive-props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ describe('Responsive props', () => {
require('./mobile-first.test')
require('./breakpoint-specific.test')
require('./inclusive-notch.test')
require('./behavior-down.test')
})
4 changes: 1 addition & 3 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ module.exports = (on, config) => {
)

const { envName } = config.env
const env = getCypressConfig(envName)
console.log({ env })
return env
return getCypressConfig(envName)
}
Binary file removed example.png
Binary file not shown.
5 changes: 1 addition & 4 deletions examples/Core/ResponsiveProps/BreakpointSpecific.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react'
import Layout, { Composition } from 'atomic-layout'
// import resetLayout from '../resetLayout'
import { Composition } from 'atomic-layout'
import Square from '@stories/Square'

// resetLayout(Layout)

const BreakpointSpecific = () => (
<Composition
id="composition"
Expand Down
32 changes: 32 additions & 0 deletions examples/Core/ResponsiveProps/Compound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import { Composition } from 'atomic-layout'
import Square from '@stories/Square'

const CompoundResponsiveProps = () => (
<>
{/* Multiple "down" behaviors */}
<Composition
id="composition-down"
padding={10}
paddingSmDown={20}
paddingMdDown={30}
paddingLgDown={40}
paddingXlDown={50}
>
<Square>First</Square>
</Composition>

{/* Combination of "up" and "down" */}
<Composition
id="composition-combination"
templateCols="200px"
templateColsSmDown="100px"
gutter={10}
>
<Square>First</Square>
<Square>Second</Square>
</Composition>
</>
)

export default CompoundResponsiveProps
5 changes: 1 addition & 4 deletions examples/Core/ResponsiveProps/InclusiveNotch.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react'
import Layout, { Composition } from 'atomic-layout'
// import resetLayout from '../resetLayout'
import { Composition } from 'atomic-layout'
import Square from '@stories/Square'

// resetLayout(Layout)

const template = 'first second'

const InclusiveNotch = () => (
Expand Down
5 changes: 1 addition & 4 deletions examples/Core/ResponsiveProps/MobileFirst.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react'
import Layout, { Composition } from 'atomic-layout'
// import resetLayout from '../resetLayout'
import { Composition } from 'atomic-layout'
import Square from '@stories/Square'

// resetLayout(Layout)

const Foo = () => (
<Composition id="composition" areas="first second" gutter={10}>
{({ First, Second }) => (
Expand Down
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ storiesOf('Core|Rendering', module)
import MobileFirstResponsiveProps from './Core/ResponsiveProps/MobileFirst'
import BreakpointSpecificResponsiveProps from './Core/ResponsiveProps/BreakpointSpecific'
import InclusiveNotchResponsiveProps from './Core/ResponsiveProps/InclusiveNotch'
import CompoundResponsiveProps from './Core/ResponsiveProps/Compound'

storiesOf('Core|Responsive props', module)
.add('Mobile-first', () => <MobileFirstResponsiveProps />)
.add('Breakpoint-specific', () => <BreakpointSpecificResponsiveProps />)
.add('Inclusive-notch', () => <InclusiveNotchResponsiveProps />)
.add('Compound', () => <CompoundResponsiveProps />)

/**
* Configuration
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "atomic-layout",
"version": "0.7.1",
"description": "A single component to distribute a spacial relation in your layouts using CSS Grid.",
"author": {
"name": "Artem Zakharchenko",
"email": "[email protected]"
},
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"scripts": {
Expand All @@ -23,7 +27,7 @@
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint ./src/",
"tslint ./src/",
"prettier --write",
"git add"
]
Expand All @@ -34,10 +38,6 @@
"maxSize": "20 kB"
}
],
"author": {
"name": "Artem Zakharchenko",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/kettanaito/atomic-layout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test('Notch', () => {
])
})

describe('Shuffled behavior', () => {
describe('Combined behavior', () => {
test('Concatenates sibling areas with "down" behavior', () => {
const breakpointSm = Layout.getBreakpoint('sm') || {}
const breakpointMd = Layout.getBreakpoint('md') || {}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/invariant/invariant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import invariant from './invariant'

const createConsoleSpy = () => jest.spyOn(console, 'error')

test('Should error when predicate is not satisfied', () => {
test('Errors upon not satisfied predicate', () => {
const consoleError = createConsoleSpy()
const errorMessage = 'Error message'

Expand All @@ -12,7 +12,7 @@ test('Should error when predicate is not satisfied', () => {
consoleError.mockRestore()
})

test('Should do nothing when predicate is satisfied', () => {
test('Does nothing upon satisfied predicate', () => {
const consoleError = createConsoleSpy()

invariant(true, 'You should not see this')
Expand Down
5 changes: 5 additions & 0 deletions src/utils/strings/capitalize/capitalize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ test('Capitalizes the given string', () => {
expect(capitalize('foo')).toBe('Foo')
expect(capitalize('fooSome')).toBe('FooSome')
})

test('Returns already capitalized string as-is', () => {
expect(capitalize('Foo')).toBe('Foo')
expect(capitalize('FooSome')).toBe('FooSome')
})
2 changes: 1 addition & 1 deletion src/utils/strings/getPrefix/getPrefix.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getPrefix from './getPrefix'

test('Returns the min/max prefix of the given string', () => {
test('Returns min/max prefix of the given string', () => {
expect(getPrefix('maxHeight')).toEqual('max')
expect(getPrefix('minResolution')).toEqual('min')
})
Expand Down
8 changes: 4 additions & 4 deletions src/utils/strings/hashString/hasString.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import hashString from './hashString'

test('Returns numeric hash based on the given string', () => {
const str = 'template:header,content,footer'
expect(hashString(str)).toEqual(1927731245)
expect(hashString(str)).toEqual(1927731245)
const templateString = 'template:header,content,footer'
expect(hashString(templateString)).toEqual(1927731245)
expect(hashString(templateString)).toEqual(1927731245)

expect(hashString('templateMd:header,content,footer')).toEqual(1323128868)
})

test('Returns zero for an empty string', () => {
test('Returns zero for empty string', () => {
expect(hashString('')).toEqual(0)
})
Loading