From 1b45582483ef109341e05e023fc0d8fe7ba5230d Mon Sep 17 00:00:00 2001
From: Alexandros Georgantas <alexgeorg86@gmail.com>
Date: Thu, 30 Mar 2017 11:13:14 +0300
Subject: [PATCH] Added render test for the Chapter

---
 .../BookBuilder/test/Chapter.spec.js          | 51 ++++++++++---------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/app/components/BookBuilder/test/Chapter.spec.js b/app/components/BookBuilder/test/Chapter.spec.js
index 41de42f..dabad98 100644
--- a/app/components/BookBuilder/test/Chapter.spec.js
+++ b/app/components/BookBuilder/test/Chapter.spec.js
@@ -3,6 +3,8 @@ import {
   // mount,
   shallow
 } from 'enzyme'
+import { shallowToJson } from 'enzyme-to-json'
+import sinon from 'sinon'
 
 // import { DropdownButton } from 'react-bootstrap'
 // import { DragDropContext } from 'react-dnd'
@@ -13,39 +15,37 @@ import {
 
 // // grab the undecorated by dnd react component
 import Chapter from '../Chapter'
-const OriginalChapter = Chapter.DecoratedComponent.DecoratedComponent
+const OriginalChapter = Chapter.DecoratedComponent
 
 // import ProgressIndicator from '../ProgressIndicator'
 // import TextInput from '../../../components/TextInput'
 
 // const identity = function (el) { return el }
-
+const identity = el => el
 const { data } = global.mock
+const type = 'front'
+const chapters = data.chapters.filter((chapter) => {
+  return chapter.division === type
+})
+const firstChapter = chapters[0]
 
 let props = {
   book: data.book,
-  chapter: data.chapters[0]
-  // connectDragSource: identity,
-  // connectDropTarget: identity,
-  // isDragging: false,
-  //
-  // title: 'This title',
-  // type: 'chapter',
-  // chapter: {
-  //   id: '123',
-  //   alignment: {},
-  //   division: 'front',
-  //   progress: {
-  //     style: 0,
-  //     edit: 0,
-  //     review: 0,
-  //     clean: 0
-  //   }
-  // },
-  // remove: sinon.spy(),
-  // update: sinon.spy(),
-  // roles: [],
-  // outerContainer: {}
+  chapter: firstChapter,
+  id: firstChapter.id,
+  ink: sinon.spy(),
+  key: firstChapter.index,
+  move: sinon.spy(),
+  no: 0,
+  outerContainer: {},
+  remove: sinon.spy(),
+  roles: [],
+  title: firstChapter.title,
+  type: firstChapter.subCategory,
+  update: sinon.spy(),
+  connectDragSource: identity,
+  connectDropTarget: identity,
+  isDragging: false
 }
 
 // function wrapInTestContext (Chapter) {
@@ -64,7 +64,8 @@ const getWrapper = () => {
 
 test('should render correctly', () => {
   const wrapper = getWrapper()
-  expect(wrapper).toMatchSnapshot()
+  const tree = shallowToJson(wrapper)
+  expect(tree).toMatchSnapshot()
 })
 
 // describe('Chapter', () => {
-- 
GitLab