@pingux/astro 1.33.1-alpha.1 → 1.34.0-alpha.0
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.
- package/lib/cjs/components/Icon/Icon.js +11 -6
- package/lib/cjs/components/Icon/Icon.stories.js +119 -8
- package/lib/cjs/components/Icon/Icon.test.js +27 -0
- package/lib/cjs/components/IconButton/IconButton.stories.js +277 -11
- package/lib/cjs/hooks/index.js +16 -7
- package/lib/cjs/hooks/useTShirtSize/index.js +18 -0
- package/lib/cjs/hooks/useTShirtSize/useTShirtSize.js +41 -0
- package/lib/cjs/hooks/useTShirtSize/useTShirtSize.test.js +93 -0
- package/lib/cjs/recipes/LinkedListView.stories.js +0 -3
- package/lib/cjs/utils/devUtils/constants/tShirtSizes.js +15 -0
- package/lib/components/Icon/Icon.js +10 -6
- package/lib/components/Icon/Icon.stories.js +102 -3
- package/lib/components/Icon/Icon.test.js +21 -0
- package/lib/components/IconButton/IconButton.stories.js +259 -2
- package/lib/hooks/index.js +5 -4
- package/lib/hooks/useTShirtSize/index.js +1 -0
- package/lib/hooks/useTShirtSize/useTShirtSize.js +29 -0
- package/lib/hooks/useTShirtSize/useTShirtSize.test.js +87 -0
- package/lib/recipes/LinkedListView.stories.js +0 -3
- package/lib/utils/devUtils/constants/tShirtSizes.js +5 -0
- package/package.json +1 -1
@@ -0,0 +1,87 @@
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
2
|
+
import useTShirtSize from './useTShirtSize';
|
3
|
+
describe('useTShirtSize', function () {
|
4
|
+
beforeEach(function () {
|
5
|
+
process.env.NODE_ENV = 'development';
|
6
|
+
|
7
|
+
global.console.warn = function () {
|
8
|
+
return jest.mock();
|
9
|
+
}; // eslint-disable-line no-console
|
10
|
+
|
11
|
+
});
|
12
|
+
afterEach(function () {
|
13
|
+
process.env.NODE_ENV = 'test';
|
14
|
+
jest.clearAllMocks();
|
15
|
+
});
|
16
|
+
test('default', function () {
|
17
|
+
var props = {};
|
18
|
+
var spy = jest.spyOn(console, 'warn');
|
19
|
+
expect(spy).toHaveBeenCalledTimes(0);
|
20
|
+
renderHook(function () {
|
21
|
+
return useTShirtSize(props);
|
22
|
+
});
|
23
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
24
|
+
});
|
25
|
+
});
|
26
|
+
test('does not warn if size prop does exist', function () {
|
27
|
+
var props = {
|
28
|
+
size: 15
|
29
|
+
};
|
30
|
+
var spy = jest.spyOn(console, 'warn');
|
31
|
+
expect(spy).not.toHaveBeenCalled();
|
32
|
+
renderHook(function () {
|
33
|
+
return useTShirtSize(props);
|
34
|
+
});
|
35
|
+
expect(spy).not.toHaveBeenCalled();
|
36
|
+
});
|
37
|
+
test('returns size value if size is a tshirt value', function () {
|
38
|
+
var props = {
|
39
|
+
size: 'xs'
|
40
|
+
};
|
41
|
+
|
42
|
+
var _renderHook = renderHook(function () {
|
43
|
+
return useTShirtSize(props);
|
44
|
+
}),
|
45
|
+
result = _renderHook.result;
|
46
|
+
|
47
|
+
var obj = {
|
48
|
+
sizeProps: {
|
49
|
+
size: '15px'
|
50
|
+
}
|
51
|
+
};
|
52
|
+
expect(result.current).toEqual(obj);
|
53
|
+
});
|
54
|
+
test('returns size value if size is a string value', function () {
|
55
|
+
var props = {
|
56
|
+
size: '20px'
|
57
|
+
};
|
58
|
+
|
59
|
+
var _renderHook2 = renderHook(function () {
|
60
|
+
return useTShirtSize(props);
|
61
|
+
}),
|
62
|
+
result = _renderHook2.result;
|
63
|
+
|
64
|
+
var obj = {
|
65
|
+
sizeProps: {
|
66
|
+
size: '20px'
|
67
|
+
}
|
68
|
+
};
|
69
|
+
expect(result.current).toEqual(obj);
|
70
|
+
});
|
71
|
+
test('returns size value if size is a number value', function () {
|
72
|
+
var props = {
|
73
|
+
size: 20
|
74
|
+
};
|
75
|
+
|
76
|
+
var _renderHook3 = renderHook(function () {
|
77
|
+
return useTShirtSize(props);
|
78
|
+
}),
|
79
|
+
result = _renderHook3.result;
|
80
|
+
|
81
|
+
var obj = {
|
82
|
+
sizeProps: {
|
83
|
+
size: 20
|
84
|
+
}
|
85
|
+
};
|
86
|
+
expect(result.current).toEqual(obj);
|
87
|
+
});
|