-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c081dbd
commit e50ae3f
Showing
17 changed files
with
451 additions
and
273 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 |
---|---|---|
|
@@ -2,4 +2,4 @@ node_modules | |
dist | ||
coverage | ||
**/*.d.ts | ||
tests | ||
lib |
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
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,32 @@ | ||
import { shallow } from 'enzyme'; | ||
import 'jest'; | ||
import * as React from 'react'; | ||
import * as samplePRs from './sample-responses/samplepr.json'; | ||
import { IBrowserProps, Browser } from '../components/browser/Browser'; | ||
|
||
// Unit tests for PullRequestTab | ||
describe('Browser', () => { | ||
const DEFAULT_PROPS: IBrowserProps = { | ||
commands: {} as any, | ||
docRegistry: {} as any, | ||
prGroups: [ | ||
{ name: 'group1', pullRequests: (samplePRs as any).default }, | ||
{ name: 'group2', pullRequests: (samplePRs as any).default } | ||
] | ||
}; | ||
|
||
// Test render | ||
describe('#render()', () => { | ||
const component = shallow(<Browser {...DEFAULT_PROPS} />); | ||
it('should be a div', () => { | ||
expect(component.find('div')).toHaveLength(1); | ||
expect(component.find('.jp-PullRequestBrowser')).toHaveLength(1); | ||
}); | ||
it('should have a list', () => { | ||
expect(component.find('ul')).toHaveLength(1); | ||
}); | ||
it('should have two BrowserGroup', () => { | ||
expect(component.find('BrowserGroup')).toHaveLength(2); | ||
}); | ||
}); | ||
}); |
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,84 @@ | ||
import { shallow } from 'enzyme'; | ||
import 'jest'; | ||
import * as React from 'react'; | ||
import { | ||
BrowserGroup, | ||
IBrowserGroupProps, | ||
} from '../components/browser/BrowserGroup'; | ||
import { PullRequestItem } from '../components/browser/PullRequestItem'; | ||
import * as samplePRs from './sample-responses/samplepr.json'; | ||
|
||
// Unit tests for BrowserGroup | ||
describe('BrowserGroup', () => { | ||
const DEFAULT_PROPS: IBrowserGroupProps = { | ||
commands: {} as any, | ||
docRegistry: {} as any, | ||
group: { name: 'group1', pullRequests: (samplePRs as any).default }, | ||
}; | ||
|
||
// Test render | ||
describe('#render()', () => { | ||
it('should be a list item', () => { | ||
const component = shallow(<BrowserGroup {...DEFAULT_PROPS} />); | ||
expect(component.find('li')).toHaveLength(1); | ||
expect(component.find('.jp-PullRequestBrowserGroup')).toHaveLength(1); | ||
}); | ||
|
||
it('should have a header with text props.header', () => { | ||
const component = shallow(<BrowserGroup {...DEFAULT_PROPS} />); | ||
expect(component.find('header h2')).toHaveLength(1); | ||
expect(component.contains([<h2>{DEFAULT_PROPS.group.name}</h2>])).toEqual( | ||
true | ||
); | ||
}); | ||
|
||
it('should load group', () => { | ||
const component = shallow(<BrowserGroup {...DEFAULT_PROPS} />); | ||
|
||
expect(component.find('.jp-PullRequestBrowserGroupError')).toHaveLength( | ||
0 | ||
); | ||
expect(component.find('ul')).toHaveLength(1); | ||
expect(component.find('.jp-PullRequestBrowserGroupList')).toHaveLength(1); | ||
}); | ||
|
||
it('should load list item prs', () => { | ||
const component = shallow(<BrowserGroup {...DEFAULT_PROPS} />); | ||
expect(component.find(PullRequestItem)).toHaveLength(1); | ||
}); | ||
|
||
it('should not have a group if there is an error', () => { | ||
const component = shallow( | ||
<BrowserGroup | ||
{...DEFAULT_PROPS} | ||
group={{ | ||
name: 'error', | ||
pullRequests: [], | ||
error: 'There is an error', | ||
}} | ||
/> | ||
); | ||
expect(component.find('ul')).toHaveLength(0); | ||
expect(component.find('.jp-PullRequestBrowserGroupList')).toHaveLength(0); | ||
}); | ||
|
||
it('should display error if one exists', () => { | ||
const error = 'There is an error'; | ||
const component = shallow( | ||
<BrowserGroup | ||
{...DEFAULT_PROPS} | ||
group={{ | ||
name: 'error', | ||
pullRequests: [], | ||
error, | ||
}} | ||
/> | ||
); | ||
|
||
expect(component.find('.jp-PullRequestBrowserGroupError')).toHaveLength( | ||
1 | ||
); | ||
expect(component.contains(error)).toEqual(true); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.