diff --git a/.babelrc b/.babelrc index 6aadfa7..c7d564a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,6 @@ { - "stage": 0, - "blacklist": ["useStrict"] + "presets": ["es2015-without-strict", "stage-0", "react"], + "plugins": [ + "transform-decorators-legacy" + ] } diff --git a/examples/cerebral/basic/app.js b/examples/cerebral/basic/app.js deleted file mode 100644 index 8ddc68c..0000000 --- a/examples/cerebral/basic/app.js +++ /dev/null @@ -1,92 +0,0 @@ -/* eslint-disable react/no-multi-comp */ -import React, {Component, PropTypes} from "react"; -import ReactDOM from "react-dom"; -import {metrics} from "react-metrics"; // eslint-disable-line import/named -import MetricsConfig from "./metrics.config"; -import getRouteState from "./getRouteState"; -import Home from "./components/home"; -import AsyncPageView from "./components/async-page-view"; -import ManualPageView from "./components/manual-page-view"; -import User from "./components/user"; -import {Container, Decorator as Cerebral} from "cerebral-react"; -import controller from "./controller"; -import Router from "cerebral-router"; - -import homeOpened from "./signals/homeOpened.js"; -import asyncOpened from "./signals/asyncOpened.js"; -import manualOpened from "./signals/manualOpened.js"; -import userOpened from "./signals/userOpened.js"; -import invalidUrlRouted from "./signals/invalidUrlRouted.js"; - -@Cerebral({ - appName: ["appName"], - route: ["route"], - title: ["title"], - page: ["page"] -}) -@metrics(MetricsConfig, { - getRouteState -}) -class App extends Component { - static displayName = controller.get("appName") - - static propTypes = { - page: PropTypes.string - } - - onClick(signal, event) { - event.preventDefault(); - signal(); - } - - renderPage() { - switch (this.props.page) { - case "home": - return ; - case "async": - return ; - case "manual": - return ; - case "user": - return ; - case "invalid": - return "This is not a valid url!"; - } - } - - render() { - return ( -
- - {this.renderPage()} -
- ); - } -} - -controller.signal("homeOpened", homeOpened); -controller.signal("asyncOpened", asyncOpened); -controller.signal("manualOpened", manualOpened); -controller.signal("userOpened", userOpened); -controller.signal("invalidUrlRouted", invalidUrlRouted); - -Router(controller, { - "/": "homeOpened", - "/async": "asyncOpened", - "/manual": "manualOpened", - "/user/:id": "userOpened", - "*": "invalidUrlRouted" -}, { - baseUrl: "/cerebral/basic/index.html", - onlyHash: true -}).trigger(); - -ReactDOM.render(( - -), document.getElementById("example")); diff --git a/examples/cerebral/basic/components/async-page-view.js b/examples/cerebral/basic/components/async-page-view.js deleted file mode 100644 index 0026e33..0000000 --- a/examples/cerebral/basic/components/async-page-view.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from "react"; -import {PropTypes, exposeMetrics} from "react-metrics"; // eslint-disable-line import/named - -@exposeMetrics -class AsyncPageView extends React.Component { - static contextTypes = { - metrics: PropTypes.metrics - } - - static willTrackPageView(routeState) { - return AsyncPageView._promise.then(result => { - return Object.assign(result, routeState.query); - }); - } - - static _promise = new Promise(resolve => { - setTimeout(() => { - resolve({ - asyncMetrics: "asyncValue" - }); - }, 2 * 1000); - }) - - render() { - return

Async Page View Example

; - } -} - -export default AsyncPageView; diff --git a/examples/cerebral/basic/components/home.js b/examples/cerebral/basic/components/home.js deleted file mode 100644 index 119e68e..0000000 --- a/examples/cerebral/basic/components/home.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from "react"; -import {Decorator as Cerebral} from "cerebral-react"; - -@Cerebral({ - route: ["route"] -}) class Home extends React.Component { - render() { - return

Home

; - } -} - -export default Home; diff --git a/examples/cerebral/basic/components/manual-page-view.js b/examples/cerebral/basic/components/manual-page-view.js deleted file mode 100644 index 08ba2b7..0000000 --- a/examples/cerebral/basic/components/manual-page-view.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; -import {PropTypes, exposeMetrics} from "react-metrics"; // eslint-disable-line import/named - -@exposeMetrics -class ManualPageView extends React.Component { - static contextTypes = { - metrics: PropTypes.metrics - } - - static propTypes = { - appName: React.PropTypes.string - } - - componentDidMount() { - const {appName} = this.props; - this.context.metrics.pageView({appName}); - } - - static willTrackPageView() { - return false; - } - - render() { - return

