Skip to content

Commit 44e361d

Browse files
committed
unit tests for sankey link label defaults
1 parent 0f08952 commit 44e361d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/jasmine/tests/sankey_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ describe('sankey tests', function() {
112112
expect(fullTrace.link.target)
113113
.toEqual([], 'presence of link target array is guaranteed');
114114

115+
expect(fullTrace.link.label)
116+
.toEqual([], 'presence of link target array is guaranteed');
115117
});
116118

117119
it('\'Sankey\' specification should have proper types',
@@ -179,6 +181,40 @@ describe('sankey tests', function() {
179181

180182
});
181183

184+
it('fills \'link\' labels if not specified', function() {
185+
186+
var fullTrace = _supply({
187+
node: {
188+
label: ['a', 'b']
189+
},
190+
link: {
191+
source: [0, 1],
192+
target: [1, 0],
193+
value: [1, 2]
194+
}
195+
});
196+
197+
expect(Lib.isArray(fullTrace.link.label)).toBe(true, 'must be an array');
198+
expect(fullTrace.link.label).toEqual(['', ''], 'an array of empty strings');
199+
});
200+
201+
it('preserves \'link\' labels if specified', function() {
202+
203+
var fullTrace = _supply({
204+
node: {
205+
label: ['a', 'b']
206+
},
207+
link: {
208+
source: [0, 1],
209+
target: [1, 0],
210+
value: [1, 2],
211+
label: ['a', 'b']
212+
}
213+
});
214+
215+
expect(Lib.isArray(fullTrace.link.label)).toBe(true, 'must be an array');
216+
expect(fullTrace.link.label).toEqual(['a', 'b'], 'an array of the supplied values');
217+
});
182218
});
183219

184220
describe('sankey calc', function() {

0 commit comments

Comments
 (0)