This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
4 changed files
with
78 additions
and
34 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
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,47 +1,31 @@ | ||
'use strict' | ||
import React from 'react' | ||
import { expect } from 'chai' | ||
import { Link } from 'react-router-dom' | ||
import MenuItem from 'material-ui/MenuItem' | ||
import MenuLink from 'components/elements/MenuLink' | ||
import { shallow } from 'enzyme' | ||
import toJson from 'enzyme-to-json' | ||
require('test/helpers/enableSnapshot') | ||
|
||
describe('MenuLink', function() { | ||
describe('when all input is valid', function() { | ||
describe('MenuLink', function () { | ||
describe('when all input is valid', function () { | ||
const mockTitle = 'mock title' | ||
const mockToolTip = 'mock tool tip' | ||
const mockRoute = '/mock/route' | ||
const mockOnClick = () => 'clicked' | ||
const mockRightIcon = {} | ||
|
||
const result = MenuLink({ | ||
primaryText: mockTitle, | ||
toolTip: mockToolTip, | ||
route: mockRoute, | ||
onClick: mockOnClick, | ||
rightIcon: mockRightIcon | ||
}) | ||
|
||
it('should render a MenuItem', function() { | ||
expect(result.type).to.equal(MenuItem) | ||
}) | ||
|
||
it('should not contain a Link in the primaryText', function() { | ||
expect(result.props.primaryText.type).to.not.equal(Link) | ||
}) | ||
|
||
it('should link to the provided route', function () { | ||
expect(result.props.containerElement.props.to).to.equal(mockRoute) | ||
}) | ||
|
||
it('should display the provided text as primaryText', function () { | ||
expect(result.props.primaryText.props.children).to.contain(mockTitle) | ||
}) | ||
|
||
it('should have a key that is composed of both the route and primaryText', function () { | ||
expect(result.key).to.equal(mockTitle + mockRoute) | ||
}) | ||
|
||
it('should contain the provided rightIcon', function () { | ||
expect(result.props.rightIcon).to.equal(mockRightIcon) | ||
it('should match the snapshot', function () { | ||
const wrapper = shallow( | ||
<MenuLink | ||
primaryText={mockTitle} | ||
toolTip={mockToolTip} | ||
route={mockRoute} | ||
onClick={mockOnClick} | ||
rightIcon={mockRightIcon} | ||
/> | ||
) | ||
|
||
expect(toJson(wrapper)).to.matchSnapshot() | ||
}) | ||
}) | ||
}) |
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,46 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MenuLink when all input is valid should match the snapshot 1`] = ` | ||
<MenuItem | ||
anchorOrigin={ | ||
Object { | ||
"horizontal": "right", | ||
"vertical": "top", | ||
} | ||
} | ||
checked={false} | ||
containerElement={ | ||
<Link | ||
replace={false} | ||
to="/mock/route" | ||
/> | ||
} | ||
desktop={false} | ||
disabled={false} | ||
focusState="none" | ||
insetChildren={false} | ||
key="mock title/mock/route" | ||
onClick={[Function]} | ||
primaryText={ | ||
<div | ||
style={ | ||
Object { | ||
"overflow": "hidden", | ||
"textOverflow": "ellipsis", | ||
"width": "25rem", | ||
} | ||
} | ||
> | ||
mock title | ||
</div> | ||
} | ||
rightIcon={Object {}} | ||
targetOrigin={ | ||
Object { | ||
"horizontal": "left", | ||
"vertical": "top", | ||
} | ||
} | ||
title="mock title" | ||
/> | ||
`; |
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,12 @@ | ||
import chai from 'chai' | ||
import chaiJestSnapshot from 'chai-jest-snapshot' | ||
|
||
chai.use(chaiJestSnapshot) | ||
|
||
before(function () { | ||
chaiJestSnapshot.resetSnapshotRegistry() | ||
}) | ||
|
||
beforeEach(function () { | ||
chaiJestSnapshot.configureUsingMochaContext(this) | ||
}) |