Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Test DevelopmentServerPane component #359

Merged
merged 2 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Props = {
abortTask: Dispatch<typeof actions.abortTask>,
};

class DevelopmentServerPane extends PureComponent<Props> {
export class DevelopmentServerPane extends PureComponent<Props> {
handleToggle = (isToggled: boolean) => {
const { task, launchDevServer, abortTask, project } = this.props;

Expand Down
61 changes: 61 additions & 0 deletions src/components/DevelopmentServerPane/DevelopmentServerPane.test.js
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()
);
});
});
});
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>
`;
1 change: 0 additions & 1 deletion src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ const Wrapper = animated(styled.nav.attrs({
${COLORS.blue[900]},
${COLORS.blue[700]}
);
transform: translateX(${props => props.offset});
will-change: transform;
height: 100vh;
`);
Expand Down