Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master to fork #1

Merged
merged 3 commits into from
Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/network/modules/components/Edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,15 @@ class Edge {

// handle multiple input cases for color
if (newOptions.color !== undefined && newOptions.color !== null) {
let fromColor = newOptions.color;
const fromColor = util.isString(newOptions.color)
? {
color: newOptions.color,
highlight: newOptions.color,
hover: newOptions.color,
inherit: false,
opacity: 1
}
: newOptions.color;
let toColor = parentOptions.color;

// If passed, fill in values from default options - required in the case of no prototype bridging
Expand Down
85 changes: 85 additions & 0 deletions test/edge-color.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { expect } from "chai";

import Edge from "../lib/network/modules/components/Edge";

describe("Edge color", function(): void {
const setOptions = Edge.prototype.setOptions;

describe("parse options", function(): void {
it("object", function(): void {
const parentOptions = {
color: {
color: "#012345",
highlight: "#012345",
hover: "#012345",
inherit: false,
opacity: 1
}
};
const newOptions = {
color: {
color: "#543210",
highlight: "#654321",
hover: "#765432",
inherit: false,
opacity: 1
}
};
const allowDeletion = false;
const globalOptions = {};
const copyFromGlobals = false;

Edge.parseOptions(
parentOptions,
newOptions,
allowDeletion,
globalOptions,
copyFromGlobals
);

expect(parentOptions)
.to.have.ownProperty("color")
.that.deep.equals({
color: "#543210",
highlight: "#654321",
hover: "#765432",
inherit: false,
opacity: 1
});
});

it("string", function(): void {
const parentOptions = {
color: {
color: "#012345",
highlight: "#123456",
hover: "#234567",
inherit: false,
opacity: 1
}
};
const newOptions = { color: "#543210" };
const allowDeletion = false;
const globalOptions = {};
const copyFromGlobals = false;

Edge.parseOptions(
parentOptions,
newOptions,
allowDeletion,
globalOptions,
copyFromGlobals
);

expect(parentOptions)
.to.have.ownProperty("color")
.that.deep.equals({
color: "#543210",
highlight: "#543210",
hover: "#543210",
inherit: false,
opacity: 1
});
});
});
});
Loading