@transferwise/components 0.0.0-experimental-c46d48c → 0.0.0-experimental-5865548

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.
Files changed (55) hide show
  1. package/build/alert/Alert.js +8 -0
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +8 -0
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/common/closeButton/CloseButton.js +3 -1
  6. package/build/common/closeButton/CloseButton.js.map +1 -1
  7. package/build/common/closeButton/CloseButton.mjs +3 -1
  8. package/build/common/closeButton/CloseButton.mjs.map +1 -1
  9. package/build/i18n/en.json +0 -2
  10. package/build/i18n/en.json.js +0 -2
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +0 -2
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/phoneNumberInput/PhoneNumberInput.js +2 -36
  15. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  16. package/build/phoneNumberInput/PhoneNumberInput.messages.js +0 -6
  17. package/build/phoneNumberInput/PhoneNumberInput.messages.js.map +1 -1
  18. package/build/phoneNumberInput/PhoneNumberInput.messages.mjs +0 -6
  19. package/build/phoneNumberInput/PhoneNumberInput.messages.mjs.map +1 -1
  20. package/build/phoneNumberInput/PhoneNumberInput.mjs +2 -36
  21. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  22. package/build/types/alert/Alert.d.ts.map +1 -1
  23. package/build/types/common/closeButton/CloseButton.d.ts +2 -0
  24. package/build/types/common/closeButton/CloseButton.d.ts.map +1 -1
  25. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  26. package/build/types/phoneNumberInput/PhoneNumberInput.messages.d.ts +0 -8
  27. package/build/types/phoneNumberInput/PhoneNumberInput.messages.d.ts.map +1 -1
  28. package/build/types/test-utils/index.d.ts +0 -4
  29. package/build/types/test-utils/index.d.ts.map +1 -1
  30. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  31. package/build/withDisplayFormat/WithDisplayFormat.js +3 -2
  32. package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
  33. package/build/withDisplayFormat/WithDisplayFormat.mjs +3 -2
  34. package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
  35. package/package.json +4 -7
  36. package/src/alert/Alert.spec.tsx +11 -0
  37. package/src/alert/Alert.story.tsx +23 -9
  38. package/src/alert/Alert.tsx +14 -1
  39. package/src/common/closeButton/CloseButton.spec.tsx +13 -1
  40. package/src/common/closeButton/CloseButton.tsx +3 -0
  41. package/src/i18n/en.json +0 -2
  42. package/src/phoneNumberInput/PhoneNumberInput.messages.ts +0 -8
  43. package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +43 -77
  44. package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -34
  45. package/src/test-utils/jest.setup.ts +0 -4
  46. package/src/typeahead/Typeahead.spec.tsx +182 -0
  47. package/src/typeahead/typeaheadInput/TypeaheadInput.spec.tsx +103 -0
  48. package/src/typeahead/util/highlight.spec.tsx +43 -0
  49. package/src/withDisplayFormat/WithDisplayFormat.spec.js +11 -15
  50. package/src/withDisplayFormat/WithDisplayFormat.tsx +3 -2
  51. package/src/typeahead/Typeahead.rtl.spec.tsx +0 -54
  52. package/src/typeahead/Typeahead.spec.js +0 -404
  53. package/src/typeahead/typeaheadInput/TypeaheadInput.spec.js +0 -74
  54. package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +0 -75
  55. package/src/typeahead/util/highlight.spec.js +0 -34
