Skip to content

Commit

Permalink
Only create test app in component tests. Fixes #683.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed May 24, 2020
1 parent 3d1bfc8 commit 5430989
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/components/__tests__/SubThoughtTop.js
@@ -1,5 +1,10 @@
import { store } from '../../store'
import { getThoughtsRanked } from '../../selectors'
import { createTestApp } from '../../setupTests'

beforeEach(async () => {
createTestApp()
})

it('create top subthought', async () => {

Expand Down
5 changes: 5 additions & 0 deletions src/components/__tests__/ThoughtAbove.js
@@ -1,8 +1,13 @@
import { createTestApp } from '../../setupTests'
import { store } from '../../store'

// selectors
import getThoughtsRanked from '../../selectors/getThoughtsRanked'

beforeEach(async () => {
createTestApp()
})

it('create thought above', async () => {

// create thought
Expand Down
5 changes: 5 additions & 0 deletions src/components/__tests__/ThoughtAboveRoot.js
@@ -1,3 +1,4 @@
import { createTestApp } from '../../setupTests'
import { store } from '../../store'

// constants
Expand All @@ -6,6 +7,10 @@ import { ROOT_TOKEN } from '../../constants.js'
// selectors
import getThoughtsRanked from '../../selectors/getThoughtsRanked'

beforeEach(async () => {
createTestApp()
})

it('create thought above (root)', async () => {

// create thought
Expand Down
5 changes: 5 additions & 0 deletions src/components/__tests__/ThoughtCreate.js
@@ -1,6 +1,11 @@
import { store } from '../../store'
import { getThoughts } from '../../selectors'
import { ROOT_TOKEN } from '../../constants'
import { createTestApp } from '../../setupTests'

beforeEach(async () => {
createTestApp()
})

it('create thought', async () => {

Expand Down
12 changes: 2 additions & 10 deletions src/setupTests.js
Expand Up @@ -10,7 +10,7 @@ import { keyDown } from './shortcuts'
configure({ adapter: new Adapter() })

/** Set up testing and mock document and window functions. */
const createTestApp = async app => {
export const createTestApp = async () => {

document.getSelection = () => ({
type: 'None',
Expand Down Expand Up @@ -52,7 +52,7 @@ const createTestApp = async app => {
onKeyDown={keyDown}
tabIndex="0"
>
{app}
<App />
</div>,
{ attachTo: root }
)
Expand All @@ -61,11 +61,3 @@ const createTestApp = async app => {
document.wrapper = wrapper
})
}

beforeAll(async () => {
createTestApp(<App />)
})

afterAll(async () => {
document.wrapper.unmount()
})

0 comments on commit 5430989

Please sign in to comment.