orgchart 5.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.github/workflows/publish.yml +35 -0
  2. package/README.md +214 -123
  3. package/README.zh-cn.md +232 -100
  4. package/README.zh-tw.md +232 -100
  5. package/bower.json +6 -9
  6. package/demo/10000-nodes.html +139 -0
  7. package/demo/ajax-datasource.html +46 -45
  8. package/demo/bottom2top.html +12 -9
  9. package/demo/center-on-selected-node.html +21 -17
  10. package/demo/color-coded.html +12 -9
  11. package/demo/css/style.css +28 -0
  12. package/demo/custom-icons.html +12 -9
  13. package/demo/custom-template.html +12 -9
  14. package/demo/data-prop-compact.html +11 -8
  15. package/demo/data-prop-hybrid.html +79 -50
  16. package/demo/default-collapsed.html +12 -9
  17. package/demo/drag-drop-hybrid-chart.html +17 -14
  18. package/demo/drag-drop.html +21 -16
  19. package/demo/edit-chart.html +144 -94
  20. package/demo/edit-hybrid-chart.html +177 -135
  21. package/demo/expand-to-given-depth.html +30 -22
  22. package/demo/export-chart-pdf.html +12 -9
  23. package/demo/export-chart-with-pictures.html +19 -12
  24. package/demo/export-chart.html +12 -9
  25. package/demo/family-tree.html +14 -11
  26. package/demo/familytree-custom-properties.html +108 -0
  27. package/demo/filter-node.html +104 -57
  28. package/demo/get-hierarchy.html +17 -12
  29. package/demo/get-related-nodes.html +27 -17
  30. package/demo/index.html +10 -3
  31. package/demo/integrate-map.html +32 -27
  32. package/demo/left2right.html +12 -9
  33. package/demo/level-offset.html +16 -15
  34. package/demo/link-node.html +12 -9
  35. package/demo/local-datasource.html +11 -8
  36. package/demo/minimap.html +224 -0
  37. package/demo/nodes-of-different-widths.html +11 -8
  38. package/demo/ondemand-loading-data.html +166 -112
  39. package/demo/option-createNode.html +28 -17
  40. package/demo/options-compact-drag.html +82 -0
  41. package/demo/options-export-navigation.html +76 -0
  42. package/demo/options-horizontal-template.html +80 -0
  43. package/demo/options-hybrid-navigation.html +71 -0
  44. package/demo/pan-zoom.html +20 -11
  45. package/demo/reload-data.html +17 -14
  46. package/demo/report-path.html +59 -29
  47. package/demo/responsive-design.html +14 -11
  48. package/demo/right2left.html +12 -9
  49. package/demo/toggle-sibs-resp.html +12 -9
  50. package/demo/ul-datasource.html +11 -8
  51. package/demo/vertical-level.html +12 -9
  52. package/dist/css/{jquery.orgchart.css → orgchart.css} +154 -80
  53. package/dist/css/orgchart.min.css +1 -0
  54. package/dist/js/orgchart.js +4474 -0
  55. package/dist/js/orgchart.min.js +2 -0
  56. package/dist/js/orgchart.min.js.map +1 -0
  57. package/gulpfile.js +42 -27
  58. package/package.json +33 -32
  59. package/src/css/{jquery.orgchart.css → orgchart.css} +154 -80
  60. package/src/js/orgchart.js +4474 -0
  61. package/test/compatibility/README.md +123 -0
  62. package/test/compatibility/browser.tests.js +1279 -0
  63. package/test/compatibility/options.tests.js +628 -0
  64. package/test/cypress/e2e/demo-interactions.cy.js +91 -0
  65. package/test/cypress/e2e/demo-rendering.cy.js +161 -0
  66. package/test/cypress/e2e/drag-drop-hybrid-chart.cy.js +23 -0
  67. package/test/cypress/e2e/edit-chart.cy.js +20 -0
  68. package/test/cypress/e2e/level-offset.cy.js +21 -0
  69. package/test/cypress/e2e/local-datasource.cy.js +16 -16
  70. package/test/cypress/e2e/minimap.cy.js +66 -0
  71. package/test/cypress/e2e/ondemand-loading-data.cy.js +34 -10
  72. package/test/cypress/e2e/pan-zoom.cy.js +165 -0
  73. package/test/cypress/e2e/report-path.cy.js +20 -0
  74. package/test/cypress/e2e/toggle-sibs-resp.cy.js +4 -4
  75. package/test/cypress/e2e/vertical-vevel.cy.js +7 -5
  76. package/test/e2e/local-datasource/test.js +1 -1
  77. package/test/integration/init-tests.js +192 -99
  78. package/test/integration/tests.js +1043 -57
  79. package/test/unit/lifecycle-builders-export.tests.js +1487 -0
  80. package/test/unit/minimap.tests.js +210 -0
  81. package/test/unit/tests.js +2372 -253
  82. package/dist/css/jquery.orgchart.min.css +0 -1
  83. package/dist/js/jquery.orgchart.js +0 -1741
  84. package/dist/js/jquery.orgchart.min.js +0 -5
  85. package/dist/js/jquery.orgchart.min.js.map +0 -1
  86. package/src/js/jquery.orgchart.js +0 -1741
