Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'trunk' of github.com:reactioncommerce/admin-core into t…
Browse files Browse the repository at this point in the history
…runk
  • Loading branch information
mikemurray committed Apr 14, 2020
2 parents ed09389 + be1be13 commit 017aa97
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 18 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const config = require("./package/config/jest.config");
module.exports = {
...config,
setupFiles: [
"<rootDir>/package/config/test-polyfills.js"
"<rootDir>/package/scripts/testPolyfills.js"
],
setupFilesAfterEnv: [
"<rootDir>/package/src/test-utils/setupTests.js"
"<rootDir>/package/scripts/setupTests.js"
]
};
1 change: 0 additions & 1 deletion package/bin/build-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cp -r bin dist
cp -r config dist
cp -r scripts dist
cp -r src/graphql dist
cp -r src/test-utils dist
cp package.json dist
cp README.md dist
cp LICENSE dist
2 changes: 1 addition & 1 deletion package/config/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function (api) {
];

let ignore;
if (process.env.NODE_ENV === "production") {
if (process.env.BABEL_ENV === "production") {
ignore = [
"**/*.test.js",
"__snapshots__",
Expand Down
7 changes: 4 additions & 3 deletions package/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ module.exports = {
"graphql"
],
setupFiles: [
"<rootDir>/node_modules/@reactioncommerce/admin-core/config/test-polyfills.js"
"<rootDir>/node_modules/@reactioncommerce/admin-core/scripts/testPolyfills.js"
],
setupFilesAfterEnv: [
"<rootDir>/node_modules/@reactioncommerce/admin-core/test-utils/setupTests.js"
"<rootDir>/node_modules/@reactioncommerce/admin-core/scripts/setupTests.js"
],
testPathIgnorePatterns: [
"<rootDir>/config/",
"<rootDir>/reports/",
"<rootDir>/bin/",
"<rootDir>/dist/",
"<rootDir>/node_modules/"
"<rootDir>/node_modules/",
"<rootDir>/package/dist/"
],
transform: {
"\\.(gql|graphql)$": "@jagi/jest-transform-graphql",
Expand Down
9 changes: 9 additions & 0 deletions package/scripts/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Add async/await features
// eslint-disable-next-line node/no-extraneous-require
require("regenerator-runtime/runtime");

// add some helpful assertions
require("@testing-library/jest-dom/extend-expect");

// Polyfill fetch
require("unfetch/polyfill");
File renamed without changes.
2 changes: 1 addition & 1 deletion package/src/lib/core/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function registerRoute(route) {
* @returns {undefined}
*/
export function registerSetting(route) {
routes.push({
registerRoute({
...route,
path: `/settings/${route.name}`,
href: `/settings/${route.name || route.href || route.path}`,
Expand Down
47 changes: 47 additions & 0 deletions package/src/lib/core/routes.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable react/no-multi-comp */
/* eslint-disable react/display-name */
import React from "react";
import { registerRoute, registerSetting, routes, defaultRouteGroups } from "./routes";

beforeEach(() => {
// Clear the routes array for each test
routes.splice(0, routes.length);
});

test("should register a route", () => {
registerRoute({
navigationItemLabel: "Test",
path: "/test",
MainComponent: () => (<span>Test Component</span>)
});

expect(routes.length).toEqual(1);
expect(routes[0].navigationItemLabel).toEqual("Test");
expect(typeof routes[0].MainComponent).toEqual("function");
expect(routes[0]).toEqual({
priority: expect.any(Number),
navigationItemLabel: "Test",
path: "/test",
MainComponent: expect.any(Function)
});
});

test("should register a setting route", () => {
registerSetting({
name: "test-setting",
navigationItemLabel: "Test Setting",
MainComponent: () => (<span>Test Component</span>)
});

expect(routes.length).toEqual(1);

expect(routes[0]).toEqual({
priority: expect.any(Number),
name: "test-setting",
group: defaultRouteGroups.settings,
navigationItemLabel: "Test Setting",
path: "/settings/test-setting",
href: "/settings/test-setting",
MainComponent: expect.any(Function)
});
});
2 changes: 0 additions & 2 deletions package/src/lib/graphql/initApollo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ApolloClient } from "apollo-client";
import { ApolloLink } from "apollo-link";
// Polyfill fetch
import "unfetch/polyfill";
import { HttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";

Expand Down
8 changes: 0 additions & 8 deletions package/src/test-utils/setupTests.js

This file was deleted.

0 comments on commit 017aa97

Please sign in to comment.