@instructure/ui-utils 8.52.1-snapshot-6 → 8.52.1-snapshot-11
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1 -1
- package/es/__new-tests__/camelize.test.js +40 -0
- package/es/__new-tests__/cloneArray.test.js +52 -0
- package/es/__new-tests__/createChainedFunction.test.js +50 -0
- package/es/__new-tests__/generateId.test.js +60 -0
- package/es/__new-tests__/hash.test.js +415 -0
- package/es/__new-tests__/mergeDeep.test.js +196 -0
- package/es/__new-tests__/ms.test.js +40 -0
- package/es/__new-tests__/parseUnit.test.js +69 -0
- package/es/__new-tests__/pascalize.test.js +48 -0
- package/es/__new-tests__/px.test.js +51 -0
- package/es/__new-tests__/within.test.js +41 -0
- package/lib/__new-tests__/camelize.test.js +43 -0
- package/lib/__new-tests__/cloneArray.test.js +55 -0
- package/lib/__new-tests__/createChainedFunction.test.js +52 -0
- package/lib/__new-tests__/generateId.test.js +63 -0
- package/lib/__new-tests__/hash.test.js +417 -0
- package/lib/__new-tests__/mergeDeep.test.js +198 -0
- package/lib/__new-tests__/ms.test.js +42 -0
- package/lib/__new-tests__/parseUnit.test.js +71 -0
- package/lib/__new-tests__/pascalize.test.js +50 -0
- package/lib/__new-tests__/px.test.js +53 -0
- package/lib/__new-tests__/within.test.js +43 -0
- package/package.json +6 -5
- package/src/__new-tests__/camelize.test.tsx +42 -0
- package/src/__new-tests__/cloneArray.test.tsx +62 -0
- package/src/__new-tests__/createChainedFunction.test.tsx +54 -0
- package/src/__new-tests__/generateId.test.tsx +69 -0
- package/src/__new-tests__/hash.test.tsx +547 -0
- package/src/__new-tests__/mergeDeep.test.tsx +133 -0
- package/src/__new-tests__/ms.test.tsx +44 -0
- package/src/__new-tests__/parseUnit.test.tsx +80 -0
- package/src/__new-tests__/pascalize.test.tsx +51 -0
- package/src/__new-tests__/px.test.tsx +59 -0
- package/src/__new-tests__/within.test.tsx +44 -0
- package/tsconfig.build.json +0 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/__new-tests__/camelize.test.d.ts +2 -0
- package/types/__new-tests__/camelize.test.d.ts.map +1 -0
- package/types/__new-tests__/cloneArray.test.d.ts +2 -0
- package/types/__new-tests__/cloneArray.test.d.ts.map +1 -0
- package/types/__new-tests__/createChainedFunction.test.d.ts +2 -0
- package/types/__new-tests__/createChainedFunction.test.d.ts.map +1 -0
- package/types/__new-tests__/generateId.test.d.ts +2 -0
- package/types/__new-tests__/generateId.test.d.ts.map +1 -0
- package/types/__new-tests__/hash.test.d.ts +2 -0
- package/types/__new-tests__/hash.test.d.ts.map +1 -0
- package/types/__new-tests__/mergeDeep.test.d.ts +2 -0
- package/types/__new-tests__/mergeDeep.test.d.ts.map +1 -0
- package/types/__new-tests__/ms.test.d.ts +2 -0
- package/types/__new-tests__/ms.test.d.ts.map +1 -0
- package/types/__new-tests__/parseUnit.test.d.ts +2 -0
- package/types/__new-tests__/parseUnit.test.d.ts.map +1 -0
- package/types/__new-tests__/pascalize.test.d.ts +2 -0
- package/types/__new-tests__/pascalize.test.d.ts.map +1 -0
- package/types/__new-tests__/px.test.d.ts +2 -0
- package/types/__new-tests__/px.test.d.ts.map +1 -0
- package/types/__new-tests__/within.test.d.ts +2 -0
- package/types/__new-tests__/within.test.d.ts.map +1 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License (MIT)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
import '@testing-library/jest-dom'
|
26
|
+
import { parseUnit } from '../parseUnit'
|
27
|
+
|
28
|
+
describe('parseUnit', () => {
|
29
|
+
it('unitless', () => {
|
30
|
+
expect(parseUnit('50')[0]).toEqual(50)
|
31
|
+
})
|
32
|
+
|
33
|
+
it('integer', () => {
|
34
|
+
expect(parseUnit(50)[0]).toEqual(50)
|
35
|
+
})
|
36
|
+
|
37
|
+
it('decimal', () => {
|
38
|
+
expect(parseUnit(47.89101)[0]).toEqual(47.89101)
|
39
|
+
})
|
40
|
+
|
41
|
+
it('negative', () => {
|
42
|
+
expect(parseUnit('-20px')[0]).toEqual(-20)
|
43
|
+
expect(parseUnit('-20px')[1]).toEqual('px')
|
44
|
+
})
|
45
|
+
|
46
|
+
it('px', () => {
|
47
|
+
expect(parseUnit('100.0792px')[0]).toEqual(100.0792)
|
48
|
+
expect(parseUnit('100.0792px')[1]).toEqual('px')
|
49
|
+
})
|
50
|
+
|
51
|
+
it('rem', () => {
|
52
|
+
expect(parseUnit('4000rem')[0]).toEqual(4000)
|
53
|
+
expect(parseUnit('4000rem')[1]).toEqual('rem')
|
54
|
+
})
|
55
|
+
|
56
|
+
it('em', () => {
|
57
|
+
expect(parseUnit('300em')[0]).toEqual(300)
|
58
|
+
expect(parseUnit('300em')[1]).toEqual('em')
|
59
|
+
})
|
60
|
+
|
61
|
+
it('s', () => {
|
62
|
+
expect(parseUnit('5s')[0]).toEqual(5)
|
63
|
+
expect(parseUnit('5s')[1]).toEqual('s')
|
64
|
+
})
|
65
|
+
|
66
|
+
it('ms', () => {
|
67
|
+
expect(parseUnit('20ms')[0]).toEqual(20)
|
68
|
+
expect(parseUnit('20ms')[1]).toEqual('ms')
|
69
|
+
})
|
70
|
+
|
71
|
+
it('vh', () => {
|
72
|
+
expect(parseUnit('327vh')[0]).toEqual(327)
|
73
|
+
expect(parseUnit('327vh')[1]).toEqual('vh')
|
74
|
+
})
|
75
|
+
|
76
|
+
it('vmin', () => {
|
77
|
+
expect(parseUnit('70vmin')[0]).toEqual(70)
|
78
|
+
expect(parseUnit('70vmin')[1]).toEqual('vmin')
|
79
|
+
})
|
80
|
+
})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License (MIT)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
import '@testing-library/jest-dom'
|
26
|
+
import { pascalize } from '../pascalize'
|
27
|
+
|
28
|
+
describe('convertCase', () => {
|
29
|
+
describe('pascalize', () => {
|
30
|
+
it('handles hyphenated strings', () => {
|
31
|
+
expect(pascalize('foo-bar')).toEqual('FooBar')
|
32
|
+
expect(pascalize('baz-qux-foo')).toEqual('BazQuxFoo')
|
33
|
+
expect(pascalize('x-large')).toEqual('XLarge')
|
34
|
+
expect(pascalize('x-x-small')).toEqual('XXSmall')
|
35
|
+
})
|
36
|
+
|
37
|
+
it('handles camel cased strings', () => {
|
38
|
+
expect(pascalize('fooBar')).toEqual('FooBar')
|
39
|
+
expect(pascalize('bazQuxFoo')).toEqual('BazQuxFoo')
|
40
|
+
expect(pascalize('xLarge')).toEqual('XLarge')
|
41
|
+
expect(pascalize('borderRadiusLarge')).toEqual('BorderRadiusLarge')
|
42
|
+
})
|
43
|
+
|
44
|
+
it('does not modify already pascal cased strings', () => {
|
45
|
+
expect(pascalize('FooBar')).toEqual('FooBar')
|
46
|
+
expect(pascalize('BazQuxFoo')).toEqual('BazQuxFoo')
|
47
|
+
expect(pascalize('XLarge')).toEqual('XLarge')
|
48
|
+
expect(pascalize('BorderRadiusLarge')).toEqual('BorderRadiusLarge')
|
49
|
+
})
|
50
|
+
})
|
51
|
+
})
|
@@ -0,0 +1,59 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License (MIT)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
import '@testing-library/jest-dom'
|
26
|
+
import { getFontSize } from '@instructure/ui-dom-utils'
|
27
|
+
|
28
|
+
import { px } from '../px'
|
29
|
+
|
30
|
+
describe('px', () => {
|
31
|
+
let node: HTMLDivElement | null
|
32
|
+
|
33
|
+
beforeEach(() => {
|
34
|
+
node = document.createElement('div')
|
35
|
+
document.body.appendChild(node)
|
36
|
+
})
|
37
|
+
|
38
|
+
afterEach(() => {
|
39
|
+
node && node.parentNode && node.parentNode.removeChild(node)
|
40
|
+
node = null
|
41
|
+
})
|
42
|
+
|
43
|
+
it('handles px units', () => {
|
44
|
+
expect(px('30px')).toEqual(30)
|
45
|
+
})
|
46
|
+
|
47
|
+
it('converts rem to px', () => {
|
48
|
+
expect(px('50rem')).toEqual(50 * getFontSize())
|
49
|
+
})
|
50
|
+
|
51
|
+
it('converts em to px', () => {
|
52
|
+
node!.style.fontSize = '24px'
|
53
|
+
expect(px('10em', node)).toEqual(10 * getFontSize(node))
|
54
|
+
})
|
55
|
+
|
56
|
+
it('handles unitless input', () => {
|
57
|
+
expect(px('4')).toEqual(4)
|
58
|
+
})
|
59
|
+
})
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License (MIT)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
import '@testing-library/jest-dom'
|
26
|
+
|
27
|
+
import { within } from '../within'
|
28
|
+
|
29
|
+
describe('within', () => {
|
30
|
+
it('returns true when values are within range', () => {
|
31
|
+
expect(within(10, 8, 2)).toBe(true)
|
32
|
+
expect(within(10, 11, 1)).toBe(true)
|
33
|
+
expect(within(10, 10, 0)).toBe(true)
|
34
|
+
expect(within(10, 9.999, 0.001)).toBe(true)
|
35
|
+
expect(within(-10, -15, 5)).toBe(true)
|
36
|
+
})
|
37
|
+
|
38
|
+
it('returns false when values are out of range', () => {
|
39
|
+
expect(within(10, 8, 1)).toBe(false)
|
40
|
+
expect(within(12, 10, 1.9999)).toBe(false)
|
41
|
+
expect(within(8.705, 8.7, 0.004)).toBe(false)
|
42
|
+
expect(within(-2, -1.5, 0.4)).toBe(false)
|
43
|
+
})
|
44
|
+
})
|