-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Chart): Handle nullish properties from API extendings safely
Chart APIs having null/undefined properties should not break the chart construction now Ref #2132
- Loading branch information
Aziz Gazanchiyan (ZIZ)
authored and
Aziz Gazanchiyan (ZIZ)
committed
Jun 11, 2021
1 parent
bf3eb46
commit b4bb414
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2017 ~ present NAVER Corp. | ||
* billboard.js project is licensed under the MIT license | ||
*/ | ||
import {expect} from "chai"; | ||
import {extend} from "../src/module/util"; | ||
|
||
import Chart from "../src/Chart/Chart"; | ||
|
||
describe("Chart", () => { | ||
it("should bind correctly with nullish properties", () => { | ||
const options = { | ||
data: { | ||
columns: [["data1", 0]] | ||
} | ||
}; | ||
|
||
class Extended extends Chart { | ||
nullProperty; | ||
voidProperty; | ||
} | ||
|
||
extend(Chart.prototype, { | ||
nullProperty: null, | ||
voidProperty: undefined | ||
}); | ||
|
||
const extendedInstance = new Chart(options); | ||
|
||
expect((extendedInstance as Extended).nullProperty).to.be.a("null"); | ||
|
||
expect((extendedInstance as Extended).voidProperty).to.be.an("undefined"); | ||
}); | ||
}); |