1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-11-25 15:50:39 +03:00

Basic test setup

This commit is contained in:
Brent Jackson 2019-03-09 17:13:23 -05:00
parent 2af123ecab
commit 868c036f13
19 changed files with 680 additions and 1372 deletions

1
babel.config.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('./packages/mdx-deck/babel.config')

View File

@ -6,7 +6,23 @@
"docs"
],
"scripts": {
"start": "yarn workspace @mdx-deck/docs start"
"start": "yarn workspace @mdx-deck/docs start",
"test": "jest"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"husky": "^1.3.1",
"jest": "^24.3.1",
"lint-staged": "^8.1.5",
"prettier": "^1.16.4"
},
"jest": {
"coverageReporters": [
"lcov",
"html"
]
},
"husky": {
"hooks": {
@ -18,10 +34,5 @@
"prettier --write",
"git add"
]
},
"devDependencies": {
"husky": "^1.3.1",
"lint-staged": "^8.1.5",
"prettier": "^1.16.4"
}
}

View File

@ -0,0 +1,12 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import Appear from '../Appear'
test('Appear renders', () => {
const json = TestRenderer.create(
<Appear>
<h1>Hello</h1>
</Appear>
).toJSON()
expect(json).toMatchSnapshot()
})

View File

@ -0,0 +1,5 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import Clock from '../Clock'
test.todo('Clock renders')

View File

@ -0,0 +1,5 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import GoogleFonts from '../GoogleFonts'
test.todo('GoogleFonts renders')

View File

@ -0,0 +1,15 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import { Head, HeadProvider } from '../Head'
test.skip('Head populates HeadProviders tag prop', () => {
const tags = []
TestRenderer.create(
<HeadProvider tags={tags}>
<Head>
<title>Hello</title>
</Head>
</HeadProvider>
)
expect(tags.length).toBe(1)
})

View File

@ -0,0 +1,8 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import Pre from '../Pre'
test('Pre renders', () => {
const json = TestRenderer.create(<Pre children="hi" />).toJSON()
expect(json).toMatchSnapshot()
})

View File

@ -0,0 +1,8 @@
import React from 'react'
import TestRenderer from 'react-test-renderer'
import Steps from '../Steps'
test('Steps renders', () => {
const json = TestRenderer.create(<Steps render={() => 'hi'} />).toJSON()
expect(json).toMatchSnapshot()
})

View File

@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Appear renders 1`] = `
<h1
style={
Object {
"visibility": "hidden",
}
}
>
Hello
</h1>
`;

View File

@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Pre renders 1`] = `
<pre
style={
Object {
"fontFamily": "Menlo, monospace",
"fontSize": 18,
"whiteSpace": "pre-wrap",
}
}
>
hi
</pre>
`;

View File

