1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/no-var-requires */
3
- /* eslint-disable react/jsx-props-no-spreading */
4
- /* eslint-disable import/no-extraneous-dependencies */
5
- /* eslint-disable import/no-named-as-default-member */
6
- /* eslint-disable import/no-named-as-default */
7
- import React from 'react' ;
8
- import { configure , mount } from 'enzyme' ;
9
- import Adapter from 'enzyme-adapter-react-16' ;
10
- import History from '../components/History' ;
1
+ /* eslint:disable */
11
2
3
+ import * as d3 from 'd3'
12
4
13
- // Unit test cases for d3 functionality
14
- configure ( { adapter : new ( Adapter as any ) ( ) } ) ;
5
+ describe ( 'D3 Canvas Testing' , ( ) => {
6
+ const getCanvas = ( ) => {
7
+ return d3 . select ( '#canvas' )
8
+ }
15
9
16
- // Test the life cycle methods in History
17
- describe ( 'Life cycle methods in History' , ( ) => {
18
- let wrapper ;
19
- const props = {
20
- hierarchy : {
21
- branch : 0 ,
22
- children : [
23
- {
24
- index :1 ,
25
- name :2 ,
26
- branch :0 ,
27
- stateSnapshot :{ } ,
28
- children : [ ]
29
- }
30
- ] ,
31
- index : 0 ,
32
- name : 1 ,
33
- stateSnapshot : {
34
- children :[ { } ] ,
35
- componentData : { } ,
36
- name : "root" ,
37
- state : "root"
38
- }
39
- } ,
40
- } ;
41
- // Set up wrapper
42
- beforeEach ( ( ) => {
43
- wrapper = mount ( < History { ...props } /> ) ;
44
- } ) ;
45
- // test componentDidMount
46
- it ( 'should call componentDidMount once' , ( ) => {
47
- const instance = wrapper . instance ( ) ;
48
- jest . spyOn ( instance , 'componentDidMount' ) ;
49
- instance . componentDidMount ( ) ;
50
- expect ( instance . componentDidMount ) . toHaveBeenCalledTimes ( 1 ) ;
51
- } ) ;
52
- // test maked3Tree within componentDidMount
53
- it ( 'should call maked3Tree upon mounting' , ( ) => {
54
- const instance = wrapper . instance ( ) ;
55
- jest . spyOn ( instance , 'maked3Tree' ) ;
56
- instance . componentDidMount ( ) ;
57
- expect ( instance . maked3Tree ) . toHaveBeenCalledTimes ( 1 ) ;
58
- } ) ;
59
- // test componentDidUpdate
60
- it ( 'should call componentDidUpdate once' , ( ) => {
61
- const instance = wrapper . instance ( ) ;
62
- jest . spyOn ( instance , 'componentDidUpdate' ) ;
63
- instance . componentDidUpdate ( ) ;
64
- expect ( instance . componentDidUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
65
- } ) ;
66
- // test maked3Tree within componentDidUpdate
67
- it ( 'should call maked3Tree once upon updating' , ( ) => {
68
- const instance = wrapper . instance ( ) ;
69
- jest . spyOn ( instance , 'maked3Tree' ) ;
70
- instance . componentDidUpdate ( ) ;
71
- expect ( instance . maked3Tree ) . toHaveBeenCalledTimes ( 1 ) ;
72
- } ) ;
73
- } ) ;
74
- // Test the root object and hierarchy
75
- describe ( 'Root object' , ( ) => {
76
- let wrapper ;
77
- const root = { } ;
78
- const props = {
79
- hierarchy : {
80
- index : 1 ,
81
- stateSnapshot : { } ,
82
- children : [ ] ,
83
- } ,
84
- } ;
85
- // Set up wrapper
86
- beforeEach ( ( ) => {
87
- wrapper = mount ( < History { ...props } /> ) ;
88
- } ) ;
10
+ it ( 'should render' , ( ) => {
11
+ expect ( getCanvas ( ) ) . not . toBeNull ( ) ;
12
+ } )
89
13
90
- // eslint-disable-next-line jest/no-disabled-tests
91
- it ( 'should be a deep clone of the hierarchy' , ( ) => {
92
- const instance = wrapper . instance ( ) ;
93
- instance . componentDidMount ( ) ;
94
- expect ( typeof root ) . toBe ( typeof props . hierarchy ) ;
95
- expect ( root ) . not . toEqual ( props . hierarchy ) ;
96
- } ) ;
97
- } ) ;
14
+ } )
98
15
99
- // Test the maked3Tree method
100
- describe ( 'maked3Tree method' , ( ) => {
101
- let wrapper ;
102
- const props = {
103
- hierarchy : 0 ,
104
- } ;
105
- // Set up wrapper
106
- beforeEach ( ( ) => {
107
- wrapper = mount ( < History { ...props } /> ) ;
108
- } ) ;
109
- // Test the invocation of removed3Tree within maked3Tree
110
- it ( 'should call removed3Tree once' , ( ) => {
111
- const instance = wrapper . instance ( ) ;
112
- jest . spyOn ( instance , 'removed3Tree' ) ;
113
- instance . maked3Tree ( ) ;
114
- expect ( instance . removed3Tree ) . toHaveBeenCalledTimes ( 1 ) ;
115
- } ) ;
116
- } ) ;
16
+ describe ( 'D3 Node Testing' , ( ) => {
17
+ const getNodes = ( ) => {
18
+ return d3 . select ( 'g' )
19
+ }
20
+
21
+ it ( 'should render' , ( ) => {
22
+ expect ( getNodes ( ) ) . not . toBeNull ( ) ;
23
+ } )
24
+
25
+
26
+ } )
0 commit comments