Skip to content

Commit

Permalink
Added module aliases (#2436)
Browse files Browse the repository at this point in the history
* Added module aliases

- Added module alias for `core/ui`
- Added module alias for `core/router`

* Revert jest module name mapper

* fix tests

- Fixed duplicated mocks warning
- added some new mocks
- fix translaton component test
  • Loading branch information
mikemurray authored Jun 15, 2017
1 parent 9858361 commit 4512d75
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 32 deletions.
12 changes: 11 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"plugins": ["lodash"],
"plugins": [
"lodash",
["module-resolver", {
"root": ["./"],
"alias": {
"underscore": "lodash",
"@reactioncommerce/reaction-ui": "./imports/plugins/core/ui/client/components",
"@reactioncommerce/reaction-router": "./imports/plugins/core/router/lib"
}
}]
],
"presets": ["es2015", "react", "stage-2"]
}
2 changes: 1 addition & 1 deletion client/modules/router/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Router } from "/imports/plugins/core/router/lib";
import { Router } from "@reactioncommerce/reaction-router";

export default Router;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classnames from "classnames/dedupe";
import Avatar from "react-avatar";
import moment from "moment";
import { formatPriceString } from "/client/api";
import { Badge, ClickToCopy, Icon, Translation } from "/imports/plugins/core/ui/client/components";
import { Badge, ClickToCopy, Icon, Translation } from "@reactioncommerce/reaction-ui";
import ProductImage from "./productImage";

class OrdersList extends Component {
Expand Down
4 changes: 0 additions & 4 deletions imports/plugins/core/router/__mocks__/meteor/blaze.js

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions imports/plugins/core/router/__mocks__/meteor/meteor.js

This file was deleted.

Empty file.
Empty file.
9 changes: 0 additions & 9 deletions imports/plugins/core/router/__mocks__/meteor/tracker.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// jest.mock("/client/api", () => {
// return {
// i18next: {
// t: (key, { defaultValue }) => {
// return defaultValue || key;
// }
// }
// };
// });
jest.mock("/client/api", () => {
return {
i18next: {
t: (key, { defaultValue }) => {
return defaultValue || key;
}
}
};
});

import React from "react";
import Translation from "../translation";
Expand Down
2 changes: 2 additions & 0 deletions imports/test-utils/__mocks__/meteor/aldeed-simple-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export class SimpleSchema {
static RegEx = {
Email: ""
}

newContext() {}
}
5 changes: 5 additions & 0 deletions imports/test-utils/__mocks__/meteor/kadira:dochead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const DocHead = {
addMeta: () => {},
removeDocHeadAddedTags: () => {},
setTitle: () => {}
};
5 changes: 5 additions & 0 deletions imports/test-utils/__mocks__/meteor/reactive-dict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class ReactiveDict {
set() {}
get() {}
default() {}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"babel-eslint": "^7.2.1",
"babel-jest": "^20.0.3",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-module-resolver": "^2.7.1",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
Expand Down Expand Up @@ -149,8 +150,7 @@
"^\/imports\/plugins(.*)": "<rootDir>/imports/plugins/$1",
"^\/client\/api(.*)": "<rootDir>/imports/test-utils/__mocks__/client/api$1",
"^meteor/aldeed:simple-schema": "<rootDir>/imports/test-utils/__mocks__/meteor/aldeed-simple-schema",
"^meteor/(.*)": "<rootDir>/imports/test-utils/__mocks__/meteor/$1",
"^meteor/(.*)": "<rootDir>/imports/plugins/core/router/__mocks__/meteor/$1"
"^meteor/(.*)": "<rootDir>/imports/test-utils/__mocks__/meteor/$1"
}
}
}

0 comments on commit 4512d75

Please sign in to comment.