Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
UM100080 authored and UM100080 committed Jul 11, 2023
1 parent 411c691 commit b18a255
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/carbon-graphs/tests/unit/controls/Graph/GraphAxes-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ describe('Graph - Axes', () => {
expect(y2Ticks).toEqual(expectedY2Ticks);
});

it('tesing filter method for numeric', () => {
it('filters out numeric axis values exceeding upper and lower limits', () => {
const localeAxisObj = utils.deepClone(axisTicks);
localeAxisObj.allowCallibration = false;
localeAxisObj.x = {
Expand All @@ -1237,17 +1237,16 @@ describe('Graph - Axes', () => {
graph = new Graph({ ...getAxes(localeAxisObj) });

const allXAxisElements = document.querySelectorAll(`.${styles.axisX}`);
const xTicks = [];
const expectedXTicks = [2, 3, 4, 5, 6, 7, 8];

for (let i = 1; i < allXAxisElements[0].childNodes.length; i += 1) {
xTicks.push(parseInt(allXAxisElements[0].childNodes[i].querySelector('text').textContent, 10));
}

// using slice method to avoid null ERROR with 'textContent'.
const xTicks = Array.from(allXAxisElements[0].childNodes)
.slice(1)
.map((node) => parseInt(node.querySelector('text').textContent, 10));
expect(xTicks).toEqual(expectedXTicks);
});

it('tesing filter method for DateTicks', () => {
it('filters out datetime axis values exceeding upper and lower limits', () => {
const localeAxisObj = utils.deepClone(axisDateTicks);
localeAxisObj.allowCallibration = false;
localeAxisObj.y = {
Expand All @@ -1265,17 +1264,19 @@ describe('Graph - Axes', () => {

const allXAxisElements = document.querySelectorAll(`.${styles.axisX}`);

const xTicks = [];
const expectedXTicks = [
new Date(2016, 2).toISOString(),
new Date(2016, 3).toISOString(),
new Date(2016, 4).toISOString(),
];
for (let i = 1; i < allXAxisElements[0].childNodes.length; i += 1) {
const { textContent } = allXAxisElements[0].childNodes[i].querySelector('text');
const dateTimeValue = new Date(textContent).toISOString();
xTicks.push(dateTimeValue);
}
// using slice method to avoid null ERROR with 'textContent'.
const xTicks = Array.from(allXAxisElements[0].childNodes)
.slice(1)
.map((childNode) => {
const { textContent } = childNode.querySelector('text');
const dateTimeValue = new Date(textContent).toISOString();
return dateTimeValue;
});
expect(xTicks).toEqual(expectedXTicks);
});
it('uses default method for Y ans Y2 tick values when custom ticks and ticksCount are not provided', () => {
Expand Down

0 comments on commit b18a255

Please sign in to comment.