Skip to main content

Unit test plan for Donut Chart

This test plan contains the list of unit testable functions which are used as a part of the Donut Chart component.

Identify the functions that can be unit tested (example, functions having calculations or getting values from Utils, etc).

  • If required, extract the unit testable portions out of the functions which can be independently unit tested without any requirement of DOM elements.
  • Alternatively, mock the sections that cannot be unit tested.
FunctionsCan it be unit testedReason
a. convertToLocaleString()Yes
b.getAccessibleDataObject()Yes
c. _valueInsideDonut()Noprivate function which can only be tested by rendering the donut chart component.
d. wrapTextInsideDonut()Nocannot be unit tested as it requires the tspan length to be calculated using Browser Functions like getComputedTextLength().
e. _computeTotalValue()Nodepends on the data prop passed down from the DonutChart.base to Pie during component rendering. Also since this is a private function, it can only be tested via component rendering.