@capillarytech/creatives-library 7.9.12 → 7.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ import React from 'react';
10
10
  import { Card } from 'antd';
11
11
  import './_customCard.scss';
12
12
 
13
- class CustomCard extends React.Component { // eslint-disable-line react/prefer-stateless-function
13
+ export class CustomCard extends React.Component { // eslint-disable-line react/prefer-stateless-function
14
14
  constructor(props) {
15
15
  super(props);
16
16
  this.handleMouseHover = this.handleMouseHover.bind(this);
@@ -0,0 +1,22 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`RestrictionPlainInput test Test 1 should render default component when a retriction constant is passed 1`] = `
4
+ <Card
5
+ className="custom-card"
6
+ onClick={[Function]}
7
+ onMouseEnter={[Function]}
8
+ onMouseLeave={[Function]}
9
+ style={
10
+ Object {
11
+ "height": undefined,
12
+ "width": undefined,
13
+ }
14
+ }
15
+ >
16
+ <div>
17
+ <div
18
+ className="content-wrapper"
19
+ />
20
+ </div>
21
+ </Card>
22
+ `;
@@ -1,10 +1,22 @@
1
- // import React from 'react';
2
- // import { shallow } from 'enzyme';
1
+ import React from 'react';
2
+ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
3
+ import { CustomCard } from '../index';
3
4
 
4
- // import Card from '../index';
5
+ describe('RestrictionPlainInput test', () => {
6
+
7
+ let renderedComponent;
8
+
9
+ const renderFunc = () => {
10
+ renderedComponent = shallowWithIntl(
11
+ <CustomCard />
12
+ );
13
+ }
14
+
15
+ describe('Test 1', () => {
16
+ it('should render default component when a retriction constant is passed', () => {
17
+ renderFunc();
18
+ expect(renderedComponent).toMatchSnapshot();
19
+ })
20
+ });
5
21
 
6
- describe('<Card />', () => {
7
- it('Expect to have unit tests specified', () => {
8
- expect(true).toEqual(false);
9
- });
10
22
  });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Components using the react-intl module require access to the intl context.
3
+ * This is not available when mounting single components in Enzyme.
4
+ * These helper functions aim to address that and wrap a valid,
5
+ * English-locale intl context around them.
6
+ */
7
+
8
+ import React from 'react';
9
+ import { IntlProvider, intlShape } from 'react-intl';
10
+ import { mount, shallow, configure } from 'enzyme';
11
+ import Adapter from 'enzyme-adapter-react-16';
12
+
13
+ configure({ adapter: new Adapter() });
14
+ // You can pass your messages to the IntlProvider. Optional: remove if unneeded.
15
+ const messages = require('../translations/en.json'); // en.json
16
+
17
+ // Create the IntlProvider to retrieve context for wrapping around.
18
+ const intlProvider = new IntlProvider({ locale: 'en', messages }, {});
19
+ const { intl } = intlProvider.getChildContext();
20
+
21
+ /**
22
+ * When using React-Intl `injectIntl` on components, props.intl is required.
23
+ */
24
+ function nodeWithIntlProp(node) {
25
+ return React.cloneElement(node, { intl });
26
+ }
27
+
28
+ /**
29
+ * Export these methods.
30
+ */
31
+ export function shallowWithIntl(node) {
32
+ return shallow(nodeWithIntlProp(node), { context: { intl } });
33
+ }
34
+
35
+ export function mountWithIntl(node) {
36
+ return mount(nodeWithIntlProp(node), {
37
+ context: { intl },
38
+ childContextTypes: { intl: intlShape },
39
+ });
40
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.9.12",
4
+ "version": "7.9.14",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import PropTypes from 'prop-types';
8
-
9
8
  import React from 'react';
9
+ import { connect } from 'react-redux';
10
10
  // import styled from 'styled-components';
11
11
  import { CapSpin, CapModal, CapButton, CapPopover, CapInput, CapTree, CapSelect, CapTooltip } from '@capillarytech/cap-ui-library';
12
12
 
@@ -15,7 +15,6 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
15
15
  import { createStructuredSelector } from 'reselect';
16
16
  import messages from './messages';
17
17
  import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/selectors';
18
- import withCreatives from '../../hoc/withCreatives';
19
18
 
20
19
  const {Search} = CapInput;
21
20
  const {CapTreeNode} = CapTree;
@@ -287,11 +286,6 @@ const mapStateToProps = createStructuredSelector({
287
286
  disableTagsDetails: makeSelectLoyaltyPromotionDisplay(),
288
287
  });
289
288
 
290
- export default withCreatives({
291
- WrappedComponent: CapTagList,
292
- mapStateToProps,
293
- mapDispatchToProps,
294
- suserAuth: true,
295
- });
296
289
 
297
- // export default injectIntl(CapTagList);
290
+ export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CapTagList));
291
+