1- const TestRunner = require ( "jest-runner" )
2-
3- // Unit Test Cases for Charts
4- // description: lifecycle methods
5- // Component should call make3dTree upon mounting
6- // object 'root' should be a deep clone of the snapshot
7- // i.e.: this.props.snapshot !== root
8-
9- // description: maked3Tree
10- // Should call function 'removed3tree' only once
11- // Should call appropriate function upon triggering a certain event on the tooltip div
12- // i.e.:
13- // 'mouseover' event -> 'tipMouseover' function
14- // 'mouseout' event -> 'tipMouseout' function
15- // Should call appropriate function upon triggering a certain event on a node (nested under the 'update' function)
16- // i.e.:
17- // 'mouseover' event -> 'mouseover' function
18- // 'mouseout' event -> 'mouseout' function
19- // 'click' event -> 'click' function
20- // Should call function 'update' at least once
21-
22- describe ( 'placeholder' , ( ) => {
23- xit ( 'placeholder for tests' , ( ) => {
24- expect ( 1 + 1 ) . toEqual ( 2 ) ;
25- } )
26- } )
1+ import React from 'react' ;
2+ import Chart from '../components/Chart' ;
3+ import testRunner from 'jest-runner' ;
4+
5+ // Unit test cases for d3 functionality
6+ // Test the life cycle methods in Chart
7+ describe ( 'Life cycle methods in Chart' , ( ) => {
8+ it ( 'should call maked3Tree upon mounting' , ( ) => {
9+ // Component should call maked3Tree upon mounting
10+ // Use the mock function + .toBeCalled()
11+ // Test the method in the component
12+ } ) ;
13+ } ) ;
14+
15+ // Test the root object and hierarchy
16+ describe ( 'Root object' , ( ) => {
17+ it ( 'should be a deep clone of the hierarchy' , ( ) => {
18+ // object 'root' should be a deep clone of the hierarchy
19+ // create an empty object to mimic root
20+ // i.e.: this.props.hierarchy !== root
21+ // expect to !== this.props.hierarchy
22+ // expect to be a deep clone
23+ } ) ;
24+ } ) ;
25+
26+ // Test the maked3Tree method
27+ describe ( 'maked3Tree method' , ( ) => {
28+ it ( 'should call removed3tree once' , ( ) => {
29+ // Should call function 'removed3tree' only once
30+ // expect toBeCalled()
31+ // expect toHaveBeenCalled()
32+ } ) ;
33+ } ) ;
34+ // Test the tooltip functionality in maked3Tree method
35+ describe ( 'tooltip functionality in maked3Tree' , ( ) => {
36+ // Should call appropriate function upon triggering
37+ // a certain event on the tooltip div
38+ // Should call appropriate function upon triggering mouseOver
39+ it ( 'should invoke tip.show on mouseOver' , ( ) => {
40+
41+ } ) ;
42+ // Should call appropriate function upon triggering mouseOut
43+ it ( 'should invoke tip.hide on mouseOut' , ( ) => {
44+
45+ } ) ;
46+ } ) ;
47+
48+
49+
50+
0 commit comments