Manual Page View Example

; - } -} - -export default ManualPageView; diff --git a/examples/cerebral/basic/components/user.js b/examples/cerebral/basic/components/user.js deleted file mode 100644 index a0dc57e..0000000 --- a/examples/cerebral/basic/components/user.js +++ /dev/null @@ -1,25 +0,0 @@ -import React, {PropTypes} from "react"; -import {exposeMetrics} from "react-metrics"; // eslint-disable-line import/named - -@exposeMetrics -class User extends React.Component { - static propTypes = { - params: PropTypes.object, - route: PropTypes.object - } - - static willTrackPageView(routeState) { - return routeState.params; - } - - render() { - const {route} = this.props; - const id = route && route.params && route.params.id; - return ( -
-

User id: {id}

-
- ); - } -} -export default User; diff --git a/examples/cerebral/basic/controller.js b/examples/cerebral/basic/controller.js deleted file mode 100644 index 4f68b40..0000000 --- a/examples/cerebral/basic/controller.js +++ /dev/null @@ -1,13 +0,0 @@ -import Controller from "cerebral"; -import Model from "cerebral-baobab"; - -const model = Model({ - appName: "My Application", - url: "/", - title: "Home", - page: "home" -}); - -const services = {}; - -export default Controller(model, services); diff --git a/examples/cerebral/basic/factories/setPage.js b/examples/cerebral/basic/factories/setPage.js deleted file mode 100644 index 41589a7..0000000 --- a/examples/cerebral/basic/factories/setPage.js +++ /dev/null @@ -1,7 +0,0 @@ -export default function (page) { - function setPage(input, state) { - state.set("route", input.route); - state.set("page", page); - } - return setPage; -} diff --git a/examples/cerebral/basic/factories/setTitle.js b/examples/cerebral/basic/factories/setTitle.js deleted file mode 100644 index 721f26c..0000000 --- a/examples/cerebral/basic/factories/setTitle.js +++ /dev/null @@ -1,6 +0,0 @@ -export default function (title) { - function setTitle(input, state) { - state.set("title", title); - } - return setTitle; -} diff --git a/examples/cerebral/basic/getRouteState.js b/examples/cerebral/basic/getRouteState.js deleted file mode 100644 index 0015b89..0000000 --- a/examples/cerebral/basic/getRouteState.js +++ /dev/null @@ -1,22 +0,0 @@ -function isRouteEqual(a, b) { - if (!a && !b) { - return true; - } - if ((a && !b) || (!a && b)) { - return false; - } - - return ( - a.path === b.path && - a.search === b.search - ); -} - -export default function getRouteState(newProps, props = {}) { - if (newProps.route && - newProps.route.path && - !isRouteEqual(props.route, newProps.route)) { - return newProps.route; - } - return null; -} diff --git a/examples/cerebral/basic/index.html b/examples/cerebral/basic/index.html deleted file mode 100644 index 05f90e6..0000000 --- a/examples/cerebral/basic/index.html +++ /dev/null @@ -1,9 +0,0 @@ - -Cerebral Example - - -

React Metrics Examples / Cerebral / Basic Example