@@ -1,49 +1,66 @@
1
- var chai = require('chai');
2
- var sinon = require('sinon');
3
- var sinonChai = require('sinon-chai');
4
- var should = chai.should();
1
+ const chai = require('chai');
2
+ const sinon = require('sinon');
3
+ const sinonChai = require('sinon-chai').default;
4
+ const should = chai.should();
5
5
  chai.use(sinonChai);
6
6
  require('jsdom-global')();
7
- var $ = require('jquery');
8
- require('../../src/js/jquery.orgchart');
7
+ const OrgChart = require('../../src/js/orgchart');
8
+
9
+ function query(selector, root) {
10
+ return (root || document).querySelector(selector);
11
+ }
12
+
13
+ function queryAll(selector, root) {
14
+ return Array.from((root || document).querySelectorAll(selector));
15
+ }
16
+
17
+ function createElementFromHtml(html) {
18
+ const template = document.createElement('template');
19
+
20
+ template.innerHTML = html.trim();
21
+ return template.content.firstElementChild;
22
+ }
9
23
 
10
24
  describe('orgchart -- integration tests', function () {
11
- document.body.innerHTML = '<div id="chart-container"></div>';
12
- var $container = $('#chart-container'),
13
- ds = {
25
+ let container;
26
+
27
+ const ds = {
14
28
  'id': 'n1',
15
29
  'name': 'Lao Lao',
16
30
  'children': [
17
31
  { 'id': 'n2', 'name': 'Bo Miao' },
18
32
  { 'id': 'n3', 'name': 'Su Miao' }
19
33
  ]
20
- },
21
- fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
22
- '<div id="n1" class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol">' +
23
- '</i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes">' +
24
- '<li class="hierarchy"><div id="n2" data-parent="n1" class="node">' +
25
- '<div class="title">Bo Miao</div><i class="edge verticalEdge topEdge oci"></i>' +
26
- '<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci">' +
27
- '</i></div></li><li class="hierarchy"><div id="n3" data-parent="n1" class="node">' +
28
- '<div class="title">Su Miao</div><i class="edge verticalEdge topEdge oci"></i>' +
29
- '<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci">' +
30
- '</i></div></li></ul></li></ul></div>',
31
- oc = {};
32
-
34
+ };
35
+
36
+ const fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy"><div id="n1" class="node" tabindex="0"><div clas' +
37
+ 's="title"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div></div><ul class="nodes"><li class="hierarc' +
38
+ 'hy"><div id="n2" data-parent="n1" class="node" tabindex="0"><div class="title">Bo Miao</div></div></li><li cla' +
39
+ 'ss="hierarchy"><div id="n3" data-parent="n1" class="node" tabindex="0"><div class="title">Su Miao</div></div><' +
40
+ '/li></ul></li></ul></div>';
41
+
42
+ let oc = {};
43
+
44
+ beforeEach(function () {
45
+ document.body.innerHTML = '<div id="chart-container"></div>';
46
+ container = document.getElementById('chart-container');
47
+ });
48
+
33
49
  afterEach(function () {
34
- $container.empty();
50
+ container.innerHTML = '';
35
51
  });
36
52
 
37
53
  describe('init()', function () {
38
54
  it('initialize chart with json datasource', function () {
39
- oc = $container.orgchart({
55
+ oc = new OrgChart({
56
+ chartContainer: '#chart-container',
40
57
  'data': ds
41
58
  });
42
- $container.html().should.equal(fragment);
59
+ container.innerHTML.should.equal(fragment);
43
60
  });
44
61
 
45
62
  it('initialize chart with <ul> datasource', function () {
46
- var $ul = $(
63
+ const ulElement = createElementFromHtml(
47
64
  '<ul id="ul-data">' +
48
65
  '<li data-id="n1">Lao Lao' +
49
66
  '<ul>' +
@@ -53,39 +70,41 @@ describe('orgchart -- integration tests', function () {
53
70
  '</li>' +
54
71
  '</ul>'
55
72
  );
56
- $('body').append($ul);
57
- oc = $container.orgchart({
58
- 'data': $('#ul-data')
73
+ document.body.appendChild(ulElement);
74
+ oc = new OrgChart({
75
+ chartContainer: '#chart-container',
76
+ 'data': ulElement
59
77
  });
60
- $container.html().should.equal(fragment);
61
- $ul.remove();
78
+ container.innerHTML.should.equal(fragment);
79
+ ulElement.remove();
62
80
  });
63
81
 
64
82
  it('initialize chart with the given visible level', function () {
65
- oc = $container.orgchart({
83
+ oc = new OrgChart({
84
+ chartContainer: '#chart-container',
66
85
  'data': ds,
67
86
  'visibleLevel': 1
68
87
  });
69
- oc.$chart.find('.hierarchy:first').is('.hidden').should.be.false;
70
- oc.$chart.find('.nodes').eq(1).is('.hidden').should.be.true;
71
- oc.$chart.find('.node.slide-up').should.lengthOf(2);
88
+ query('.hierarchy', oc.chart).classList.contains('hidden').should.be.false;
89
+ queryAll('.nodes', oc.chart)[1].classList.contains('hidden').should.be.true;
90
+ queryAll('.node.slide-up', oc.chart).should.lengthOf(2);
72
91
  });
73
92
 
74
93
  it('initialize chart with the given vertical level', function () {
75
- var fragment = '<li class="hierarchy"><div id="n1" class="node"><div class="title">' +
76
- '<i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci">' +
77
- '</i></div><ul class="nodes vertical"><li class="hierarchy"><div id="n2" data-parent="n1" class="node">' +
78
- '<div class="title">Bo Miao</div></div></li><li class="hierarchy"><div id="n3" data-parent="n1" class="node">' +
79
- '<div class="title">Su Miao</div></div></li></ul></li>';
80
- oc = $container.orgchart({
94
+ const fragment = '<li class="hierarchy"><div id="n1" class="node" tabindex="0"><div class="title"><i class="oci oci-menu parentN' +
95
+ 'odeSymbol"></i>Lao Lao</div></div><ul class="nodes vertical"><li class="hierarchy"><div id="n2" data-parent="n' +
96
+ '1" class="node" tabindex="0"><div class="title">Bo Miao</div></div></li><li class="hierarchy"><div id="n3" dat' +
97
+ 'a-parent="n1" class="node" tabindex="0"><div class="title">Su Miao</div></div></li></ul></li>';
98
+ oc = new OrgChart({
99
+ chartContainer: '#chart-container',
81
100
  'data': ds,
82
101
  'verticalLevel': 2
83
102
  });
84
- oc.$chart.find('.nodes:first').html().should.equal(fragment);
103
+ query('.nodes', oc.chart).innerHTML.should.equal(fragment);
85
104
  });
86
105
 
87
106
  context('initialize chart with various combinations of "visibleLevel" and "verticalLevel" ', function () {
88
- var ds = {
107
+ const ds = {
89
108
  'name': 'Lao Lao',
90
109
  'children': [
91
110
  { 'name': 'Bo Miao'
@@ -100,127 +119,201 @@ describe('orgchart -- integration tests', function () {
100
119
  };
101
120
 
102
121
  it('verticalLevel=2 and visibleLevel=1', function () {
103
- var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
104
- '<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol">' +
105
- '</i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci"></i></div>' +
106
- '<ul class="nodes hidden vertical"><li class="hierarchy"><div class="node slide-up">' +
107
- '<div class="title">Bo Miao</div></div></li><li class="hierarchy">' +
108
- '<div class="node slide-up"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
109
- '<i class="toggleBtn oci"></i></div><ul class="nodes hidden">' +
110
- '<li class="hierarchy"><div class="node slide-up"><div class="title">Tie Hua</div>' +
111
- '</div></li><li class="hierarchy"><div class="node slide-up">' +
112
- '<div class="title">Hei Hei</div></div></li></ul></li></ul></li></ul></div>';
113
- oc = $container.orgchart({
122
+ const fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy"><div class="node" tabindex="0"><div class="title' +
123
+ '"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div></div><ul class="nodes hidden vertical"><li class=' +
124
+ '"hierarchy"><div class="node slide-up" tabindex="0"><div class="title">Bo Miao</div></div></li><li class="hier' +
125
+ 'archy"><div class="node slide-up" tabindex="0"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i' +
126
+ '>Su Miao</div></div><ul class="nodes hidden"><li class="hierarchy"><div class="node slide-up" tabindex="0"><di' +
127
+ 'v class="title">Tie Hua</div></div></li><li class="hierarchy"><div class="node slide-up" tabindex="0"><div cla' +
128
+ 'ss="title">Hei Hei</div></div></li></ul></li></ul></li></ul></div>';
129
+ oc = new OrgChart({
130
+ chartContainer: '#chart-container',
114
131
  'data': ds,
115
132
  'verticalLevel': 2,
116
133
  'visibleLevel': 1
117
134
  });
118
- $container.html().should.equal(fragment);
135
+ container.innerHTML.should.equal(fragment);
119
136
  });
120
137
 
121
138
  it('verticalLevel=2 and visibleLevel=2', function () {
122
- var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
123
- '<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div>' +
124
- '<i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes vertical">' +
125
- '<li class="hierarchy"><div class="node"><div class="title">Bo Miao</div></div></li>' +
126
- '<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
127
- '<i class="toggleBtn oci"></i></div><ul class="nodes hidden">' +
128
- '<li class="hierarchy"><div class="node slide-up"><div class="title">Tie Hua</div></div>' +
129
- '</li><li class="hierarchy"><div class="node slide-up"><div class="title">Hei Hei</div>' +
130
- '</div></li></ul></li></ul></li></ul></div>';
131
- oc = $container.orgchart({
139
+ const fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy"><div class="node" tabindex="0"><div class="title' +
140
+ '"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div></div><ul class="nodes vertical"><li class="hierar' +
141
+ 'chy"><div class="node" tabindex="0"><div class="title">Bo Miao</div></div></li><li class="hierarchy"><div clas' +
142
+ 's="node" tabindex="0"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div></div><ul c' +
143
+ 'lass="nodes hidden"><li class="hierarchy"><div class="node slide-up" tabindex="0"><div class="title">Tie Hua</' +
144
+ 'div></div></li><li class="hierarchy"><div class="node slide-up" tabindex="0"><div class="title">Hei Hei</div><' +
145
+ '/div></li></ul></li></ul></li></ul></div>';
146
+ oc = new OrgChart({
147
+ chartContainer: '#chart-container',
132
148
  'data': ds,
133
149
  'verticalLevel': 2,
134
150
  'visibleLevel': 2
135
151
  });
136
- $container.html().should.equal(fragment);
152
+ container.innerHTML.should.equal(fragment);
137
153
  });
138
154
 
139
155
  it('verticalLevel=2 and visibleLevel=3', function () {
140
- var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
141
- '<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div>' +
142
- '<i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes vertical">' +
143
- '<li class="hierarchy"><div class="node"><div class="title">Bo Miao</div></div></li>' +
144
- '<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
145
- '<i class="toggleBtn oci"></i></div><ul class="nodes">' +
146
- '<li class="hierarchy"><div class="node"><div class="title">Tie Hua</div></div>' +
147
- '</li><li class="hierarchy"><div class="node"><div class="title">Hei Hei</div></div>' +
148
- '</li></ul></li></ul></li></ul></div>';
149
- oc = $container.orgchart({
156
+ const fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy"><div class="node" tabindex="0"><div class="title' +
157
+ '"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div></div><ul class="nodes vertical"><li class="hierar' +
158
+ 'chy"><div class="node" tabindex="0"><div class="title">Bo Miao</div></div></li><li class="hierarchy"><div clas' +
159
+ 's="node" tabindex="0"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div></div><ul c' +
160
+ 'lass="nodes"><li class="hierarchy"><div class="node" tabindex="0"><div class="title">Tie Hua</div></div></li><' +
161
+ 'li class="hierarchy"><div class="node" tabindex="0"><div class="title">Hei Hei</div></div></li></ul></li></ul>' +
162
+ '</li></ul></div>';
163
+ oc = new OrgChart({
164
+ chartContainer: '#chart-container',
150
165
  'data': ds,
151
166
  'verticalLevel': 2,
152
167
  'visibleLevel': 3
153
168
  });
154
- $container.html().should.equal(fragment);
169
+ container.innerHTML.should.equal(fragment);
155
170
  });
156
171
  });
157
172
 
158
173
  it('initCompleted should be invoked immediately after construting one node', function () {
159
- var spy = sinon.spy();
160
- oc = $container.orgchart({
174
+ const spy = sinon.spy();
175
+ oc = new OrgChart({
176
+ chartContainer: '#chart-container',
161
177
  'data': ds,
162
178
  'createNode': spy
163
179
  });
164
180
  spy.should.have.been.callCount(3);
165
- spy.should.have.been.calledWithMatch($('#n1'),{ 'id': 'n1', 'name': 'Lao Lao' });
166
- spy.should.have.been.calledWithMatch($('#n2'),{ 'id': 'n2', 'name': 'Bo Miao' });
167
- spy.should.have.been.calledWithMatch($('#n3'),{ 'id': 'n3', 'name': 'Su Miao' });
181
+ spy.getCall(0).args[0].id.should.equal('n1');
182
+ spy.getCall(0).args[1].id.should.equal('n1');
183
+ spy.getCall(1).args[0].id.should.equal('n2');
184
+ spy.getCall(1).args[1].id.should.equal('n2');
185
+ spy.getCall(2).args[0].id.should.equal('n3');
186
+ spy.getCall(2).args[1].id.should.equal('n3');
168
187
  // spy.should.always.have.been.calledOn(oc);
169
188
  });
170
189
 
190
+ it('renders custom data fields and invokes createNode after the node markup is built', function () {
191
+ const createNode = sinon.spy(function (nodeElement, data) {
192
+ nodeElement.setAttribute('data-role', data.role);
193
+ });
194
+
195
+ oc = new OrgChart({
196
+ chartContainer: '#chart-container',
197
+ data: {
198
+ key: 'n1',
199
+ label: 'Director',
200
+ role: 'Operations',
201
+ children: [{ key: 'n2', label: 'Engineer', role: 'Platform' }]
202
+ },
203
+ nodeId: 'key',
204
+ nodeTitle: 'label',
205
+ nodeContent: 'role',
206
+ createNode: createNode
207
+ });
208
+
209
+ query('#n1 .title', oc.chart).textContent.should.equal('Director');
210
+ query('#n1 .content', oc.chart).textContent.should.equal('Operations');
211
+ query('#n2', oc.chart).getAttribute('data-role').should.equal('Platform');
212
+ createNode.should.have.been.calledTwice;
213
+ createNode.firstCall.args[0].querySelector('.title').textContent.should.equal('Director');
214
+ });
215
+
216
+ it('renders custom node templates instead of the default title and content markup', function () {
217
+ oc = new OrgChart({
218
+ chartContainer: '#chart-container',
219
+ data: ds,
220
+ nodeTemplate: function (data) {
221
+ return '<section class="employee-card" data-name="' + data.name + '">' + data.name + '</section>';
222
+ }
223
+ });
224
+
225
+ query('#n1 .employee-card', oc.chart).getAttribute('data-name').should.equal('Lao Lao');
226
+ query('#n2 .employee-card', oc.chart).textContent.should.equal('Bo Miao');
227
+ should.not.exist(query('#n1 > .title', oc.chart));
228
+ });
229
+
230
+ it('dispatches init.orgchart after initCompleted receives the rendered chart', function (done) {
231
+ const initCompleted = sinon.spy(function (chartElement) {
232
+ chartElement.addEventListener('init.orgchart', function () {
233
+ initCompleted.should.have.been.calledOnce;
234
+ initCompleted.firstCall.args[0].should.equal(chartElement);
235
+ done();
236
+ }, { once: true });
237
+ });
238
+
239
+ oc = new OrgChart({
240
+ chartContainer: '#chart-container',
241
+ data: ds,
242
+ initCompleted: initCompleted
243
+ });
244
+ });
245
+
171
246
  it('initialize chart with default className', function () {
172
- oc = $container.orgchart({
247
+ oc = new OrgChart({
248
+ chartContainer: '#chart-container',
173
249
  'data': ds,
174
250
  'chartClass': 'demo'
175
251
  });
176
- oc.$chart.is('.demo').should.be.true;
252
+ oc.chart.classList.contains('demo').should.be.true;
177
253
  });
178
254
 
179
255
  it('initialize chart with export button', function () {
180
- oc = $container.orgchart({
256
+ oc = new OrgChart({
257
+ chartContainer: '#chart-container',
181
258
  'data': ds,
182
259
  'exportButton': true
183
260
  });
184
- $('.oc-export-btn').prop('outerHTML').should.equal('<button class="oc-export-btn">Export</button>');
261
+ query('.oc-export-btn').outerHTML.should.equal('<button class="oc-export-btn">Export</button>');
185
262
  });
186
263
 
187
264
  it('initialize chart with "bottom to top" direction', function () {
188
- oc = $container.orgchart({
265
+ oc = new OrgChart({
266
+ chartContainer: '#chart-container',
189
267
  'data': ds,
190
268
  'direction': 'b2t'
191
269
  });
192
- oc.$chart.is('.b2t').should.be.true;
270
+ oc.chart.classList.contains('b2t').should.be.true;
271
+ });
272
+
273
+ it('applies horizontal direction classes', function () {
274
+ oc = new OrgChart({
275
+ chartContainer: '#chart-container',
276
+ data: ds,
277
+ direction: 'l2r'
278
+ });
279
+ oc.chart.classList.contains('l2r').should.be.true;
280
+
281
+ oc.init({ direction: 'r2l' });
282
+ oc.chart.classList.contains('r2l').should.be.true;
283
+ oc.chart.classList.contains('l2r').should.be.false;
193
284
  });
194
285
 
195
286
  it('reinitialize chart with drggable feature', function () {
196
- oc = $container.orgchart({
287
+ oc = new OrgChart({
288
+ chartContainer: '#chart-container',
197
289
  'data': ds
198
290
  });
199
- var spy = sinon.spy(oc, 'bindDragDrop');
291
+ const spy = sinon.spy(oc, 'bindDragDrop');
200
292
  oc.init({ 'draggable': true });
201
293
  spy.should.have.been.callCount(3);
202
- spy.should.have.been.calledWith($('#n1'));
203
- spy.should.have.been.calledWithMatch($('#n2'));
204
- spy.should.have.been.calledWithMatch($('#n3'));
294
+ spy.getCall(0).args[0].id.should.equal('n1');
295
+ spy.getCall(1).args[0].id.should.equal('n2');
296
+ spy.getCall(2).args[0].id.should.equal('n3');
205
297
  });
206
298
 
207
299
  it('reinitialize chart with pan feature', function () {
208
- oc = $container.orgchart({
300
+ oc = new OrgChart({
301
+ chartContainer: '#chart-container',
209
302
  'data': ds
210
303
  });
211
- var spy = sinon.spy(oc, 'bindPan');
304
+ const spy = sinon.spy(oc, 'bindPan');
212
305
  oc.init({ 'pan': true });
213
306
  spy.should.have.been.callCount(1);
214
307
  });
215
308
 
216
309
  it('reinitialize chart with zoom feature', function () {
217
- oc = $container.orgchart({
310
+ oc = new OrgChart({
311
+ chartContainer: '#chart-container',
218
312
  'data': ds
219
313
  });
220
- var spy = sinon.spy(oc, 'bindZoom');
314
+ const spy = sinon.spy(oc, 'bindZoom');
221
315
  oc.init({ 'zoom': true });
222
316
  spy.should.have.been.callCount(1);
223
317
  });
224
318
  });
225
-
226
- });
319
+ });