Skip to content

Commit 1fadecd

Browse files
committed
first test of component
1 parent 7b52305 commit 1fadecd

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<a href="https://www.npmjs.com/package/react-scrollbars-custom"><img src="https://img.shields.io/badge/npm-react--scrollbars--custom-brightgreen.svg" /></a>
44
<a href="https://www.npmjs.com/package/react-scrollbars-custom"><img src="https://img.shields.io/npm/l/react-scrollbars-custom.svg" /></a>
55
<a href="https://www.npmjs.com/package/react-scrollbars-custom"><img src="https://img.shields.io/npm/v/react-scrollbars-custom.svg" /></a>
6+
<a href="https://www.codacy.com/app/xobotyi/react-scrollbars-custom"><img src="https://api.codacy.com/project/badge/Grade/f0875490cea1497a9eca9c25f3f7774e"/></a>
67
<a href="https://www.npmjs.com/package/react-scrollbars-custom"><img src="https://img.shields.io/npm/dt/react-scrollbars-custom.svg" /></a>
78
<a></a>
89
</p>

tests/Scrollbar.spec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import { render, unmountComponentAtNode } from 'react-dom';
3+
import { Scrollbar } from "react-scrollbars-custom";
4+
5+
describe('rendering', () => {
6+
let node;
7+
beforeEach(() => {
8+
node = document.createElement('div');
9+
document.body.appendChild(node);
10+
});
11+
afterEach(() => {
12+
unmountComponentAtNode(node);
13+
document.body.removeChild(node);
14+
});
15+
16+
describe("when <Scrollbar /> is rendered", function () {
17+
it('renders tracks', (done) => {
18+
render(<Scrollbar />, node, function () {
19+
expect(this.trackVertical).to.be.an.instanceof(Node);
20+
expect(this.trackHorizontal).to.be.an.instanceof(Node);
21+
22+
done();
23+
});
24+
});
25+
it('renders thumbs', (done) => {
26+
render(<Scrollbar />, node, function () {
27+
expect(this.thumbVertical).to.be.an.instanceof(Node);
28+
expect(this.thumbHorizontal).to.be.an.instanceof(Node);
29+
30+
done();
31+
});
32+
});
33+
it('renders content wrapper', (done) => {
34+
render(<Scrollbar />, node, function () {
35+
expect(this.wrapper).to.be.an.instanceof(Node);
36+
37+
done();
38+
});
39+
});
40+
it('renders content', (done) => {
41+
render(<Scrollbar />, node, function () {
42+
expect(this.content).to.be.an.instanceof(Node);
43+
44+
done();
45+
});
46+
});
47+
});
48+
});

tests/getInnerSizes.spec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,28 @@ describe('getInnerSizes', () => {
1414
});
1515

1616
describe('getInnerHeight()', () => {
17-
it('returns the height of an element without padding', () => {
17+
it('returns the height of an element without padding', (done) => {
1818
render(<div style={ {width: 200, height: 200, padding: 20} } />, node, function () {
1919
expect(getInnerHeight(findDOMNode(this))).to.equal(200);
20+
done();
2021
});
2122
});
2223
});
2324

2425
describe('getInnerWidth()', () => {
25-
it('returns the width of an element without padding', () => {
26+
it('returns the width of an element without padding', (done) => {
2627
render(<div style={ {width: 200, height: 200, padding: 20} } />, node, function () {
2728
expect(getInnerWidth(findDOMNode(this))).to.equal(200);
29+
done();
2830
});
2931
});
3032
});
3133

3234
describe('getInnerSizes()', () => {
33-
it('returns the width and height of an element without padding', () => {
35+
it('returns the width and height of an element without padding', (done) => {
3436
render(<div style={ {width: 200, height: 200, padding: 20} } />, node, function () {
3537
expect(getInnerSizes(findDOMNode(this))).to.deep.equal({width: 200, height: 200});
38+
done();
3639
});
3740
});
3841
});

0 commit comments

Comments
 (0)