Skip to content

Commit

Permalink
chore: fix formatting config
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Apr 8, 2021
1 parent 5fe9485 commit e82aa61
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"type": "commonjs",
"main": "./index.js",
"types": "./index.d.ts"
}
}
34 changes: 22 additions & 12 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,18 @@ title: This is frontmatter
published: new Date('2021-02-13'),
description: 'This is some meta-data',
})

const {container} = render(
React.createElement(Component, {components: {strong: SpanBold}}),
)

assert.equal(container.innerHTML, `<h1>This is the title</h1>

assert.equal(
container.innerHTML,
`<h1>This is the title</h1>
<p>Here's a <span>neat</span> demo:</p>
<div>$$Neat demo!<div class="sub-dir">Sub dir!</div><p>JSON: mdx-bundler</p><div>this is js info</div><div>jsx comp</div><h1>Frontmatter title: This is frontmatter</h1></div>`)
<div>$$Neat demo!<div class="sub-dir">Sub dir!</div><p>JSON: mdx-bundler</p><div>this is js info</div><div>jsx comp</div><h1>Frontmatter title: This is frontmatter</h1></div>`,
)
})

test('bundles 3rd party deps', async () => {
Expand Down Expand Up @@ -142,8 +145,11 @@ import Demo from './demo'
files: {},
}).catch(e => e))

assert.equal(error.message, `Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}index.mdx:2:17: error: [inMemory] Could not resolve "./demo" from the entry MDX file.`)
assert.equal(
error.message,
`Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}index.mdx:2:17: error: [inMemory] Could not resolve "./demo" from the entry MDX file.`,
)
})

test('gives a handy error when importing a module that cannot be found', async () => {
Expand All @@ -159,9 +165,11 @@ import Demo from './demo'
},
}).catch(e => e))


assert.equal(error.message, `Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}demo.tsx:1:7: error: [inMemory] Could not resolve "./blah-blah" from "./demo.tsx"`)
assert.equal(
error.message,
`Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}demo.tsx:1:7: error: [inMemory] Could not resolve "./blah-blah" from "./demo.tsx"`,
)
})

test('gives a handy error when a file of an unsupported type is provided', async () => {
Expand All @@ -177,8 +185,11 @@ import Demo from './demo.blah'
},
}).catch(e => e))

assert.equal(error.message, `Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}index.mdx:2:17: error: [JavaScript plugins] Invalid loader: "blah" (valid: js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)`)
assert.equal(
error.message,
`Build failed with 1 error:
__mdx_bundler_fake_dir__${path.sep}index.mdx:2:17: error: [JavaScript plugins] Invalid loader: "blah" (valid: js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)`,
)
})

test('files is optional', async () => {
Expand Down Expand Up @@ -240,5 +251,4 @@ import LeftPad from 'left-pad-js'
assert.match(container.innerHTML, 'this is left pad')
})


test.run()
6 changes: 3 additions & 3 deletions src/__tests__/setup-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
const {window} = jsdom

/**
* @param {Object} src
* @param {Object} target
* @param {Object} src
* @param {Object} target
*/
function copyProps(src, target) {
Object.defineProperties(target, {
Expand All @@ -20,7 +20,7 @@ function copyProps(src, target) {
global.window = window
global.document = window.document
// @ts-expect-error TS2740 🤷‍♂️
global.navigator = { userAgent: 'node.js', }
global.navigator = {userAgent: 'node.js'}
global.requestAnimationFrame = callback => setTimeout(callback, 0)
global.cancelAnimationFrame = id => clearTimeout(id)
copyProps(window, global)

0 comments on commit e82aa61

Please sign in to comment.