-
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
1 parent
1836197
commit 364e91a
Showing
11 changed files
with
505 additions
and
102 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
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
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
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
import { createContext } from "react"; | ||
import facepaint from "facepaint"; | ||
|
||
const mqContext = createContext(facepaint(["@media(min-width: 420px)", "@media(min-width: 920px)", "@media(min-width: 1120px)"])); | ||
|
||
export default mqContext; |
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 |
---|---|---|
@@ -1,83 +1,84 @@ | ||
import test from "ava"; | ||
import React from "react"; | ||
import * as render from "react-test-renderer"; | ||
import { shallow } from "enzyme"; | ||
import * as sinon from "sinon"; | ||
import Box from "../src/box"; | ||
import * as styles from "../src/styles"; | ||
import { propNames } from "../src/enhancers"; | ||
import test from 'ava' | ||
import React from 'react' | ||
import * as render from 'react-test-renderer' | ||
import {shallow} from 'enzyme' | ||
import * as sinon from 'sinon' | ||
import Box from '../src/box' | ||
import * as styles from '../src/styles' | ||
import allPropertiesComponent from '../tools/all-properties-component' | ||
import {propNames} from '../src/enhancers' | ||
|
||
test.afterEach.always(() => { | ||
styles.clear(); | ||
}); | ||
styles.clear() | ||
}) | ||
|
||
// test.serial('all properties', t => { | ||
// const component = allPropertiesComponent() | ||
// const tree = render.create(component).toJSON() | ||
// t.snapshot(tree, 'DOM') | ||
// t.snapshot(styles.getAll(), 'CSS') | ||
// }) | ||
test.serial('all properties', t => { | ||
const component = allPropertiesComponent() | ||
const tree = render.create(component).toJSON() | ||
t.snapshot(tree, 'DOM') | ||
t.snapshot(styles.getAll(), 'CSS') | ||
}) | ||
|
||
test.serial("all properties set to inherit", t => { | ||
const properties: any = {}; | ||
test.serial('all properties set to inherit', t => { | ||
const properties: any = {} | ||
for (const name of propNames) { | ||
properties[name] = "inherit"; | ||
properties[name] = 'inherit' | ||
} | ||
|
||
delete properties.clearfix; // Non-css property | ||
const component = <Box {...properties} />; | ||
shallow(component); | ||
t.snapshot(styles.getAll(), "CSS"); | ||
}); | ||
delete properties.clearfix // Non-css property | ||
const component = <Box {...properties} /> | ||
shallow(component) | ||
t.snapshot(styles.getAll(), 'CSS') | ||
}) | ||
|
||
test.serial("all properties set to initial", t => { | ||
const properties: any = {}; | ||
test.serial('all properties set to initial', t => { | ||
const properties: any = {} | ||
for (const name of propNames) { | ||
properties[name] = "initial"; | ||
properties[name] = 'initial' | ||
} | ||
|
||
delete properties.clearfix; // Non-css property | ||
const component = <Box {...properties} />; | ||
shallow(component); | ||
t.snapshot(styles.getAll(), "CSS"); | ||
}); | ||
delete properties.clearfix // Non-css property | ||
const component = <Box {...properties} /> | ||
shallow(component) | ||
t.snapshot(styles.getAll(), 'CSS') | ||
}) | ||
|
||
test("is prop allows changing the dom element type", t => { | ||
const component = shallow(<Box is="h1" />); | ||
t.true(component.is("h1")); | ||
}); | ||
test('is prop allows changing the dom element type', t => { | ||
const component = shallow(<Box is="h1" />) | ||
t.true(component.is('h1')) | ||
}) | ||
|
||
test("is prop allows changing the component type", t => { | ||
test('is prop allows changing the component type', t => { | ||
function TestComponent(props) { | ||
return <h1 {...props} />; | ||
return <h1 {...props} /> | ||
} | ||
|
||
const component = shallow(<Box is={TestComponent} />); | ||
t.true(component.is(TestComponent)); | ||
}); | ||
const component = shallow(<Box is={TestComponent} />) | ||
t.true(component.is(TestComponent)) | ||
}) | ||
|
||
test("innerRef prop gets passed the ref", t => { | ||
const node = { domNode: true }; | ||
const innerRef = sinon.spy(); | ||
test('innerRef prop gets passed the ref', t => { | ||
const node = {domNode: true} | ||
const innerRef = sinon.spy() | ||
render.create(<Box innerRef={innerRef} />, { | ||
createNodeMock() { | ||
return node; | ||
return node | ||
} | ||
}); | ||
t.true(innerRef.calledOnce); | ||
t.is(innerRef.args[0][0], node); | ||
}); | ||
}) | ||
t.true(innerRef.calledOnce) | ||
t.is(innerRef.args[0][0], node) | ||
}) | ||
|
||
test("renders children", t => { | ||
test('renders children', t => { | ||
const component = shallow( | ||
<Box> | ||
<h1>Hi</h1> | ||
</Box> | ||
); | ||
t.true(component.contains(<h1>Hi</h1>)); | ||
}); | ||
) | ||
t.true(component.contains(<h1>Hi</h1>)) | ||
}) | ||
|
||
test("maintains the original className", t => { | ||
const component = shallow(<Box className="derp" margin="10px" />); | ||
t.true(component.hasClass("derp")); | ||
}); | ||
test('maintains the original className', t => { | ||
const component = shallow(<Box className="derp" margin="10px" />) | ||
t.true(component.hasClass('derp')) | ||
}) |
Oops, something went wrong.