@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Steps renders 1`] = `"hi"`;

View File

@ -1,6 +1,6 @@
import React, { useContext } from 'react'
export const Context = React.createContext(null)
export const Context = React.createContext({})
export const withContext = Component => props => (
<Context.Consumer

View File

@ -9,8 +9,7 @@
"scripts": {
"start": "./cli.js demo.mdx -p 8080",
"build": "./cli.js build demo.mdx -d public",
"help": "./cli.js",
"test": "jest"
"help": "./cli.js"
},
"keywords": [],
"author": "Brent Jackson",
@ -63,26 +62,12 @@
"devDependencies": {
"@mdx-deck/themes": "^2.0.0-0",
"@rebass/grid": "^6.0.0-7",
"babel-jest": "^24.1.0",
"husky": "^1.3.1",
"jest": "^24.1.0",
"lint-staged": "^8.1.5",
"mdx-deck-code-surfer": "^0.5.5",
"prettier": "^1.16.4",
"react-test-renderer": "^16.8.3"
},
"jest": {
"roots": [
"<rootDir>/test/"
],
"testMatch": [
"**/test/**/*.js"
],
"testURL": "http://localhost/",
"coverageReporters": [
"html"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"

View File

@ -0,0 +1,60 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`adds an export 1`] = `
"/* @jsx mdx */
export const slides = [(props => {
const Layout = props =>
<section>
{props.children}
</section>
return <Layout
name=\\"wrapper\\"
components={props.components}>
<h1 data-name=\\"h1\\">{\`Hello\`}</h1>
</Layout>
}),
(props => {
const Layout = \\"div\\"
return <Layout
name=\\"wrapper\\"
components={props.components}>
<h2 data-name=\\"h2\\">{\`Two\`}</h2>
</Layout>
}),
(props => {
const Layout = \\"div\\"
return <Layout
name=\\"wrapper\\"
components={props.components}>
<h2 data-name=\\"h2\\">{\`Three\`}</h2>
</Layout>
})]
const layoutProps = {
slides
};
const MDXLayout = props =>
<section>
{props.children}
</section>
export default function MDXContent({ components, ...props }) {
return (
<div
name=\\"wrapper\\"
components={components}>
<MDXLayout {...layoutProps} {...props}>
<h1 >{\`Hello\`}</h1>
<hr ></hr>
<h2 >{\`Two\`}</h2>
<hr ></hr>
<h2 >{\`Three\`}</h2>
</MDXLayout>
</div>
)
}
MDXContent.isMDXComponent = true"
`;

View File

@ -3,16 +3,11 @@
"version": "2.0.0-0",
"description": "",
"main": "index.js",
"scripts": {
"test": "nyc ava"
},
"keywords": [],
"author": "Brent Jackson <jxnblk@gmail.com>",
"license": "MIT",
"devDependencies": {
"@mdx-js/mdx": "^1.0.0-alpha.5",
"ava": "^1.2.1",
"nyc": "^13.3.0"
"@mdx-js/mdx": "^1.0.0-alpha.5"
},
"dependencies": {
"unist-util-is": "^2.1.2",

View File

@ -1,4 +1,3 @@
import test from 'ava'
import mdx from '@mdx-js/mdx'
import plugin from '.'
@ -15,10 +14,10 @@ export default props =>
## Three
`
test('adds an export', t => {
test('adds an export', () => {
const code = mdx.sync(src, {
mdPlugins: [plugin],
})
t.is(typeof code, 'string')
t.snapshot(code)
expect(typeof code).toBe('string')
expect(code).toMatchSnapshot()
})

View File

@ -1,66 +0,0 @@
# Snapshot report for `test.js`
The actual snapshot is saved in `test.js.snap`.
Generated by [AVA](https://ava.li).
## adds an export
> Snapshot 1
`␊
export const slides = [(props => (␊
<MDXTag
name="wrapper"␊
Layout={props =>␊
<section>
{props.children}␊
</section>}␊
components={props.components}>␊
<MDXTag name="h1" components={props.components}>Hello</MDXTag>
</MDXTag>
)),␊
(props => (␊
<MDXTag
name="wrapper"␊
components={props.components}>␊
<MDXTag name="h2" components={props.components}>Two</MDXTag>
</MDXTag>
)),␊
(props => (␊
<MDXTag
name="wrapper"␊
components={props.components}>␊
<MDXTag name="h2" components={props.components}>Three</MDXTag>
</MDXTag>
))]␊
const layoutProps = {␊
slides␊
};␊
export default class MDXContent extends React.Component {␊
constructor(props) {␊
super(props)␊
this.layout = props =>␊
<section>
{props.children}␊
</section>
}␊
render() {␊
const { components, ...props } = this.props␊
return <MDXTag
name="wrapper"␊
Layout={this.layout} layoutProps={Object.assign({}, layoutProps, props)}␊
components={components}>␊
<MDXTag name="h1" components={components}>{`Hello`}</MDXTag>
<MDXTag name="hr" components={components}></MDXTag>
<MDXTag name="h2" components={components}>{`Two`}</MDXTag>
<MDXTag name="hr" components={components}></MDXTag>
<MDXTag name="h2" components={components}>{`Three`}</MDXTag>
</MDXTag>
}␊
}␊
MDXContent.isMDXComponent = true`

Binary file not shown.

1785
yarn.lock

File diff suppressed because it is too large Load Diff