From bd83e9e118499b89033eda0423ab3289b46e81d5 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:31:10 +0700 Subject: [PATCH] Add first Snapshot testing --- .../__tests__/infoBox.spec.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/talk-plugin-infobox/__tests__/infoBox.spec.js b/client/talk-plugin-infobox/__tests__/infoBox.spec.js index 2110f5dc9..e26baa54f 100644 --- a/client/talk-plugin-infobox/__tests__/infoBox.spec.js +++ b/client/talk-plugin-infobox/__tests__/infoBox.spec.js @@ -1,29 +1,36 @@ import React from 'react'; import {shallow} from 'enzyme'; -import {expect} from 'chai'; import InfoBox from '../InfoBox'; +import renderer from 'react-test-renderer'; const render = (props) => shallow(); describe('InfoBox', () => { + it('renders correctly', () => { + const tree = renderer.create( + + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('should render hidden InfoBox', () => { const wrapper = render(); const className = wrapper.prop('className'); - expect(className).to.include('-info'); - expect(className).to.include('hidden'); + expect(className).toMatch('-info'); + expect(className).toMatch('hidden'); }); it('should render enabled InfoBox', () => { const wrapper = render({enable: true}); const className = wrapper.prop('className'); - expect(className).to.include('-info'); - expect(className).to.not.include('hidden'); + expect(className).toMatch('-info'); + expect(className).not.toMatch('hidden'); }); it('should render Markdown', () => { const wrapper = render({content: 'x'}); const Markddown = wrapper.find('Markdown'); - expect(Markddown).to.have.length(1); - expect(Markddown.prop('content')).to.equal('x'); + expect(Markddown).toHaveLength(1); + expect(Markddown.prop('content')).toEqual('x'); }); });