mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-11-26 00:35:02 +03:00
Update tests
This commit is contained in:
parent
6761ff65c3
commit
3bb487f0c1
@ -12,7 +12,7 @@
|
||||
"build": "yarn workspace @mdx-deck/docs build",
|
||||
"start-theme": "yarn workspace @mdx-deck/gatsby-theme start",
|
||||
"build-theme": "yarn workspace @mdx-deck/gatsby-theme build",
|
||||
"test": "jest && yarn build-theme"
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.3.4",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"devDependencies": {
|
||||
"react": "^16.8.3",
|
||||
"react-dom": "^16.8.3",
|
||||
"react-test-renderer": "^16.8.4"
|
||||
"react-test-renderer": "^16.8.4",
|
||||
"react-testing-library": "^6.1.2"
|
||||
}
|
||||
}
|
||||
|
35
packages/components/src/__tests__/MDXDeck.js
Normal file
35
packages/components/src/__tests__/MDXDeck.js
Normal file
@ -0,0 +1,35 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { render, cleanup } from 'react-testing-library'
|
||||
import renderer from 'react-test-renderer'
|
||||
import { MDXDeckState, MDXDeckContext, MDXDeck } from '../MDXDeck'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
const slides = [() => <pre>one</pre>, () => <pre>two</pre>]
|
||||
|
||||
describe('MDXDeckState', () => {
|
||||
test('provides state', () => {
|
||||
let context
|
||||
const Consumer = props => {
|
||||
context = useContext(MDXDeckContext)
|
||||
return false
|
||||
}
|
||||
const deck = renderer.create(
|
||||
<MDXDeckState>
|
||||
<Consumer />
|
||||
</MDXDeckState>
|
||||
)
|
||||
expect(typeof context.state).toBe('object')
|
||||
expect(typeof context.state.metadata).toBe('object')
|
||||
expect(context.state.step).toBe(0)
|
||||
expect(context.state.mode).toBe('normal')
|
||||
expect(typeof context.setState).toBe('function')
|
||||
})
|
||||
|
||||
test.todo('setState updates state')
|
||||
})
|
||||
|
||||
test('renders', () => {
|
||||
const json = renderer.create(<MDXDeck slides={slides} />).toJSON()
|
||||
expect(json).toMatchSnapshot()
|
||||
})
|
@ -0,0 +1,33 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders 1`] = `
|
||||
<div>
|
||||
<div
|
||||
role="group"
|
||||
style={
|
||||
Object {
|
||||
"outline": "none",
|
||||
}
|
||||
}
|
||||
tabIndex="-1"
|
||||
>
|
||||
<div
|
||||
className="css-suf238-Root ekm8v3h0"
|
||||
>
|
||||
<div
|
||||
role="group"
|
||||
style={
|
||||
Object {
|
||||
"outline": "none",
|
||||
}
|
||||
}
|
||||
tabIndex="-1"
|
||||
>
|
||||
<pre>
|
||||
one
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
32
yarn.lock
32
yarn.lock
@ -747,7 +747,7 @@
|
||||
dependencies:
|
||||
regenerator-runtime "^0.12.0"
|
||||
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.2":
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.2":
|
||||
version "7.4.3"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.3.tgz#79888e452034223ad9609187a0ad1fe0d2ad4bdc"
|
||||
integrity sha512-9lsJwJLxDh/T3Q3SZszfWOTkk3pHbkmH+3KY+zwIDmsNlxsumuhS2TH3NIpktU4kNvfzy+k3eLT7aTJSPTo0OA==
|
||||
@ -1823,6 +1823,11 @@
|
||||
dependencies:
|
||||
any-observable "^0.3.0"
|
||||
|
||||
"@sheerun/mutationobserver-shim@^0.3.2":
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b"
|
||||
integrity sha512-vTCdPp/T/Q3oSqwHmZ5Kpa9oI7iLtGl3RQaA/NyLHikvcrPxACkkKVr/XzkSPJWXHRhKGzVvb0urJsbMlRxi1Q==
|
||||
|
||||
"@stefanprobst/lokijs@^1.5.6-b":
|
||||
version "1.5.6-b"
|
||||
resolved "https://registry.yarnpkg.com/@stefanprobst/lokijs/-/lokijs-1.5.6-b.tgz#6a36a86dbe132e702e6b15ffd3ce4139aebfe942"
|
||||
@ -5002,6 +5007,16 @@ dom-serializer@0, dom-serializer@~0.1.0:
|
||||
domelementtype "^1.3.0"
|
||||
entities "^1.1.1"
|
||||
|
||||
dom-testing-library@^3.19.0:
|
||||
version "3.19.3"
|
||||
resolved "https://registry.yarnpkg.com/dom-testing-library/-/dom-testing-library-3.19.3.tgz#fba399987be1bdd57b07c4bc3ef46c3c084b26d9"
|
||||
integrity sha512-oiI+oq91iO/Vpp+pt8PqfqLfBK074FH0eprhoFNvBCvJOk7vL4ozbe/yj/kEEGR6kiT4F3MAam19AX1fdGFjrA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.3.4"
|
||||
"@sheerun/mutationobserver-shim" "^0.3.2"
|
||||
pretty-format "^24.5.0"
|
||||
wait-for-expect "^1.1.0"
|
||||
|
||||
dom-walk@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018"
|
||||
@ -11470,7 +11485,7 @@ pretty-error@^2.1.1:
|
||||
renderkid "^2.0.1"
|
||||
utila "~0.4"
|
||||
|
||||
pretty-format@^24.7.0:
|
||||
pretty-format@^24.5.0, pretty-format@^24.7.0:
|
||||
version "24.7.0"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.7.0.tgz#d23106bc2edcd776079c2daa5da02bcb12ed0c10"
|
||||
integrity sha512-apen5cjf/U4dj7tHetpC7UEFCvtAgnNZnBDkfPv3fokzIqyOJckAG9OlAPC1BlFALnqT/lGB2tl9EJjlK6eCsA==
|
||||
@ -11901,6 +11916,14 @@ react-test-renderer@^16.8.4:
|
||||
react-is "^16.8.6"
|
||||
scheduler "^0.13.6"
|
||||
|
||||
react-testing-library@^6.1.2:
|
||||
version "6.1.2"
|
||||
resolved "https://registry.yarnpkg.com/react-testing-library/-/react-testing-library-6.1.2.tgz#f6bba6eeecedac736eb00b22b4c70bae04535a4f"
|
||||
integrity sha512-z69lhRDGe7u/NOjDCeFRoe1cB5ckJ4656n0tj/Fdcr6OoBUu7q9DBw0ftR7v5i3GRpdSWelnvl+feZFOyXyxwg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.4.2"
|
||||
dom-testing-library "^3.19.0"
|
||||
|
||||
react@^16.8.3, react@^16.8.6:
|
||||
version "16.8.6"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
|
||||
@ -14432,6 +14455,11 @@ w3c-hr-time@^1.0.1:
|
||||
dependencies:
|
||||
browser-process-hrtime "^0.1.2"
|
||||
|
||||
wait-for-expect@^1.1.0:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-1.1.1.tgz#9cd10e07d52810af9e0aaf509872e38f3c3d81ae"
|
||||
integrity sha512-vd9JOqqEcBbCDhARWhW85ecjaEcfBLuXgVBqatfS3iw6oU4kzAcs+sCNjF+TC9YHPImCW7ypsuQc+htscIAQCw==
|
||||
|
||||
walker@^1.0.7, walker@~1.0.5:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
|
||||
|
Loading…
Reference in New Issue
Block a user