-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from selvagsz/tests
Tests
- Loading branch information
Showing
11 changed files
with
305 additions
and
4,843 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# output | ||
lib/ | ||
coverage/ | ||
|
||
# dependencies | ||
/node_modules | ||
|
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- "6" | ||
- "4" | ||
- "5" | ||
- stable | ||
script: | ||
- npm test | ||
after_success: 'npm run coveralls' |
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
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
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,35 @@ | ||
/* global describe, it, expect */ | ||
import { classNames } from '../utils'; | ||
|
||
describe('Utils - classNames', () => { | ||
it('Should return empty string when falsy class names are passed', () => { | ||
let emptyKlassName; | ||
let falsyKlassName = false; | ||
let falsyKlassObject = { | ||
loading: false, | ||
pending: false, | ||
rejected: false, | ||
}; | ||
|
||
expect(classNames(emptyKlassName)).toBe(''); | ||
expect(classNames(falsyKlassName)).toBe(''); | ||
expect(classNames(falsyKlassObject)).toBe(''); | ||
expect(classNames(emptyKlassName, falsyKlassName, falsyKlassObject)).toBe( | ||
'' | ||
); | ||
}); | ||
|
||
it('Should return comma separated classes when valid classNames are passed', () => { | ||
let klassName = 'AsyncButton'; | ||
let klassObject = { | ||
loading: false, | ||
pending: true, | ||
rejected: true, | ||
}; | ||
|
||
expect(classNames(klassName)).toBe('AsyncButton'); | ||
expect(classNames(klassName, klassObject)).toBe( | ||
'AsyncButton pending rejected' | ||
); | ||
}); | ||
}); |
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
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
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,36 @@ | ||
import React from 'react'; | ||
import AsyncButton from '../AsyncButton'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
const expectToMatchSnapshot = component => { | ||
expect(renderer.create(component).toJSON()).toMatchSnapshot(); | ||
}; | ||
|
||
describe('<AsyncButton /> Snapshots', () => { | ||
it('should have sane defaults', () => { | ||
expectToMatchSnapshot(<AsyncButton />); | ||
}); | ||
|
||
it('should delegate text, className & disabled props', () => { | ||
expectToMatchSnapshot( | ||
<AsyncButton className="btn btn-default" text="Save" disabled={true} /> | ||
); | ||
}); | ||
}); | ||
|
||
describe('Block form :- <AsyncButton></AsyncButton>', () => { | ||
it('should have sane defaults', () => { | ||
expectToMatchSnapshot(<AsyncButton>Save</AsyncButton>); | ||
}); | ||
|
||
it('should delegate text, className & disabled props', () => { | ||
expectToMatchSnapshot( | ||
<AsyncButton className="btn btn-default" text="Save" disabled={true}> | ||
{({ buttonText, isPending }) => | ||
<span> | ||
{buttonText} | ||
</span>} | ||
</AsyncButton> | ||
); | ||
}); | ||
}); |
Oops, something went wrong.