@@ -1,74 +0,0 @@
1
- import { shallow } from 'enzyme';
2
-
3
- import { Input } from '../../inputs/Input';
4
-
5
- import TypeaheadInput from './TypeaheadInput';
6
-
7
- describe('Typeahead input', () => {
8
- let component;
9
- let props;
10
-
11
- const inputWrapper = () => component.find('.typeahead__input-wrapper');
12
- const input = () => component.find(Input);
13
-
14
- beforeEach(() => {
15
- props = {
16
- name: 'test',
17
- typeaheadId: 'test',
18
- multiple: false,
19
- value: '',
20
- renderChip: jest.fn(),
21
- onKeyDown: jest.fn(),
22
- onFocus: jest.fn(),
23
- onPaste: jest.fn(),
24
- onChange: jest.fn(),
25
- autoComplete: 'off',
26
- selected: [],
27
- };
28
-
29
- component = shallow(<TypeaheadInput {...props} />);
30
- });
31
-
32
- it('renders single input when multiple is false', () => {
33
- expect(component.children()).toHaveLength(0);
34
- expect(component.is(Input)).toBe(true);
35
- });
36
-
37
- it('renders chips when provided', () => {
38
- const selected = [{ label: 'test1' }, { label: 'test2' }];
39
- component.setProps({
40
- multiple: true,
41
- selected,
42
- renderChip: jest.fn(({ label }, idx) => <span key={idx}>{label}</span>),
43
- });
44
-
45
- expect(inputWrapper().find('span')).toHaveLength(selected.length);
46
- });
47
-
48
- it('adds aria-controls prop if dropdown is open', () => {
49
- expect(component.prop('aria-controls')).toBeUndefined();
50
- component.setProps({ dropdownOpen: true });
51
- expect(component.prop('aria-controls')).toBe('menu-test');
52
- });
53
-
54
- it('passes all callbacks to input', () => {
55
- const event = {};
56
- const extraProps = {
57
- multiple: true,
58
- value: '',
59
- onKeyDown: jest.fn(),
60
- onBlur: jest.fn(),
61
- onFocus: jest.fn(),
62
- onPaste: jest.fn(),
63
- };
64
- component.setProps(extraProps);
65
-
66
- input().simulate('focus', event);
67
- input().simulate('paste', event);
68
- input().simulate('keyDown', event);
69
- const inputProps = input().props();
70
- expect(inputProps.onKeyDown).toHaveBeenCalledWith(event);
71
- expect(inputProps.onFocus).toHaveBeenCalledWith(event);
72
- expect(inputProps.onPaste).toHaveBeenCalledWith(event);
73
- });
74
- });
@@ -1,75 +0,0 @@
1
- import { shallow, mount } from 'enzyme';
2
-
3
- import { fakeEvent } from '../../common/fakeEvents';
4
-
5
- import TypeaheadOption from './TypeaheadOption';
6
- import Highlight from '../util/highlight';
7
-
8
- describe('Typeahead Option', () => {
9
- let props;
10
- let component;
11
-
12
- const labelHighlight = () => component.find(Highlight);
13
- const noteSpan = () => component.find('.np-text-body-default.m-l-1');
14
- const secondaryTextHighlight = () => component.find('.np-text-body-default.text-ellipsis > span');
15
- const dropdownItem = () => component.find('.dropdown-item');
16
-
17
- beforeEach(() => {
18
- props = {
19
- option: {
20
- label: 'test',
21
- },
22
- };
23
-
24
- component = mount(<TypeaheadOption {...props} />);
25
- });
26
-
27
- it('renders a label', () => {
28
- const label = 'test';
29
- component.setProps({ option: { label } });
30
- expect(labelHighlight().text()).toStrictEqual(label);
31
- });
32
-
33
- it('renders a note', () => {
34
- const label = 'test';
35
- const note = 'test note';
36
- component.setProps({ option: { label, note } });
37
- expect(noteSpan().text()).toStrictEqual(note);
38
- });
39
-
40
- it('renders a seconday text', () => {
41
- const label = 'test';
42
- const secondary = 'test note';
43
- component.setProps({ option: { label, secondary } });
44
- expect(secondaryTextHighlight().text()).toStrictEqual(secondary);
45
- });
46
-
47
- it('highlights when selected', () => {
48
- component = shallow(<TypeaheadOption {...props} />);
49
- component.setProps({
50
- selected: true,
51
- });
52
-
53
- expect(component.is('.tw-dropdown-item--focused')).toBe(true);
54
- });
55
-
56
- it('expect aria-selected to be true', () => {
57
- component = shallow(<TypeaheadOption {...props} />);
58
- component.setProps({
59
- selected: true,
60
- });
61
-
62
- expect(component.prop('aria-selected')).toBe('true');
63
- });
64
-
65
- it('calls onClick when clicked', () => {
66
- const onClick = jest.fn();
67
- component.setProps({
68
- onClick,
69
- });
70
-
71
- dropdownItem().simulate('click', fakeEvent);
72
-
73
- expect(onClick).toHaveBeenCalledTimes(1);
74
- });
75
- });
@@ -1,34 +0,0 @@
1
- import { mount } from 'enzyme';
2
-
3
- import Highlight from './highlight';
4
-
5
- describe('Typeahead input', () => {
6
- const highlighted = (node) => node.find('strong');
7
- const getTextFromNodes = (nodes) => nodes.reduce((value, node) => value + node.text(), '');
8
-
9
- it('highlights part of label that matches the query', () => {
10
- const query = 'test';
11
- const label = `this is a ${query} label`;
12
- const result = mount(<Highlight value={label} query={query} />);
13
-
14
- expect(highlighted(result).text()).toStrictEqual(query);
15
-
16
- expect(getTextFromNodes(result)).toBe(label);
17
- });
18
-
19
- it('does not change text if query is not present in it', () => {
20
- const query = 'test';
21
- const label = `this is a label`;
22
- const result = mount(<Highlight value={label} query={query} />);
23
-
24
- expect(result.text()).toBe(label);
25
- });
26
-
27
- it('highlights whole label that matches the query', () => {
28
- const query = 'test';
29
- const label = query;
30
- const result = mount(<Highlight value={label} query={query} />);
31
-
32
- expect(highlighted(result).text()).toStrictEqual(query);
33
- });
34
- });