diff --git a/package-lock.json b/package-lock.json
index 301cd070..b055cd8f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21666,6 +21666,16 @@
"snapdragon": "^0.8.1",
"to-regex": "^3.0.2"
}
+ },
+ "watch": {
+ "version": "0.18.0",
+ "resolved": "https://registry.npmjs.org/watch/-/watch-0.18.0.tgz",
+ "integrity": "sha1-KAlUdsbffJDJYxOJkMClQj60uYY=",
+ "dev": true,
+ "requires": {
+ "exec-sh": "^0.2.0",
+ "minimist": "^1.2.0"
+ }
}
}
},
@@ -24627,9 +24637,9 @@
}
},
"watch": {
- "version": "0.18.0",
- "resolved": "https://registry.npmjs.org/watch/-/watch-0.18.0.tgz",
- "integrity": "sha1-KAlUdsbffJDJYxOJkMClQj60uYY=",
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/watch/-/watch-1.0.2.tgz",
+ "integrity": "sha1-NApxe952Vyb6CqB9ch4BR6VR3ww=",
"dev": true,
"requires": {
"exec-sh": "^0.2.0",
diff --git a/package.json b/package.json
index 8331c7da..16457167 100644
--- a/package.json
+++ b/package.json
@@ -78,7 +78,6 @@
"peerDependencies": {
"@edx/paragon": "^3.8.0",
"clean-webpack-plugin": "^0.1.19",
- "copy-webpack-plugin": "^4.6.0",
"html-webpack-plugin": "^3.2.0",
"prop-types": "^15.5.10",
"react": "^16.4.2",
diff --git a/src/lib/components/SiteFooter/SiteFooter.test.jsx b/src/lib/components/SiteFooter/SiteFooter.test.jsx
index 62a904ee..63d680cf 100644
--- a/src/lib/components/SiteFooter/SiteFooter.test.jsx
+++ b/src/lib/components/SiteFooter/SiteFooter.test.jsx
@@ -1,81 +1,112 @@
import React from 'react';
import renderer from 'react-test-renderer';
+import { mount } from 'enzyme';
import FooterLogo from '../../../edx-footer.png';
-import SiteFooter from '../../index';
+import SiteFooter, { EVENT_NAMES } from './index';
+
+const completeSiteFooterComponent = mockHandleAllTrackEvents =>
+ ();
describe('', () => {
- it('renders correctly', () => {
- const tree = renderer
- .create()
- .toJSON();
- expect(tree).toMatchSnapshot();
+ describe('renders correctly', () => {
+ it('renders with social and mobile links', () => {
+ const mockHandleAllTrackEvents = jest.fn();
+ const tree = renderer
+ .create(completeSiteFooterComponent(mockHandleAllTrackEvents))
+ .toJSON();
+ expect(tree).toMatchSnapshot();
+ });
+
+ it('does not render social links', () => {
+ const tree = renderer
+ .create()
+ .toJSON();
+ expect(tree).toMatchSnapshot();
+ });
+
+ it('does not render mobile links', () => {
+ const tree = renderer
+ .create()
+ .toJSON();
+ expect(tree).toMatchSnapshot();
+ });
});
- it('does not render social links', () => {
- const tree = renderer
- .create()
- .toJSON();
- expect(tree).toMatchSnapshot();
- });
+ describe('handles analytics', () => {
+ it('calls handleAllTrackEvents prop when external links clicked', () => {
+ const mockHandleAllTrackEvents = jest.fn();
+ const footer = mount((completeSiteFooterComponent(mockHandleAllTrackEvents)));
+ const externalLinks = footer.find("a[target='_blank']");
- it('does not render mobile links', () => {
- const tree = renderer
- .create()
- .toJSON();
- expect(tree).toMatchSnapshot();
+ expect(externalLinks).toHaveLength(8);
+ externalLinks.forEach((externalLink) => {
+ const callIndex = mockHandleAllTrackEvents.mock.calls.length;
+ externalLink.simulate('click');
+ expect(mockHandleAllTrackEvents.mock.calls[callIndex]).toEqual([
+ EVENT_NAMES.FOOTER_LINK,
+ {
+ category: 'outbound_link',
+ label: externalLink.prop('href'),
+ },
+ ]);
+ });
+ });
});
});
diff --git a/src/lib/components/SiteFooter/__snapshots__/SiteFooter.test.jsx.snap b/src/lib/components/SiteFooter/__snapshots__/SiteFooter.test.jsx.snap
index b83b3f66..46e5989c 100644
--- a/src/lib/components/SiteFooter/__snapshots__/SiteFooter.test.jsx.snap
+++ b/src/lib/components/SiteFooter/__snapshots__/SiteFooter.test.jsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[` does not render mobile links 1`] = `
+exports[` renders correctly does not render mobile links 1`] = `
does not render mobile links 1`] = `
does not render mobile links 1`] = `
`;
-exports[` does not render social links 1`] = `
+exports[` renders correctly does not render social links 1`] = `
does not render social links 1`] = `
`;
-exports[` renders correctly 1`] = `
+exports[` renders correctly renders with social and mobile links 1`] = `
renders correctly 1`] = `