From d9720021b152a680732be65b8758c15a89629136 Mon Sep 17 00:00:00 2001 From: Raphael Benitte Date: Wed, 11 May 2016 11:38:41 +0900 Subject: [PATCH] feat(calendar): add test for CalendarD3 component --- specs/bubble/Bubble.spec.js | 2 +- specs/bubble/BubbleD3.spec.js | 2 +- specs/calendar/CalendarD3.spec.js | 110 ++++++++++++++++++ ...nsiveCalendar.js => ResponsiveCalendar.js} | 0 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 specs/calendar/CalendarD3.spec.js rename src/components/charts/calendar/{RepsonsiveCalendar.js => ResponsiveCalendar.js} (100%) diff --git a/specs/bubble/Bubble.spec.js b/specs/bubble/Bubble.spec.js index 03c5fea72..c621534e6 100644 --- a/specs/bubble/Bubble.spec.js +++ b/specs/bubble/Bubble.spec.js @@ -44,7 +44,7 @@ describe('', function () { expect(circles.length).toBe(11); done(); - }, 4000); + }, 400); }) }); }); diff --git a/specs/bubble/BubbleD3.spec.js b/specs/bubble/BubbleD3.spec.js index 56391b940..edf8eb45c 100644 --- a/specs/bubble/BubbleD3.spec.js +++ b/specs/bubble/BubbleD3.spec.js @@ -44,7 +44,7 @@ describe('', function () { expect(circles.length).toBe(11); done(); - }, 4000); + }, 400); }) }); }); diff --git a/specs/calendar/CalendarD3.spec.js b/specs/calendar/CalendarD3.spec.js new file mode 100644 index 000000000..17cc259f9 --- /dev/null +++ b/specs/calendar/CalendarD3.spec.js @@ -0,0 +1,110 @@ +/* + * This file is part of the nivo library. + * + * (c) Raphaƫl Benitte + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +'use strict'; + +import expect, { spyOn } from 'expect'; +import React, { Component } from 'react'; +import { render } from 'react-dom'; +import { CalendarD3 } from '../../src/'; + + +describe('', function () { + this.timeout(10000); + + let node; + beforeEach(() => { + node = document.createElement('div'); + document.body.appendChild(node); + }); + + afterEach(() => { + document.body.removeChild(node); + }); + + it('should render all years days', done => { + render(( + + ), node, () => { + setTimeout(() => { + const days = node.getElementsByClassName('nivo_calendar_day'); + expect(days).toNotBe(null); + expect(days.length).toBe(365 * 2); + + done(); + }, 400); + }) + }); + + it('should render all years months', done => { + render(( + + ), node, () => { + setTimeout(() => { + const months = node.getElementsByClassName('nivo_calendar_month'); + expect(months).toNotBe(null); + expect(months.length).toBe(12 * 2); + + done(); + }, 400); + }) + }); + + it('should render a label for each year', done => { + render(( + + ), node, () => { + setTimeout(() => { + const legends = node.getElementsByClassName('nivo_calendar_year_legend'); + expect(legends).toNotBe(null); + expect(legends.length).toBe(2); + + done(); + }, 400); + }) + }); + + it('should support vertical layout', done => { + render(( + + ), node, () => { + setTimeout(() => { + const days = node.getElementsByClassName('nivo_calendar_day'); + expect(days).toNotBe(null); + expect(days.length).toBe(365 * 2); + + done(); + }, 400); + }) + }); +}); diff --git a/src/components/charts/calendar/RepsonsiveCalendar.js b/src/components/charts/calendar/ResponsiveCalendar.js similarity index 100% rename from src/components/charts/calendar/RepsonsiveCalendar.js rename to src/components/charts/calendar/ResponsiveCalendar.js