-
- - - diff --git a/examples/cerebral/basic/metrics.config.js b/examples/cerebral/basic/metrics.config.js deleted file mode 100644 index 6217997..0000000 --- a/examples/cerebral/basic/metrics.config.js +++ /dev/null @@ -1,50 +0,0 @@ -import pkg from "../../../package.json"; - -const config = { - vendors: [ - { - api: { - name: "Test", - pageView(eventName, params) { - return new Promise(resolve => { - setTimeout(() => { - resolve({ - eventName, - params - }); - }, 0 * 1000); - }); - }, - track(eventName, params) { - return new Promise(resolve => { - resolve({ - eventName, - params - }); - }); - }, - user(user) { - return new Promise(resolve => { - resolve({ - user - }); - }); - } - } - } - ], - pageDefaults: (routeState) => { - const paths = routeState.path.substr(1).split("/"); - const timestamp = new Date(); - return { - timestamp, - build: pkg.version, - siteName: "React Metrics Example", - category: !paths[0] ? "landing" : paths[0] - }; - }, - pageViewEvent: "pageLoad", - debug: true -}; - -export default config; diff --git a/examples/cerebral/basic/signals/asyncOpened.js b/examples/cerebral/basic/signals/asyncOpened.js deleted file mode 100644 index 4a971a9..0000000 --- a/examples/cerebral/basic/signals/asyncOpened.js +++ /dev/null @@ -1,7 +0,0 @@ -import setTitle from "../factories/setTitle.js"; -import setPage from "../factories/setPage.js"; - -export default [ - setTitle("Async"), - setPage("async") -]; diff --git a/examples/cerebral/basic/signals/homeOpened.js b/examples/cerebral/basic/signals/homeOpened.js deleted file mode 100644 index 4a438f0..0000000 --- a/examples/cerebral/basic/signals/homeOpened.js +++ /dev/null @@ -1,7 +0,0 @@ -import setTitle from "../factories/setTitle.js"; -import setPage from "../factories/setPage.js"; - -export default [ - setTitle("Home"), - setPage("home") -]; diff --git a/examples/cerebral/basic/signals/invalidUrlRouted.js b/examples/cerebral/basic/signals/invalidUrlRouted.js deleted file mode 100644 index 2166fcb..0000000 --- a/examples/cerebral/basic/signals/invalidUrlRouted.js +++ /dev/null @@ -1,7 +0,0 @@ -import setTitle from "../factories/setTitle.js"; -import setPage from "../factories/setPage.js"; - -export default [ - setTitle("Invalid URL"), - setPage("invalid") -]; diff --git a/examples/cerebral/basic/signals/manualOpened.js b/examples/cerebral/basic/signals/manualOpened.js deleted file mode 100644 index 57d35bf..0000000 --- a/examples/cerebral/basic/signals/manualOpened.js +++ /dev/null @@ -1,7 +0,0 @@ -import setTitle from "../factories/setTitle.js"; -import setPage from "../factories/setPage.js"; - -export default [ - setTitle("Manual"), - setPage("manual") -]; diff --git a/examples/cerebral/basic/signals/userOpened.js b/examples/cerebral/basic/signals/userOpened.js deleted file mode 100644 index 6acdf0b..0000000 --- a/examples/cerebral/basic/signals/userOpened.js +++ /dev/null @@ -1,7 +0,0 @@ -import setTitle from "../factories/setTitle.js"; -import setPage from "../factories/setPage.js"; - -export default [ - setTitle("User"), - setPage("user") -]; diff --git a/examples/cerebral/index.html b/examples/cerebral/index.html deleted file mode 100644 index 28aefa5..0000000 --- a/examples/cerebral/index.html +++ /dev/null @@ -1,9 +0,0 @@ - -React Router Example - - -

React Metrics Examples / Cerebral

- - diff --git a/examples/index.html b/examples/index.html index f38065f..0bde691 100644 --- a/examples/index.html +++ b/examples/index.html @@ -6,6 +6,5 @@

React Metrics Examples

