This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test DevelopmentServerPane component (#359)
- Loading branch information
1 parent
c84c992
commit 39a565e
Showing
3 changed files
with
154 additions
and
1 deletion.
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
61 changes: 61 additions & 0 deletions
61
src/components/DevelopmentServerPane/DevelopmentServerPane.test.js
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,61 @@ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import lolex from 'lolex'; | ||
|
||
import { DevelopmentServerPane } from './DevelopmentServerPane'; | ||
|
||
describe('DevelopmentServerPane component', () => { | ||
let wrapper; | ||
let instance; | ||
lolex.install(); | ||
|
||
const task = { | ||
name: 'start', | ||
status: 'idle', | ||
}; | ||
|
||
const project = { | ||
id: 'a-project', | ||
type: 'create-react-app', | ||
}; | ||
|
||
const mockActions = { | ||
launchDevServer: jest.fn(), | ||
abortTask: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
wrapper = shallow( | ||
<DevelopmentServerPane task={task} project={project} {...mockActions} /> | ||
); | ||
instance = wrapper.instance(); | ||
}); | ||
|
||
describe('Rendering', () => { | ||
it('should render', () => { | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should return message if no tasks', () => { | ||
wrapper = shallow(<DevelopmentServerPane />); | ||
expect(wrapper.text()).toMatch(/This project does not appear/); | ||
}); | ||
}); | ||
|
||
describe('Component logic', () => { | ||
it('should start devServer', () => { | ||
instance.handleToggle(true); | ||
expect(mockActions.launchDevServer).toBeCalledWith(task, new Date()); | ||
}); | ||
|
||
it('should abort task', () => { | ||
instance.handleToggle(false); | ||
expect(mockActions.abortTask).toBeCalledWith( | ||
task, | ||
project.type, | ||
new Date() | ||
); | ||
}); | ||
}); | ||
}); |
92 changes: 92 additions & 0 deletions
92
src/components/DevelopmentServerPane/__snapshots__/DevelopmentServerPane.test.js.snap
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,92 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DevelopmentServerPane component Rendering should render 1`] = ` | ||
<Pane | ||
moreInfoHref="https://github.com/joshwcomeau/guppy/blob/master/docs/getting-started.md#development-server" | ||
primaryActionChildren={ | ||
<Toggle | ||
isToggled={false} | ||
onToggle={[Function]} | ||
padding={2} | ||
size={32} | ||
/> | ||
} | ||
title="Development Server" | ||
> | ||
<OnlyOn | ||
display="inline" | ||
size="mdMin" | ||
> | ||
<styled.div> | ||
<styled.div> | ||
<styled.div> | ||
Runs a local development server that updates whenever you make changes to the files. | ||
</styled.div> | ||
<DevelopmentServerStatus | ||
status="idle" | ||
/> | ||
<styled.div> | ||
<ExternalLink | ||
color="#304FFE" | ||
display="inline-block" | ||
hoverColor="#3f6cff" | ||
href="https://github.com/facebook/create-react-app#user-guide" | ||
> | ||
View Documentation | ||
</ExternalLink> | ||
</styled.div> | ||
</styled.div> | ||
<styled.div> | ||
<Connect(TerminalOutput) | ||
height={300} | ||
task={ | ||
Object { | ||
"name": "start", | ||
"status": "idle", | ||
} | ||
} | ||
title="Server Logs" | ||
/> | ||
</styled.div> | ||
</styled.div> | ||
</OnlyOn> | ||
<OnlyOn | ||
display="inline" | ||
size="sm" | ||
> | ||
<styled.div> | ||
<styled.div> | ||
<styled.div> | ||
<styled.div> | ||
Runs a local development server that updates whenever you make changes to the files. | ||
</styled.div> | ||
<styled.div | ||
size={10} | ||
/> | ||
<styled.div> | ||
<ExternalLink | ||
color="#304FFE" | ||
display="inline-block" | ||
hoverColor="#3f6cff" | ||
href="https://github.com/facebook/create-react-app#user-guide" | ||
> | ||
View Documentation | ||
</ExternalLink> | ||
</styled.div> | ||
</styled.div> | ||
</styled.div> | ||
<styled.div> | ||
<Connect(TerminalOutput) | ||
height={300} | ||
task={ | ||
Object { | ||
"name": "start", | ||
"status": "idle", | ||
} | ||
} | ||
/> | ||
</styled.div> | ||
</styled.div> | ||
</OnlyOn> | ||
</Pane> | ||
`; |