Skip to content
Snippets Groups Projects
Unverified Commit 8c3e89ff authored by Tom Robinson's avatar Tom Robinson Committed by GitHub
Browse files

Merge pull request #9379 from metabase/upgrade-enzyme

Upgrade Enzyme for unit and integration tests (but not e2e tests)
parents 2bc91086 51651438
Branches
Tags
No related merge requests found
......@@ -44,7 +44,7 @@ export type APIMethod = (d?: Data, o?: Options) => Promise<any>;
export type APICreator = (t: string, o?: Options | TransformFn) => APIMethod;
export class Api extends EventEmitter {
basename: "";
basename = "";
GET: APICreator;
POST: APICreator;
......
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-15";
configure({ adapter: new Adapter() });
......@@ -22,6 +22,6 @@ describe("Button", () => {
it("should render a primary button given the primary prop", () => {
const button = render(<Button primary>Clickity click</Button>);
expect(button.find("button.Button--primary").length).toEqual(1);
expect(button.hasClass("Button--primary")).toBe(true);
});
});
......@@ -20,7 +20,7 @@ describe("AdminPinMessage", () => {
it("should not show the message if the admin has dismissed it", () => {
localStorage.setItem(PIN_MESSAGE_STORAGE_KEY, "true");
const wrapper = shallow(<AdminPinMessage />);
expect(wrapper.getNode(0)).toBe(null);
expect(wrapper.getElement(0)).toBe(null);
});
it("should set the proper local storage key if the dismiss icon is clicked", () => {
......@@ -33,6 +33,6 @@ describe("AdminPinMessage", () => {
PIN_MESSAGE_STORAGE_KEY,
"true",
);
expect(wrapper.getNode(0)).toBe(null);
expect(wrapper.getElement(0)).toBe(null);
});
});
......@@ -34,15 +34,15 @@ describe("DashCard", () => {
it("should render slow card with Card--slow className", () => {
const props = assocIn(DEFAULT_PROPS, ["slowCards", 1], true);
const dashCard = render(<DashCard {...props} />);
expect(dashCard.find(".Card--recent")).toHaveLength(0);
expect(dashCard.find(".Card--unmapped")).toHaveLength(0);
expect(dashCard.find(".Card--slow")).toHaveLength(1);
expect(dashCard.hasClass("Card--recent")).toBe(false);
expect(dashCard.hasClass("Card--unmapped")).toBe(false);
expect(dashCard.hasClass("Card--slow")).toBe(true);
});
it("should render new card with Card--recent className", () => {
const props = assocIn(DEFAULT_PROPS, ["dashcard", "isAdded"], true);
const dashCard = render(<DashCard {...props} />);
expect(dashCard.find(".Card--recent")).toHaveLength(1);
expect(dashCard.find(".Card--unmapped")).toHaveLength(0);
expect(dashCard.find(".Card--slow")).toHaveLength(0);
expect(dashCard.hasClass("Card--recent")).toBe(true);
expect(dashCard.hasClass("Card--unmapped")).toBe(false);
expect(dashCard.hasClass("Card--slow")).toBe(false);
});
});
{
"moduleNameMapper": {
"^enzyme$": "enzyme-2",
"\\.(css|less)$": "<rootDir>/frontend/test/__mocks__/styleMock.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/frontend/test/__mocks__/fileMock.js",
"^promise-loader\\?global\\!metabase\\/lib\\/ga-metadata$": "<rootDir>/frontend/src/metabase/lib/ga-metadata.js"
......
......@@ -17,6 +17,7 @@
],
"setupFiles": [
"<rootDir>/frontend/test/jest-setup.js",
"<rootDir>/frontend/test/enzyme-setup.js",
"<rootDir>/frontend/test/metabase-bootstrap.js"
],
"globals": {
......
......@@ -17,6 +17,7 @@
],
"setupFiles": [
"<rootDir>/frontend/test/jest-setup.js",
"<rootDir>/frontend/test/enzyme-setup.js",
"<rootDir>/frontend/test/metabase-bootstrap.js"
],
"globals": {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment