forked from vkbansal/react-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate enzyme tests to testing-library #52
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
03afac5
Add new packages
julienw db3101c
Configure eslint for the new eslint packages
julienw 4fc7c40
Simple eslint fixes
julienw 5ecc0dc
Move from the deprecated keyCode to key for keyboard events
julienw c16bd75
Migrate tests to testing-library
julienw 48fe4b1
Remove enzyme packages
julienw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,51 +1,51 @@ | ||
"use strict"; | ||
|
||
import React from "react"; | ||
import { shallow, mount } from "enzyme"; | ||
import { expect } from "chai"; | ||
|
||
import SubMenu from "../src/submenu"; | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
|
||
describe("<SubMenu/>", () => { | ||
it("should have `react-context-menu-item` & `submenu` classes", () => { | ||
const wrapper = shallow(<SubMenu title="foo"/>); | ||
import SubMenu from '../src/submenu'; | ||
|
||
expect(wrapper).to.have.className("react-context-menu-item"); | ||
expect(wrapper).to.have.className("submenu"); | ||
describe('<SubMenu/>', () => { | ||
it('should have `react-context-menu-item` & `submenu` classes', () => { | ||
const wrapper = shallow(<SubMenu title='foo' />); | ||
|
||
expect(wrapper).to.have.className('react-context-menu-item'); | ||
expect(wrapper).to.have.className('submenu'); | ||
}); | ||
|
||
it("<a/> should have `react-context-menu-link` class", () => { | ||
const wrapper = shallow(<SubMenu title="foo"/>); | ||
it('<a/> should have `react-context-menu-link` class', () => { | ||
const wrapper = shallow(<SubMenu title='foo' />); | ||
|
||
expect(wrapper.find("a")).to.have.className("react-context-menu-link"); | ||
expect(wrapper.find("a")).to.not.have.className("disabled"); | ||
expect(wrapper.find('a')).to.have.className('react-context-menu-link'); | ||
expect(wrapper.find('a')).to.not.have.className('disabled'); | ||
}); | ||
|
||
it("<a/> should have `disabled` class when disabled", () => { | ||
const wrapper = shallow(<SubMenu title="foo" disabled/>); | ||
it('<a/> should have `disabled` class when disabled', () => { | ||
const wrapper = shallow(<SubMenu title='foo' disabled />); | ||
|
||
expect(wrapper.find("a")).to.have.className("react-context-menu-link"); | ||
expect(wrapper.find("a")).to.have.className("disabled"); | ||
expect(wrapper.find('a')).to.have.className('react-context-menu-link'); | ||
expect(wrapper.find('a')).to.have.className('disabled'); | ||
}); | ||
|
||
it("should render `title` inside `<a/>`", () => { | ||
const title = Math.random().toString(36), | ||
wrapper = shallow(<SubMenu title={title} disabled/>); | ||
it('should render `title` inside `<a/>`', () => { | ||
const title = Math.random().toString(36); | ||
const wrapper = shallow(<SubMenu title={title} disabled />); | ||
|
||
expect(wrapper.find("a")).to.have.text(title); | ||
expect(wrapper.find('a')).to.have.text(title); | ||
}); | ||
|
||
xit("should open submenu `onMouseEnter`", function() { | ||
const wrapper = mount(<SubMenu title="foo" hoverDelay={0}/>); | ||
xit('should open submenu `onMouseEnter`', function () { | ||
const wrapper = mount(<SubMenu title='foo' hoverDelay={0} />); | ||
|
||
wrapper.find(".submenu").simulate("mouseEnter"); | ||
expect(wrapper).to.have.state("visible", true); | ||
wrapper.find('.submenu').simulate('mouseEnter'); | ||
expect(wrapper).to.have.state('visible', true); | ||
}); | ||
|
||
xit("should not open submenu `onMouseEnter` when disabled", function() { | ||
const wrapper = mount(<SubMenu title="foo" hoverDelay={0} disabled/>); | ||
xit('should not open submenu `onMouseEnter` when disabled', function () { | ||
const wrapper = mount(<SubMenu title='foo' hoverDelay={0} disabled />); | ||
|
||
wrapper.simulate("mouseenter"); | ||
expect(wrapper).to.have.state("visible", false); | ||
wrapper.simulate('mouseenter'); | ||
expect(wrapper).to.have.state('visible', false); | ||
}); | ||
}); |
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,29 +1,29 @@ | ||
"use strict"; | ||
|
||
import React from "react"; | ||
import { shallow, mount } from "enzyme"; | ||
|
||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
// import sinon from "sinon"; | ||
import { expect } from "chai"; | ||
import { expect } from 'chai'; | ||
|
||
import SubMenuWrapper from "../src/submenu/wrapper"; | ||
import SubMenuWrapper from '../src/submenu/wrapper'; | ||
// import monitor from "../src/monitor"; | ||
|
||
describe("<SubMenuWrapper/>", () => { | ||
it("should have `react-context-menu` class", () => { | ||
const wrapper = shallow(<SubMenuWrapper/>); | ||
describe('<SubMenuWrapper/>', () => { | ||
it('should have `react-context-menu` class', () => { | ||
const wrapper = shallow(<SubMenuWrapper />); | ||
|
||
expect(wrapper.hasClass("react-context-menu")).to.equal(true); | ||
expect(wrapper.hasClass('react-context-menu')).to.equal(true); | ||
}); | ||
|
||
it("should be invisible by default", () => { | ||
const wrapper = mount(<SubMenuWrapper/>); | ||
it('should be invisible by default', () => { | ||
const wrapper = mount(<SubMenuWrapper />); | ||
|
||
expect(wrapper.find("nav")).to.have.style("display", "none"); | ||
expect(wrapper.find('nav')).to.have.style('display', 'none'); | ||
}); | ||
|
||
it("should be visible when `visible` is passed", () => { | ||
const wrapper = mount(<SubMenuWrapper visible/>); | ||
it('should be visible when `visible` is passed', () => { | ||
const wrapper = mount(<SubMenuWrapper visible />); | ||
|
||
expect(wrapper.find("nav")).to.have.style("display", "block"); | ||
expect(wrapper.find('nav')).to.have.style('display', 'block'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curiously the test files weren't checked by eslint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting. Thanks for adding them!