diff --git a/examples/no-router-lib/basic/app.js b/examples/no-router-lib/basic/app.js index 1cba02b..c1b5b34 100644 --- a/examples/no-router-lib/basic/app.js +++ b/examples/no-router-lib/basic/app.js @@ -12,7 +12,7 @@ class App extends Component { static propTypes = { history: PropTypes.object, children: PropTypes.node - } + }; render() { const createHref = this.props.history.createHref; diff --git a/examples/no-router-lib/basic/page.js b/examples/no-router-lib/basic/page.js index 575c231..bc029c9 100644 --- a/examples/no-router-lib/basic/page.js +++ b/examples/no-router-lib/basic/page.js @@ -5,11 +5,11 @@ class Page extends React.Component { static contextTypes = { metrics: MetricsPropTypes.metrics, appState: PropTypes.any - } + }; static propTypes = { params: PropTypes.object - } + }; onClick() { this.context.metrics.user({ diff --git a/examples/react-router/basic/app.js b/examples/react-router/basic/app.js index 5da3f20..6262577 100644 --- a/examples/react-router/basic/app.js +++ b/examples/react-router/basic/app.js @@ -1,21 +1,20 @@ /* eslint-disable react/no-multi-comp */ import React, {Component, PropTypes} from "react"; import ReactDOM from "react-dom"; -import {Router, Route, IndexRoute, Link, IndexLink} from "react-router"; +import {Router, Route, IndexRoute, Link, IndexLink, hashHistory} from "react-router"; import {metrics} from "react-metrics"; // eslint-disable-line import/named import MetricsConfig from "./metrics.config"; import Home from "./home"; import AsyncPageView from "./async-page-view"; import ManualPageView from "./manual-page-view"; import User from "./user"; -import createHistory from "history/lib/createHashHistory"; class App extends Component { - static displayName = "My Application" + static displayName = "My Application"; static propTypes = { children: PropTypes.node - } + }; render() { return ( @@ -23,7 +22,7 @@ class App extends Component {
  • Home
  • Async Page View Track
  • -
  • Async Page View Track with query param
  • +
  • Async Page View Track with query param
  • Manual Page View Track
  • Page View Track with params
@@ -45,7 +44,7 @@ class NotFound extends Component { } ReactDOM.render(( - + diff --git a/examples/react-router/basic/async-page-view.js b/examples/react-router/basic/async-page-view.js index 38ca91a..4d675a8 100644 --- a/examples/react-router/basic/async-page-view.js +++ b/examples/react-router/basic/async-page-view.js @@ -5,7 +5,7 @@ import {PropTypes, exposeMetrics} from "react-metrics"; // eslint-disable-line i class AsyncPageView extends React.Component { static contextTypes = { metrics: PropTypes.metrics - } + }; static willTrackPageView(routeState) { return AsyncPageView._promise.then(result => { @@ -19,7 +19,7 @@ class AsyncPageView extends React.Component { asyncMetrics: "asyncValue" }); }, 5 * 1000); - }) + }); render() { return

Async Page View Example

; diff --git a/examples/react-router/basic/manual-page-view.js b/examples/react-router/basic/manual-page-view.js index 08ba2b7..2709014 100644 --- a/examples/react-router/basic/manual-page-view.js +++ b/examples/react-router/basic/manual-page-view.js @@ -5,11 +5,11 @@ import {PropTypes, exposeMetrics} from "react-metrics"; // eslint-disable-line i class ManualPageView extends React.Component { static contextTypes = { metrics: PropTypes.metrics - } + }; static propTypes = { appName: React.PropTypes.string - } + }; componentDidMount() { const {appName} = this.props; diff --git a/examples/react-router/basic/user.js b/examples/react-router/basic/user.js index d684343..70189a3 100644 --- a/examples/react-router/basic/user.js +++ b/examples/react-router/basic/user.js @@ -5,7 +5,7 @@ import {exposeMetrics} from "react-metrics"; // eslint-disable-line import/named class User extends React.Component { static propTypes = { params: PropTypes.object - } + }; static willTrackPageView(routeState) { return routeState.params; diff --git a/examples/redux/basic/app.js b/examples/redux/basic/app.js index 550bf39..a3e46db 100644 --- a/examples/redux/basic/app.js +++ b/examples/redux/basic/app.js @@ -1,7 +1,7 @@ /* eslint-disable react/no-multi-comp */ import React, {Component, PropTypes} from "react"; import ReactDOM from "react-dom"; -import {Router, Route, IndexRoute, Link, IndexLink} from "react-router"; +import {Router, Route, IndexRoute, Link, IndexLink, useRouterHistory} from "react-router"; import createHistory from "history/lib/createHashHistory"; import {createStore, applyMiddleware} from "redux"; import {Provider, connect} from "react-redux"; @@ -27,6 +27,7 @@ history.listen(location => { prevLocation = location; } }); +const appHistory = useRouterHistory(createHistory)(); @connect( state => ({ @@ -38,7 +39,7 @@ class Application extends Component { static propTypes = { children: PropTypes.node, dispatch: PropTypes.func.isRequired - } + }; onInclementClick(id) { this.props.dispatch(inclement(id)); } @@ -78,7 +79,7 @@ class Page extends Component { onDeclementClick: PropTypes.func, counterA: PropTypes.number, counterB: PropTypes.number - } + }; render() { const {params, counterA, counterB, onInclementClick, onDeclementClick} = this.props; @@ -99,7 +100,7 @@ class Page extends Component { ReactDOM.render((
- + diff --git a/examples/webpack.config.js b/examples/webpack.config.js index 2007dac..7601bed 100644 --- a/examples/webpack.config.js +++ b/examples/webpack.config.js @@ -39,7 +39,8 @@ module.exports = { exclude: /node_modules/, loader: "babel", query: { - stage: 0 + presets: ["es2015-without-strict", "stage-0", "react"], + plugins: ["transform-decorators-legacy"] } }, { diff --git a/package.json b/package.json index d6c7529..26b17a5 100644 --- a/package.json +++ b/package.json @@ -25,60 +25,65 @@ "url": "https://github.com/nfl/react-metrics/issues" }, "dependencies": { - "core-js": "^1.2.3", + "core-js": "^2.1.1", "deep-equal": "^1.0.1", "eventemitter3": "^1.1.1", - "fbjs": "^0.4.0", - "hoist-non-react-statics": "^1.0.3", + "fbjs": "^0.7.2", + "hoist-non-react-statics": "^1.0.5", "querystring": "^0.2.0", - "rimraf": "^2.4.3" + "rimraf": "^2.5.1" }, "devDependencies": { "analytics.js": "^2.9.1", - "babel": "^5.8.23", - "babel-core": "^5.8.25", - "babel-eslint": "^4.1.3", - "babel-loader": "^5.3.2", - "baobab": "^2.0.0", - "cerebral": "^0.21.0", - "cerebral-baobab": "^0.3.0", - "cerebral-react": "^0.5.0", - "cerebral-router": "^0.6.0", - "chai": "^3.3.0", - "eslint": "^1.6.0", - "eslint-config-nfl": "^4.0.2", - "eslint-plugin-import": "^0.8.1", - "eslint-plugin-react": "^3.7.1", - "history": "1.13.x", - "isparta-loader": "^1.0.0", + "babel-cli": "^6.5.1", + "babel-core": "^6.5.1", + "babel-eslint": "^5.0.0", + "babel-loader": "^6.2.3", + "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-preset-es2015-without-strict": "0.0.2", + "babel-preset-react": "^6.5.0", + "babel-preset-stage-0": "^6.5.0", + "chai": "^3.5.0", + "commitizen": "^2.5.0", + "conventional-changelog": "^1.0.1", + "cz-conventional-changelog": "^1.1.5", + "eslint": "^2.1.0", + "eslint-config-nfl": "^6.0.0", + "eslint-plugin-import": "^1.0.3", + "eslint-plugin-mocha": "^2.0.0", + "eslint-plugin-react": "^3.16.1", + "history": "^2.0.0", + "isparta-loader": "^2.0.0", "json-loader": "^0.5.3", "karma": "^0.13.10", "karma-browserstack-launcher": "taak77/karma-browserstack-launcher#feature/fixes", "karma-chai-sinon": "^0.1.5", "karma-chrome-launcher": "^0.2.0", - "karma-cli": "0.1.1", + "karma-cli": "0.1.2", "karma-coverage": "^0.5.3", - "karma-mocha": "^0.2.0", - "karma-mocha-reporter": "^1.1.1", + "karma-mocha": "^0.2.2", + "karma-mocha-reporter": "^1.2.2", "karma-safari-launcher": "^0.1.1", "karma-sauce-launcher": "^0.3.0", "karma-sourcemap-loader": "^0.3.5", - "karma-tap-reporter": "0.0.4", + "karma-tap-reporter": "0.0.6", "karma-webpack": "^1.7.0", - "mocha": "^2.3.3", + "mocha": "^2.4.5", "path-to-regexp": "^1.2.1", - "react": "0.14.2", - "react-addons-test-utils": "0.14.2", - "react-dom": "0.14.2", - "react-redux": "^4.0.0", - "react-router": "1.0.2", - "redux": "^3.0.2", - "sinon": "^1.17.1", + "react": "^0.14.7", + "react-addons-test-utils": "0.14.7", + "react-dom": "^0.14.7", + "react-redux": "^4.4.0", + "react-router": "^2.0.0", + "redux": "^3.3.1", + "sinon": "^1.17.3", "sinon-chai": "^2.8.0", - "webpack": "^1.12.2", + "webpack": "^1.12.14", "webpack-dev-server": "^1.12.0" }, "scripts": { + "commit": "git-cz", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -w", "build": "npm run clean && npm run compile", "clean": "rimraf lib build", "compile": "babel src --out-dir lib", @@ -89,5 +94,10 @@ "test": "karma start", "postinstall": "node ./npm-scripts/postinstall.js" }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + }, "registry": "npm" } diff --git a/src/core/utils/attr2obj.js b/src/core/utils/attr2obj.js index 54a044c..0d441f3 100644 --- a/src/core/utils/attr2obj.js +++ b/src/core/utils/attr2obj.js @@ -8,15 +8,13 @@ const attr2obj = (elem, prefix = "data") => { const camelCase = string => { return string.replace(rdashAlpha, fcamelCase); }; - let name; - let camelName; - let i; + if (elem.nodeType === 1) { - i = attrs.length; + let i = attrs.length; while (i--) { - name = attrs[i].name; + const name = attrs[i].name; if (name.indexOf(`${prefix}-`) === 0) { - camelName = camelCase(name.slice(prefix.length + 1)); + const camelName = camelCase(name.slice(prefix.length + 1)); dataAttrs[camelName] = elem.getAttribute(name); } } diff --git a/src/react/exposeMetrics.js b/src/react/exposeMetrics.js index 4d5b8d7..e9e04d2 100644 --- a/src/react/exposeMetrics.js +++ b/src/react/exposeMetrics.js @@ -19,12 +19,12 @@ function getDisplayName(Comp) { function wrap(ComposedComponent) { class Metrics extends Component { - static displayName = `Metrics(${getDisplayName(ComposedComponent)})` + static displayName = `Metrics(${getDisplayName(ComposedComponent)})`; // context unit test fails w/o this, why?? static contextTypes = { metrics: PropTypes.metrics - } + }; componentWillMount() { mountedInstances.push(Metrics); diff --git a/src/react/metrics.js b/src/react/metrics.js index 058e8b5..0882c03 100644 --- a/src/react/metrics.js +++ b/src/react/metrics.js @@ -24,7 +24,7 @@ export default function metrics(metricsOrOptions, options = {}) { return function wrap(ComposedComponent) { class MetricsContainer extends Component { - static displayName = "MetricsContainer" + static displayName = "MetricsContainer"; static getMountedMetricsInstances() { // eslint-disable-line react/sort-comp if (!mountedInstances) { @@ -35,12 +35,12 @@ export default function metrics(metricsOrOptions, options = {}) { static childContextTypes = { metrics: metricsType.isRequired - } + }; static propTypes = { location: locationType, params: PropTypes.object - } + }; getChildContext() { return { diff --git a/test/ReactMetrics/exposeMetrics.spec.js b/test/ReactMetrics/exposeMetrics.spec.js index 991548c..71a568c 100644 --- a/test/ReactMetrics/exposeMetrics.spec.js +++ b/test/ReactMetrics/exposeMetrics.spec.js @@ -24,7 +24,7 @@ describe("exposeMetrics", () => { it("should be named after wrapped component", () => { class Comp1 extends React.Component { - static displayName = "Compo1" + static displayName = "Compo1"; render() { return (

Page

); } @@ -76,7 +76,7 @@ describe("exposeMetrics", () => { @exposeMetrics class Page extends React.Component { - static displayName = "Page" + static displayName = "Page"; static willTrackPageView() { expect(true).to.be.ok; diff --git a/test/ReactMetrics/metrics.spec.js b/test/ReactMetrics/metrics.spec.js index ee58969..bbc77e9 100644 --- a/test/ReactMetrics/metrics.spec.js +++ b/test/ReactMetrics/metrics.spec.js @@ -117,7 +117,7 @@ describe("metrics", () => { // context unit test fails w/o this, why?? static contextTypes = { metrics: PropTypes.metrics - } + }; render() { return (

Page

); } @@ -160,7 +160,7 @@ describe("metrics", () => { it("should not auto track page view when 'autoTrackPageView' is set to false.", done => { @metrics(metricsConfig, {autoTrackPageView: false}) class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; render() { return (
{this.props.children}
); @@ -186,11 +186,11 @@ describe("metrics", () => { ]; class Page extends React.Component { - static displayName = "Page" + static displayName = "Page"; static contextTypes = { metrics: PropTypes.metrics.isRequired - } + }; componentDidMount() { this.context.metrics.pageView(); @@ -221,7 +221,7 @@ describe("metrics", () => { const metricsInstance = new Metrics(metricsConfig); @metrics(metricsInstance, {useTrackBinding: false}) class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; componentDidMount() { // make sure click happens after binding is done. setTimeout(() => { @@ -253,7 +253,7 @@ describe("metrics", () => { }] }) class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; render() { return (

Appication

); @@ -279,11 +279,11 @@ describe("metrics", () => { @metrics(metricsConfig) @exposeMetrics class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; static contextTypes = { metrics: PropTypes.metrics.isRequired - } + }; componentDidMount() { this.context.metrics.pageView(customPageViewRule, customData); @@ -326,11 +326,11 @@ describe("metrics", () => { @metrics(metricsConfig) @exposeMetrics class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; static contextTypes = { metrics: PropTypes.metrics.isRequired - } + }; componentDidMount() { this.context.metrics.track(trackId, customData); diff --git a/test/ReactMetrics/willTrackPageView.spec.js b/test/ReactMetrics/willTrackPageView.spec.js index c38a8eb..c722226 100644 --- a/test/ReactMetrics/willTrackPageView.spec.js +++ b/test/ReactMetrics/willTrackPageView.spec.js @@ -28,7 +28,7 @@ describe("willTrackPageView", () => { @metrics(MetricsConfig) class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; render() { return (

Application

{this.props.children}
); @@ -36,7 +36,7 @@ describe("willTrackPageView", () => { } class Page extends React.Component { - static displayName = "Page" + static displayName = "Page"; render() { return (

Page

{this.props.children}
); @@ -45,7 +45,7 @@ describe("willTrackPageView", () => { @exposeMetrics class Content extends React.Component { - static displayName = "Content" + static displayName = "Content"; componentWillMount() { componentWillMountCalled = true; @@ -95,7 +95,7 @@ describe("willTrackPageView", () => { @metrics(MetricsConfig) @exposeMetrics class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; static willTrackPageView() { return false; @@ -128,7 +128,7 @@ describe("willTrackPageView", () => { @metrics(MetricsConfig) @exposeMetrics class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; static willTrackPageView() { return { @@ -165,7 +165,7 @@ describe("willTrackPageView", () => { @metrics(MetricsConfig) class Application extends React.Component { - static displayName = "Application" + static displayName = "Application"; render() { return (
{this.props.children}
); @@ -174,7 +174,7 @@ describe("willTrackPageView", () => { @exposeMetrics class Page extends React.Component { - static displayName = "Page" + static displayName = "Page"; static willTrackPageView(routeState) { expect(routeState.pathname).to.equal("/page/123"); diff --git a/test/core/attr2obj.spec.js b/test/core/attr2obj.spec.js index f5dbd18..1c7943b 100644 --- a/test/core/attr2obj.spec.js +++ b/test/core/attr2obj.spec.js @@ -7,16 +7,14 @@ import attr2obj from "../../src/core/utils/attr2obj"; describe("attr2obj", () => { it("returns empty object if an element is not nodeType 1", () => { const node = document.createDocumentFragment(); - let obj; - obj = attr2obj(node); + const obj = attr2obj(node); expect(obj).to.be.an("object"); expect(Object.keys(obj).length).to.equal(0); }); it("extracts prefixed attributes as empty object when no attribute is found", () => { const node = document.createElement("a"); - let obj; - obj = attr2obj(node, "prefix"); + const obj = attr2obj(node, "prefix"); expect(obj).to.be.an("object"); expect(Object.keys(obj).length).to.equal(0); }); @@ -24,8 +22,7 @@ describe("attr2obj", () => { it("uses 'data' as default prefix", () => { const node = document.createElement("a"); node.setAttribute("data-event", "My Event Name"); - let obj; - obj = attr2obj(node); + const obj = attr2obj(node); expect(obj).to.be.an("object"); expect(obj).to.have.property("event").and.to.equal("My Event Name"); }); diff --git a/test/execSteps.js b/test/execSteps.js index afb8d3c..c6a38e3 100644 --- a/test/execSteps.js +++ b/test/execSteps.js @@ -2,12 +2,12 @@ function execSteps(steps, done) { let index = 0; - return function () { + return function (...args) { if (steps.length === 0) { done(); } else { try { - steps[index++].apply(this, arguments); + steps[index++].apply(this, args); if (index === steps.length) { done();