File tree 4 files changed +1702
-32
lines changed
lib/network/modules/components
4 files changed +1702
-32
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,15 @@ class Edge {
202
202
203
203
// handle multiple input cases for color
204
204
if ( newOptions . color !== undefined && newOptions . color !== null ) {
205
- let fromColor = newOptions . color ;
205
+ const fromColor = util . isString ( newOptions . color )
206
+ ? {
207
+ color : newOptions . color ,
208
+ highlight : newOptions . color ,
209
+ hover : newOptions . color ,
210
+ inherit : false ,
211
+ opacity : 1
212
+ }
213
+ : newOptions . color ;
206
214
let toColor = parentOptions . color ;
207
215
208
216
// If passed, fill in values from default options - required in the case of no prototype bridging
Original file line number Diff line number Diff line change
1
+ import { expect } from "chai" ;
2
+
3
+ import Edge from "../lib/network/modules/components/Edge" ;
4
+
5
+ describe ( "Edge color" , function ( ) : void {
6
+ const setOptions = Edge . prototype . setOptions ;
7
+
8
+ describe ( "parse options" , function ( ) : void {
9
+ it ( "object" , function ( ) : void {
10
+ const parentOptions = {
11
+ color : {
12
+ color : "#012345" ,
13
+ highlight : "#012345" ,
14
+ hover : "#012345" ,
15
+ inherit : false ,
16
+ opacity : 1
17
+ }
18
+ } ;
19
+ const newOptions = {
20
+ color : {
21
+ color : "#543210" ,
22
+ highlight : "#654321" ,
23
+ hover : "#765432" ,
24
+ inherit : false ,
25
+ opacity : 1
26
+ }
27
+ } ;
28
+ const allowDeletion = false ;
29
+ const globalOptions = { } ;
30
+ const copyFromGlobals = false ;
31
+
32
+ Edge . parseOptions (
33
+ parentOptions ,
34
+ newOptions ,
35
+ allowDeletion ,
36
+ globalOptions ,
37
+ copyFromGlobals
38
+ ) ;
39
+
40
+ expect ( parentOptions )
41
+ . to . have . ownProperty ( "color" )
42
+ . that . deep . equals ( {
43
+ color : "#543210" ,
44
+ highlight : "#654321" ,
45
+ hover : "#765432" ,
46
+ inherit : false ,
47
+ opacity : 1
48
+ } ) ;
49
+ } ) ;
50
+
51
+ it ( "string" , function ( ) : void {
52
+ const parentOptions = {
53
+ color : {
54
+ color : "#012345" ,
55
+ highlight : "#123456" ,
56
+ hover : "#234567" ,
57
+ inherit : false ,
58
+ opacity : 1
59
+ }
60
+ } ;
61
+ const newOptions = { color : "#543210" } ;
62
+ const allowDeletion = false ;
63
+ const globalOptions = { } ;
64
+ const copyFromGlobals = false ;
65
+
66
+ Edge . parseOptions (
67
+ parentOptions ,
68
+ newOptions ,
69
+ allowDeletion ,
70
+ globalOptions ,
71
+ copyFromGlobals
72
+ ) ;
73
+
74
+ expect ( parentOptions )
75
+ . to . have . ownProperty ( "color" )
76
+ . that . deep . equals ( {
77
+ color : "#543210" ,
78
+ highlight : "#543210" ,
79
+ hover : "#543210" ,
80
+ inherit : false ,
81
+ opacity : 1
82
+ } ) ;
83
+ } ) ;
84
+ } ) ;
85
+ } ) ;
You can’t perform that action at this time.
0 commit comments