mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-11-26 00:35:02 +03:00
Basic test setup
This commit is contained in:
parent
2af123ecab
commit
868c036f13
1
babel.config.js
Normal file
1
babel.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require('./packages/mdx-deck/babel.config')
|
23
package.json
23
package.json
@ -6,7 +6,23 @@
|
|||||||
"docs"
|
"docs"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"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": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
@ -18,10 +34,5 @@
|
|||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"husky": "^1.3.1",
|
|
||||||
"lint-staged": "^8.1.5",
|
|
||||||
"prettier": "^1.16.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
packages/components/src/__tests__/Appear.js
Normal file
12
packages/components/src/__tests__/Appear.js
Normal 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()
|
||||||
|
})
|
5
packages/components/src/__tests__/Clock.js
Normal file
5
packages/components/src/__tests__/Clock.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import TestRenderer from 'react-test-renderer'
|
||||||
|
import Clock from '../Clock'
|
||||||
|
|
||||||
|
test.todo('Clock renders')
|
5
packages/components/src/__tests__/GoogleFonts.js
Normal file
5
packages/components/src/__tests__/GoogleFonts.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import TestRenderer from 'react-test-renderer'
|
||||||
|
import GoogleFonts from '../GoogleFonts'
|
||||||
|
|
||||||
|
test.todo('GoogleFonts renders')
|
15
packages/components/src/__tests__/Head.js
Normal file
15
packages/components/src/__tests__/Head.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import TestRenderer from 'react-test-renderer'
|
||||||
|
import { Head, HeadProvider } from '../Head'
|
||||||
|
|
||||||
|
test.skip('Head populates HeadProvider‘s tag prop', () => {
|
||||||
|
const tags = []
|
||||||
|
TestRenderer.create(
|
||||||
|
<HeadProvider tags={tags}>
|
||||||
|
<Head>
|
||||||
|
<title>Hello</title>
|
||||||
|
</Head>
|
||||||
|
</HeadProvider>
|
||||||
|
)
|
||||||
|
expect(tags.length).toBe(1)
|
||||||
|
})
|
8
packages/components/src/__tests__/Pre.js
Normal file
8
packages/components/src/__tests__/Pre.js
Normal 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()
|
||||||
|
})
|
8
packages/components/src/__tests__/Steps.js
Normal file
8
packages/components/src/__tests__/Steps.js
Normal 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()
|
||||||
|
})
|
@ -0,0 +1,13 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Appear renders 1`] = `
|
||||||
|
<h1
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"visibility": "hidden",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Hello
|
||||||
|
</h1>
|
||||||
|
`;
|
15
packages/components/src/__tests__/__snapshots__/Pre.js.snap
Normal file
15
packages/components/src/__tests__/__snapshots__/Pre.js.snap
Normal 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>
|
||||||
|
`;
|
@ -0,0 +1,3 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Steps renders 1`] = `"hi"`;
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
|
|
||||||
export const Context = React.createContext(null)
|
export const Context = React.createContext({})
|
||||||
|
|
||||||
export const withContext = Component => props => (
|
export const withContext = Component => props => (
|
||||||
<Context.Consumer
|
<Context.Consumer
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "./cli.js demo.mdx -p 8080",
|
"start": "./cli.js demo.mdx -p 8080",
|
||||||
"build": "./cli.js build demo.mdx -d public",
|
"build": "./cli.js build demo.mdx -d public",
|
||||||
"help": "./cli.js",
|
"help": "./cli.js"
|
||||||
"test": "jest"
|
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Brent Jackson",
|
"author": "Brent Jackson",
|
||||||
@ -63,26 +62,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mdx-deck/themes": "^2.0.0-0",
|
"@mdx-deck/themes": "^2.0.0-0",
|
||||||
"@rebass/grid": "^6.0.0-7",
|
"@rebass/grid": "^6.0.0-7",
|
||||||
"babel-jest": "^24.1.0",
|
|
||||||
"husky": "^1.3.1",
|
"husky": "^1.3.1",
|
||||||
"jest": "^24.1.0",
|
|
||||||
"lint-staged": "^8.1.5",
|
"lint-staged": "^8.1.5",
|
||||||
"mdx-deck-code-surfer": "^0.5.5",
|
"mdx-deck-code-surfer": "^0.5.5",
|
||||||
"prettier": "^1.16.4",
|
"prettier": "^1.16.4",
|
||||||
"react-test-renderer": "^16.8.3"
|
"react-test-renderer": "^16.8.3"
|
||||||
},
|
},
|
||||||
"jest": {
|
|
||||||
"roots": [
|
|
||||||
"<rootDir>/test/"
|
|
||||||
],
|
|
||||||
"testMatch": [
|
|
||||||
"**/test/**/*.js"
|
|
||||||
],
|
|
||||||
"testURL": "http://localhost/",
|
|
||||||
"coverageReporters": [
|
|
||||||
"html"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lint-staged"
|
"pre-commit": "lint-staged"
|
||||||
|
60
packages/mdx-plugin/__snapshots__/test.js.snap
Normal file
60
packages/mdx-plugin/__snapshots__/test.js.snap
Normal 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"
|
||||||
|
`;
|
@ -3,16 +3,11 @@
|
|||||||
"version": "2.0.0-0",
|
"version": "2.0.0-0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
|
||||||
"test": "nyc ava"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Brent Jackson <jxnblk@gmail.com>",
|
"author": "Brent Jackson <jxnblk@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mdx-js/mdx": "^1.0.0-alpha.5",
|
"@mdx-js/mdx": "^1.0.0-alpha.5"
|
||||||
"ava": "^1.2.1",
|
|
||||||
"nyc": "^13.3.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"unist-util-is": "^2.1.2",
|
"unist-util-is": "^2.1.2",
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import test from 'ava'
|
|
||||||
import mdx from '@mdx-js/mdx'
|
import mdx from '@mdx-js/mdx'
|
||||||
import plugin from '.'
|
import plugin from '.'
|
||||||
|
|
||||||
@ -15,10 +14,10 @@ export default props =>
|
|||||||
## Three
|
## Three
|
||||||
`
|
`
|
||||||
|
|
||||||
test('adds an export', t => {
|
test('adds an export', () => {
|
||||||
const code = mdx.sync(src, {
|
const code = mdx.sync(src, {
|
||||||
mdPlugins: [plugin],
|
mdPlugins: [plugin],
|
||||||
})
|
})
|
||||||
t.is(typeof code, 'string')
|
expect(typeof code).toBe('string')
|
||||||
t.snapshot(code)
|
expect(code).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
@ -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.
Loading…
Reference in New Issue
Block a user