From d455ca2ebbbcf65b552404d36533aad12ef977d9 Mon Sep 17 00:00:00 2001 From: Ali Sheehan-Dare Date: Fri, 14 Oct 2016 12:59:45 +0100 Subject: [PATCH] test: add broken test for miss case with blocker --- modules/__tests__/Miss-test.js | 49 +++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/modules/__tests__/Miss-test.js b/modules/__tests__/Miss-test.js index 553c0b0a94..dacbf1c9d7 100644 --- a/modules/__tests__/Miss-test.js +++ b/modules/__tests__/Miss-test.js @@ -2,6 +2,7 @@ import expect from 'expect' import React from 'react' import Miss from '../Miss' import Match from '../Match' +import Redirect from '../Redirect' import { render, unmountComponentAtNode } from 'react-dom' import MemoryRouter from '../MemoryRouter' @@ -9,6 +10,12 @@ describe('Miss', () => { const TEXT = 'TEXT' const loc = { pathname: '/', search: '', hash: '', state: TEXT } + const renderRouter = (element, location) => ( + + {element} + + ) + it('renders a Component prop', (done) => { const div = document.createElement('div') const Page = () =>
{TEXT}
@@ -42,9 +49,10 @@ describe('Miss', () => { const MATCH = 'MATCH' const App = ({ location }) => ( - - - + renderRouter( + , + location + ) ) const Parent = () => ( @@ -61,6 +69,7 @@ describe('Miss', () => { render(, div, () => { expect(div.innerHTML).toNotContain(TEXT) expect(div.innerHTML).toContain(MATCH) + unmountComponentAtNode(div) done() }) }) @@ -72,8 +81,42 @@ describe('Miss', () => { render(, div, () => { expect(div.innerHTML).toContain(TEXT) expect(div.innerHTML).toNotContain(MATCH) + unmountComponentAtNode(div) done() }) }) }) + + describe('FAILING MISS TESTS', () => { + it('does not update when a `blocker` component is rendered', (done) => { + const div = document.createElement('div') + + class Blocker extends React.Component { + shouldComponentUpdate() { return false } + render() { return } + } + const Home = () => ( + + ) + const App = () => ( +
+ +

NotFound

} /> +
+ ) + + render( + renderRouter( + , + { pathname: '/' } + ), + div, + () => { + expect(div.innerHTML).toContain('NotFound') + unmountComponentAtNode(div) + done() + } + ) + }) + }) })