From 4a60bfa8ed2bd0767e6296005c8dff7493a6d889 Mon Sep 17 00:00:00 2001 From: John Edward Date: Mon, 26 Mar 2018 18:20:17 +0800 Subject: [PATCH] updated test setup and container components --- .meteor/packages | 2 +- .meteor/versions | 4 ++-- imports/ui/components/dashboard/dashboard.js | 6 +++--- imports/ui/components/index.js | 6 +++--- package.json | 8 +++++--- test/client/components/index.spec.js | 6 +++++- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.meteor/packages b/.meteor/packages index 1e78916..63a12d5 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -24,5 +24,5 @@ accounts-password@1.5.0 alanning:roles accounts-base@1.4.2 shell-server@0.3.1 -dispatch:mocha dynamic-import +meteortesting:mocha diff --git a/.meteor/versions b/.meteor/versions index 416ead6..f07c9b1 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,7 +1,6 @@ accounts-base@1.4.2 accounts-password@1.5.1 alanning:roles@1.2.16 -aldeed:browser-tests@0.1.1 allow-deny@1.1.0 autoupdate@1.4.0 babel-compiler@7.0.5 @@ -23,7 +22,6 @@ ddp-rate-limiter@1.0.7 ddp-server@2.1.2 deps@1.0.12 diff-sequence@1.1.0 -dispatch:mocha@0.4.1 dynamic-import@0.3.0 ecmascript@0.10.5 ecmascript-runtime@0.5.0 @@ -46,6 +44,8 @@ localstorage@1.2.0 logging@1.1.19 meteor@1.8.4 meteor-base@1.3.0 +meteortesting:browser-tests@0.1.2 +meteortesting:mocha@0.5.0 minifier-css@1.3.1 minifier-js@2.3.3 minimongo@1.4.3 diff --git a/imports/ui/components/dashboard/dashboard.js b/imports/ui/components/dashboard/dashboard.js index 7679d52..b110ceb 100644 --- a/imports/ui/components/dashboard/dashboard.js +++ b/imports/ui/components/dashboard/dashboard.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { createContainer } from 'meteor/react-meteor-data'; +import { withTracker } from 'meteor/react-meteor-data'; import SideBar from './sidebar/sidebar'; import AppHeader from '../app/app_header'; @@ -43,7 +43,7 @@ Dashboard.propTypes = { users: PropTypes.arrayOf(PropTypes.object), }; -export default createContainer(() => { +export default withTracker(() => { /** * Add subscription here */ @@ -53,4 +53,4 @@ export default createContainer(() => { currentUser: Meteor.user(), users: Meteor.users.find().fetch(), }; -}, Dashboard); +})(Dashboard); diff --git a/imports/ui/components/index.js b/imports/ui/components/index.js index 8c32402..efc777b 100644 --- a/imports/ui/components/index.js +++ b/imports/ui/components/index.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { createContainer } from 'meteor/react-meteor-data'; +import { withTracker } from 'meteor/react-meteor-data'; import Loading from '../layouts/loading/loading'; class Index extends Component { @@ -36,6 +36,6 @@ Index.propTypes = { currentUser: PropTypes.object, }; -export default createContainer(() => ({ +export default withTracker(() => ({ currentUser: Meteor.user(), -}), Index); +}))(Index); diff --git a/package.json b/package.json index 4aa1752..6ea53f7 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,9 @@ "version": "2.0.0", "scripts": { "start": "meteor run", - "test": "TEST_BROWSER_DRIVER=phantomjs meteor test --once --driver-package dispatch:mocha", - "test:watch": "TEST_WATCH=1 TEST_BROWSER_DRIVER=phantomjs meteor test --driver-package dispatch:mocha", + "pretest": "npm run lint --silent", + "test": "TEST_BROWSER_DRIVER=phantomjs meteor test --once --driver-package meteortesting:mocha", + "test:watch": "TEST_BROWSER_DRIVER=phantomjs TEST_WATCH=1 meteor test --driver-package meteortesting:mocha", "lint": "eslint --ignore-path .eslintignore ." }, "dependencies": { @@ -23,13 +24,14 @@ "devDependencies": { "chai": "^4.1.2", "enzyme": "^3.3.0", + "enzyme-adapter-react-16": "^1.1.1", "eslint": "4.18.2", "eslint-config-airbnb": "16.1.0", "eslint-plugin-import": "2.9.0", "eslint-plugin-jsx-a11y": "6.0.3", "eslint-plugin-react": "7.7.0", "eslint-watch": "3.1.3", - "phantomjs-prebuilt": "^2.1.14", + "phantomjs-prebuilt": "^2.1.16", "pre-commit": "^1.1.3", "react-addons-test-utils": "^15.4.2" }, diff --git a/test/client/components/index.spec.js b/test/client/components/index.spec.js index fdd3c55..9a3a365 100644 --- a/test/client/components/index.spec.js +++ b/test/client/components/index.spec.js @@ -1,9 +1,13 @@ /* eslint-disable import/no-unresolved */ import React from 'react'; -import { mount } from 'enzyme'; +import { mount, configure } from 'enzyme'; import { expect } from 'chai'; +import Adapter from 'enzyme-adapter-react-16'; import Index from '../../../imports/ui/components/index'; +// TODO: centralized this config +configure({ adapter: new Adapter() }); + describe('App index', () => { it('should render app layout', () => { const wrapper = mount();