-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calendar): add test for CalendarD3 component
- Loading branch information
Raphael Benitte
committed
May 11, 2016
1 parent
1ef5b5e
commit d972002
Showing
4 changed files
with
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ describe('<Bubble />', function () { | |
expect(circles.length).toBe(11); | ||
|
||
done(); | ||
}, 4000); | ||
}, 400); | ||
}) | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -44,7 +44,7 @@ describe('<BubbleD3 />', function () { | |
expect(circles.length).toBe(11); | ||
|
||
done(); | ||
}, 4000); | ||
}, 400); | ||
}) | ||
}); | ||
}); |
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,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('<CalendarD3 />', 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(( | ||
<CalendarD3 | ||
width={700} height={400} | ||
margin={{ top: 30, right: 30, bottom: 30, left: 30 }} | ||
from={new Date(2013, 3, 1)} to={new Date(2014, 7, 12)} | ||
transitionDuration={0} | ||
transitionStaggering={0} | ||
/> | ||
), 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(( | ||
<CalendarD3 | ||
width={700} height={400} | ||
margin={{ top: 30, right: 30, bottom: 30, left: 30 }} | ||
from={new Date(2013, 3, 1)} to={new Date(2014, 7, 12)} | ||
transitionDuration={0} | ||
transitionStaggering={0} | ||
/> | ||
), 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(( | ||
<CalendarD3 | ||
width={700} height={400} | ||
margin={{ top: 30, right: 30, bottom: 30, left: 30 }} | ||
from={new Date(2013, 3, 1)} to={new Date(2014, 7, 12)} | ||
transitionDuration={0} | ||
transitionStaggering={0} | ||
/> | ||
), 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(( | ||
<CalendarD3 | ||
width={400} height={700} | ||
margin={{ top: 30, right: 30, bottom: 30, left: 30 }} | ||
from={new Date(2013, 3, 1)} to={new Date(2014, 7, 12)} | ||
direction="vertical" | ||
transitionDuration={0} | ||
transitionStaggering={0} | ||
/> | ||
), node, () => { | ||
setTimeout(() => { | ||
const days = node.getElementsByClassName('nivo_calendar_day'); | ||
expect(days).toNotBe(null); | ||
expect(days.length).toBe(365 * 2); | ||
|
||
done(); | ||
}, 400); | ||
}) | ||
}); | ||
}); |
File renamed without changes.