@instructure/ui-file-drop 10.19.2-snapshot-2 → 10.19.2-snapshot-4
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/CHANGELOG.md +1 -1
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
- package/es/FileDrop/__new-tests__/FileDrop.test.js +0 -152
- package/es/FileDrop/utils/__new-tests__/accepts.test.js +0 -67
- package/es/FileDrop/utils/__new-tests__/getEventFiles.test.js +0 -69
- package/lib/FileDrop/__new-tests__/FileDrop.test.js +0 -153
- package/lib/FileDrop/utils/__new-tests__/accepts.test.js +0 -70
- package/lib/FileDrop/utils/__new-tests__/getEventFiles.test.js +0 -71
- package/src/FileDrop/__new-tests__/FileDrop.test.tsx +0 -158
- package/src/FileDrop/utils/__new-tests__/accepts.test.tsx +0 -72
- package/src/FileDrop/utils/__new-tests__/getEventFiles.test.tsx +0 -86
- package/types/FileDrop/__new-tests__/FileDrop.test.d.ts +0 -2
- package/types/FileDrop/__new-tests__/FileDrop.test.d.ts.map +0 -1
- package/types/FileDrop/utils/__new-tests__/accepts.test.d.ts +0 -2
- package/types/FileDrop/utils/__new-tests__/accepts.test.d.ts.map +0 -1
- package/types/FileDrop/utils/__new-tests__/getEventFiles.test.d.ts +0 -2
- package/types/FileDrop/utils/__new-tests__/getEventFiles.test.d.ts.map +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
var _FileDrop, _FileDrop2, _FileDrop3, _FileDrop4, _FileDrop5, _FileDrop6, _section;
|
|
2
|
-
/*
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { render } from '@testing-library/react';
|
|
27
|
-
import { vi } from 'vitest';
|
|
28
|
-
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
-
import '@testing-library/jest-dom';
|
|
30
|
-
import { FileDrop } from '../index';
|
|
31
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
-
describe('<FileDrop/>', () => {
|
|
33
|
-
it('should focus the input when focus is called', async () => {
|
|
34
|
-
let inputEl;
|
|
35
|
-
const _render = render(_jsx(FileDrop, {
|
|
36
|
-
renderLabel: "filedrop",
|
|
37
|
-
inputRef: el => {
|
|
38
|
-
inputEl = el;
|
|
39
|
-
}
|
|
40
|
-
})),
|
|
41
|
-
container = _render.container;
|
|
42
|
-
const input = container.querySelector('input[class$="-fileDrop__input"]');
|
|
43
|
-
inputEl.focus();
|
|
44
|
-
expect(input).toHaveFocus();
|
|
45
|
-
});
|
|
46
|
-
it('should provide an inputRef prop', async () => {
|
|
47
|
-
const inputRef = vi.fn();
|
|
48
|
-
const _render2 = render(_jsx(FileDrop, {
|
|
49
|
-
renderLabel: "filedrop",
|
|
50
|
-
inputRef: inputRef
|
|
51
|
-
})),
|
|
52
|
-
container = _render2.container;
|
|
53
|
-
const input = container.querySelector('input[class$="-fileDrop__input"]');
|
|
54
|
-
expect(inputRef).toHaveBeenCalledWith(input);
|
|
55
|
-
});
|
|
56
|
-
it('should render', async () => {
|
|
57
|
-
const _render3 = render(_FileDrop || (_FileDrop = _jsx(FileDrop, {
|
|
58
|
-
renderLabel: "fake label"
|
|
59
|
-
}))),
|
|
60
|
-
container = _render3.container;
|
|
61
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
62
|
-
expect(fileDrop).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
it('should meet a11y standards', async () => {
|
|
65
|
-
const _render4 = render(_FileDrop2 || (_FileDrop2 = _jsx(FileDrop, {
|
|
66
|
-
renderLabel: "fake label"
|
|
67
|
-
}))),
|
|
68
|
-
container = _render4.container;
|
|
69
|
-
const axeCheck = await runAxeCheck(container);
|
|
70
|
-
expect(axeCheck).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
describe('interactions', async () => {
|
|
73
|
-
it('should functionally disable the input if `interaction` is set to disabled', async () => {
|
|
74
|
-
const _render5 = render(_FileDrop3 || (_FileDrop3 = _jsx(FileDrop, {
|
|
75
|
-
renderLabel: "Some label",
|
|
76
|
-
interaction: "disabled"
|
|
77
|
-
}))),
|
|
78
|
-
container = _render5.container;
|
|
79
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
80
|
-
expect(fileDrop).toBeDisabled();
|
|
81
|
-
});
|
|
82
|
-
it('should functionally disable the input if `disabled` is set', async () => {
|
|
83
|
-
const _render6 = render(_FileDrop4 || (_FileDrop4 = _jsx(FileDrop, {
|
|
84
|
-
renderLabel: "Some label",
|
|
85
|
-
disabled: true
|
|
86
|
-
}))),
|
|
87
|
-
container = _render6.container;
|
|
88
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
89
|
-
expect(fileDrop).toBeDisabled();
|
|
90
|
-
});
|
|
91
|
-
it('should functionally disable the input if `interaction` is set to readonly', async () => {
|
|
92
|
-
const _render7 = render(_FileDrop5 || (_FileDrop5 = _jsx(FileDrop, {
|
|
93
|
-
renderLabel: "Some label",
|
|
94
|
-
interaction: "readonly"
|
|
95
|
-
}))),
|
|
96
|
-
container = _render7.container;
|
|
97
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
98
|
-
expect(fileDrop).toBeDisabled();
|
|
99
|
-
});
|
|
100
|
-
it('should functionally disable the input if `readOnly` is set', async () => {
|
|
101
|
-
const _render8 = render(_FileDrop6 || (_FileDrop6 = _jsx(FileDrop, {
|
|
102
|
-
renderLabel: "Some label",
|
|
103
|
-
readOnly: true
|
|
104
|
-
}))),
|
|
105
|
-
container = _render8.container;
|
|
106
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
107
|
-
expect(fileDrop).toBeDisabled();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe('label handling', async () => {
|
|
111
|
-
it('renders element label directly', async () => {
|
|
112
|
-
const label = _section || (_section = _jsx("section", {
|
|
113
|
-
id: "test-id",
|
|
114
|
-
children: "This is an element label"
|
|
115
|
-
}));
|
|
116
|
-
const _render9 = render(_jsx(FileDrop, {
|
|
117
|
-
renderLabel: label
|
|
118
|
-
})),
|
|
119
|
-
container = _render9.container;
|
|
120
|
-
const renderedLabel = container.querySelector('[id="test-id"]');
|
|
121
|
-
expect(renderedLabel).toBeInTheDocument();
|
|
122
|
-
});
|
|
123
|
-
it('passes isDragAccepted and isDragRejected boolean props to component label', async () => {
|
|
124
|
-
let result = {};
|
|
125
|
-
const label = props => {
|
|
126
|
-
result = {
|
|
127
|
-
...props
|
|
128
|
-
};
|
|
129
|
-
return null;
|
|
130
|
-
};
|
|
131
|
-
render(_jsx(FileDrop, {
|
|
132
|
-
renderLabel: label
|
|
133
|
-
}));
|
|
134
|
-
expect(typeof result.isDragAccepted).toBe('boolean');
|
|
135
|
-
expect(typeof result.isDragRejected).toBe('boolean');
|
|
136
|
-
});
|
|
137
|
-
it(`label component's props are false by default`, async () => {
|
|
138
|
-
let result = {};
|
|
139
|
-
const label = props => {
|
|
140
|
-
result = {
|
|
141
|
-
...props
|
|
142
|
-
};
|
|
143
|
-
return null;
|
|
144
|
-
};
|
|
145
|
-
render(_jsx(FileDrop, {
|
|
146
|
-
renderLabel: label
|
|
147
|
-
}));
|
|
148
|
-
expect(result.isDragAccepted).toBe(false);
|
|
149
|
-
expect(result.isDragRejected).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
import { expect } from 'vitest';
|
|
25
|
-
import { accepts } from '../accepts';
|
|
26
|
-
describe('accepts', () => {
|
|
27
|
-
const dropImage = new File([], 'whale whale whale.jpg', {
|
|
28
|
-
type: 'image/jpeg'
|
|
29
|
-
});
|
|
30
|
-
const dropFile = new File([], 'whale oil production.pdf', {
|
|
31
|
-
type: 'application/pdf'
|
|
32
|
-
});
|
|
33
|
-
const chromeDragEnterFile = new File([], '', {
|
|
34
|
-
type: 'image/jpeg'
|
|
35
|
-
});
|
|
36
|
-
const firefoxDragEnterFile = new File([], '', {
|
|
37
|
-
type: 'application/x-moz-file'
|
|
38
|
-
});
|
|
39
|
-
it('should take image/* to mean any image type', () => {
|
|
40
|
-
expect(accepts(dropImage, 'image/*')).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
it('should reject anything that is not an image, given image/*', () => {
|
|
43
|
-
expect(accepts(dropFile, 'image/*')).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
it('should match the exact file extensions given', () => {
|
|
46
|
-
expect(accepts(dropImage, '.jpg')).toBe(true);
|
|
47
|
-
expect(accepts(dropImage, '.jpg, .png')).toBe(true);
|
|
48
|
-
expect(accepts(dropImage, '.png')).toBe(false);
|
|
49
|
-
expect(accepts(dropFile, '.jpg, .pdf')).toBe(true);
|
|
50
|
-
expect(accepts(dropFile, '.jpg, .pdf')).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it('should handle chrome dragenter file data', () => {
|
|
53
|
-
expect(accepts(chromeDragEnterFile, 'image/*')).toBe(true);
|
|
54
|
-
expect(accepts(chromeDragEnterFile, '.jpeg')).toBe(true);
|
|
55
|
-
expect(accepts(chromeDragEnterFile, '.png')).not.toBe(true);
|
|
56
|
-
expect(accepts(chromeDragEnterFile, '.pdf')).not.toBe(true);
|
|
57
|
-
});
|
|
58
|
-
it(`should always be true for firefox's dragenter file data`, () => {
|
|
59
|
-
expect(accepts(firefoxDragEnterFile, 'image/*')).toBe(true);
|
|
60
|
-
expect(accepts(firefoxDragEnterFile, '.jpeg')).toBe(true);
|
|
61
|
-
expect(accepts(firefoxDragEnterFile, '.png')).toBe(true);
|
|
62
|
-
expect(accepts(firefoxDragEnterFile, '.pdf')).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
it('allows extensions without leading dot', () => {
|
|
65
|
-
expect(accepts(dropImage, 'jpg, png')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
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 { expect } from 'vitest';
|
|
26
|
-
import { getEventFiles } from '../getEventFiles';
|
|
27
|
-
describe('getEventFiles', () => {
|
|
28
|
-
const chromeDragEnter = {
|
|
29
|
-
dataTransfer: {
|
|
30
|
-
dropEffect: 'none',
|
|
31
|
-
effectAllowed: 'all',
|
|
32
|
-
files: [],
|
|
33
|
-
items: [{
|
|
34
|
-
kind: 'file',
|
|
35
|
-
type: 'image/jpeg'
|
|
36
|
-
}],
|
|
37
|
-
types: ['Files']
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const firefoxDragEnter = {
|
|
41
|
-
dataTransfer: {
|
|
42
|
-
dropEffect: 'move',
|
|
43
|
-
effectAllowed: 'uninitialized',
|
|
44
|
-
files: [],
|
|
45
|
-
items: [{
|
|
46
|
-
kind: 'file',
|
|
47
|
-
type: 'application/x-moz-file'
|
|
48
|
-
}],
|
|
49
|
-
types: ['application/x-moz-file', 'Files']
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const safariDragEnter = {
|
|
53
|
-
dataTransfer: {
|
|
54
|
-
dropEffect: 'none',
|
|
55
|
-
effectAllowed: 'all',
|
|
56
|
-
files: [],
|
|
57
|
-
types: []
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
it('should return items on chrome dragenter event', () => {
|
|
61
|
-
expect(getEventFiles(chromeDragEnter)).toEqual(chromeDragEnter.dataTransfer.items);
|
|
62
|
-
});
|
|
63
|
-
it('should return items on a firefox dragenter event', () => {
|
|
64
|
-
expect(getEventFiles(firefoxDragEnter)).toEqual(firefoxDragEnter.dataTransfer.items);
|
|
65
|
-
});
|
|
66
|
-
it('should return empty array on a safari dragenter event', () => {
|
|
67
|
-
expect(getEventFiles(safariDragEnter).length).toEqual(0);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _vitest = require("vitest");
|
|
5
|
-
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
6
|
-
require("@testing-library/jest-dom");
|
|
7
|
-
var _index = require("../index");
|
|
8
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
-
var _FileDrop, _FileDrop2, _FileDrop3, _FileDrop4, _FileDrop5, _FileDrop6, _section;
|
|
10
|
-
/*
|
|
11
|
-
* The MIT License (MIT)
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
-
*
|
|
15
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
-
* in the Software without restriction, including without limitation the rights
|
|
18
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
-
* furnished to do so, subject to the following conditions:
|
|
21
|
-
*
|
|
22
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
-
* copies or substantial portions of the Software.
|
|
24
|
-
*
|
|
25
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
-
* SOFTWARE.
|
|
32
|
-
*/
|
|
33
|
-
describe('<FileDrop/>', () => {
|
|
34
|
-
it('should focus the input when focus is called', async () => {
|
|
35
|
-
let inputEl;
|
|
36
|
-
const _render = (0, _react.render)((0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
37
|
-
renderLabel: "filedrop",
|
|
38
|
-
inputRef: el => {
|
|
39
|
-
inputEl = el;
|
|
40
|
-
}
|
|
41
|
-
})),
|
|
42
|
-
container = _render.container;
|
|
43
|
-
const input = container.querySelector('input[class$="-fileDrop__input"]');
|
|
44
|
-
inputEl.focus();
|
|
45
|
-
expect(input).toHaveFocus();
|
|
46
|
-
});
|
|
47
|
-
it('should provide an inputRef prop', async () => {
|
|
48
|
-
const inputRef = _vitest.vi.fn();
|
|
49
|
-
const _render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
50
|
-
renderLabel: "filedrop",
|
|
51
|
-
inputRef: inputRef
|
|
52
|
-
})),
|
|
53
|
-
container = _render2.container;
|
|
54
|
-
const input = container.querySelector('input[class$="-fileDrop__input"]');
|
|
55
|
-
expect(inputRef).toHaveBeenCalledWith(input);
|
|
56
|
-
});
|
|
57
|
-
it('should render', async () => {
|
|
58
|
-
const _render3 = (0, _react.render)(_FileDrop || (_FileDrop = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
59
|
-
renderLabel: "fake label"
|
|
60
|
-
}))),
|
|
61
|
-
container = _render3.container;
|
|
62
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
63
|
-
expect(fileDrop).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
it('should meet a11y standards', async () => {
|
|
66
|
-
const _render4 = (0, _react.render)(_FileDrop2 || (_FileDrop2 = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
67
|
-
renderLabel: "fake label"
|
|
68
|
-
}))),
|
|
69
|
-
container = _render4.container;
|
|
70
|
-
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
71
|
-
expect(axeCheck).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
describe('interactions', async () => {
|
|
74
|
-
it('should functionally disable the input if `interaction` is set to disabled', async () => {
|
|
75
|
-
const _render5 = (0, _react.render)(_FileDrop3 || (_FileDrop3 = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
76
|
-
renderLabel: "Some label",
|
|
77
|
-
interaction: "disabled"
|
|
78
|
-
}))),
|
|
79
|
-
container = _render5.container;
|
|
80
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
81
|
-
expect(fileDrop).toBeDisabled();
|
|
82
|
-
});
|
|
83
|
-
it('should functionally disable the input if `disabled` is set', async () => {
|
|
84
|
-
const _render6 = (0, _react.render)(_FileDrop4 || (_FileDrop4 = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
85
|
-
renderLabel: "Some label",
|
|
86
|
-
disabled: true
|
|
87
|
-
}))),
|
|
88
|
-
container = _render6.container;
|
|
89
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
90
|
-
expect(fileDrop).toBeDisabled();
|
|
91
|
-
});
|
|
92
|
-
it('should functionally disable the input if `interaction` is set to readonly', async () => {
|
|
93
|
-
const _render7 = (0, _react.render)(_FileDrop5 || (_FileDrop5 = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
94
|
-
renderLabel: "Some label",
|
|
95
|
-
interaction: "readonly"
|
|
96
|
-
}))),
|
|
97
|
-
container = _render7.container;
|
|
98
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
99
|
-
expect(fileDrop).toBeDisabled();
|
|
100
|
-
});
|
|
101
|
-
it('should functionally disable the input if `readOnly` is set', async () => {
|
|
102
|
-
const _render8 = (0, _react.render)(_FileDrop6 || (_FileDrop6 = (0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
103
|
-
renderLabel: "Some label",
|
|
104
|
-
readOnly: true
|
|
105
|
-
}))),
|
|
106
|
-
container = _render8.container;
|
|
107
|
-
const fileDrop = container.querySelector('[class$="-fileDrop__input"]');
|
|
108
|
-
expect(fileDrop).toBeDisabled();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe('label handling', async () => {
|
|
112
|
-
it('renders element label directly', async () => {
|
|
113
|
-
const label = _section || (_section = (0, _jsxRuntime.jsx)("section", {
|
|
114
|
-
id: "test-id",
|
|
115
|
-
children: "This is an element label"
|
|
116
|
-
}));
|
|
117
|
-
const _render9 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
118
|
-
renderLabel: label
|
|
119
|
-
})),
|
|
120
|
-
container = _render9.container;
|
|
121
|
-
const renderedLabel = container.querySelector('[id="test-id"]');
|
|
122
|
-
expect(renderedLabel).toBeInTheDocument();
|
|
123
|
-
});
|
|
124
|
-
it('passes isDragAccepted and isDragRejected boolean props to component label', async () => {
|
|
125
|
-
let result = {};
|
|
126
|
-
const label = props => {
|
|
127
|
-
result = {
|
|
128
|
-
...props
|
|
129
|
-
};
|
|
130
|
-
return null;
|
|
131
|
-
};
|
|
132
|
-
(0, _react.render)((0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
133
|
-
renderLabel: label
|
|
134
|
-
}));
|
|
135
|
-
expect(typeof result.isDragAccepted).toBe('boolean');
|
|
136
|
-
expect(typeof result.isDragRejected).toBe('boolean');
|
|
137
|
-
});
|
|
138
|
-
it(`label component's props are false by default`, async () => {
|
|
139
|
-
let result = {};
|
|
140
|
-
const label = props => {
|
|
141
|
-
result = {
|
|
142
|
-
...props
|
|
143
|
-
};
|
|
144
|
-
return null;
|
|
145
|
-
};
|
|
146
|
-
(0, _react.render)((0, _jsxRuntime.jsx)(_index.FileDrop, {
|
|
147
|
-
renderLabel: label
|
|
148
|
-
}));
|
|
149
|
-
expect(result.isDragAccepted).toBe(false);
|
|
150
|
-
expect(result.isDragRejected).toBe(false);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _accepts = require("../accepts");
|
|
5
|
-
/*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
9
|
-
*
|
|
10
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
* in the Software without restriction, including without limitation the rights
|
|
13
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
* furnished to do so, subject to the following conditions:
|
|
16
|
-
*
|
|
17
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
* copies or substantial portions of the Software.
|
|
19
|
-
*
|
|
20
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
* SOFTWARE.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
describe('accepts', () => {
|
|
30
|
-
const dropImage = new File([], 'whale whale whale.jpg', {
|
|
31
|
-
type: 'image/jpeg'
|
|
32
|
-
});
|
|
33
|
-
const dropFile = new File([], 'whale oil production.pdf', {
|
|
34
|
-
type: 'application/pdf'
|
|
35
|
-
});
|
|
36
|
-
const chromeDragEnterFile = new File([], '', {
|
|
37
|
-
type: 'image/jpeg'
|
|
38
|
-
});
|
|
39
|
-
const firefoxDragEnterFile = new File([], '', {
|
|
40
|
-
type: 'application/x-moz-file'
|
|
41
|
-
});
|
|
42
|
-
it('should take image/* to mean any image type', () => {
|
|
43
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropImage, 'image/*')).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
it('should reject anything that is not an image, given image/*', () => {
|
|
46
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropFile, 'image/*')).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
it('should match the exact file extensions given', () => {
|
|
49
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropImage, '.jpg')).toBe(true);
|
|
50
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropImage, '.jpg, .png')).toBe(true);
|
|
51
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropImage, '.png')).toBe(false);
|
|
52
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropFile, '.jpg, .pdf')).toBe(true);
|
|
53
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropFile, '.jpg, .pdf')).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
it('should handle chrome dragenter file data', () => {
|
|
56
|
-
(0, _vitest.expect)((0, _accepts.accepts)(chromeDragEnterFile, 'image/*')).toBe(true);
|
|
57
|
-
(0, _vitest.expect)((0, _accepts.accepts)(chromeDragEnterFile, '.jpeg')).toBe(true);
|
|
58
|
-
(0, _vitest.expect)((0, _accepts.accepts)(chromeDragEnterFile, '.png')).not.toBe(true);
|
|
59
|
-
(0, _vitest.expect)((0, _accepts.accepts)(chromeDragEnterFile, '.pdf')).not.toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it(`should always be true for firefox's dragenter file data`, () => {
|
|
62
|
-
(0, _vitest.expect)((0, _accepts.accepts)(firefoxDragEnterFile, 'image/*')).toBe(true);
|
|
63
|
-
(0, _vitest.expect)((0, _accepts.accepts)(firefoxDragEnterFile, '.jpeg')).toBe(true);
|
|
64
|
-
(0, _vitest.expect)((0, _accepts.accepts)(firefoxDragEnterFile, '.png')).toBe(true);
|
|
65
|
-
(0, _vitest.expect)((0, _accepts.accepts)(firefoxDragEnterFile, '.pdf')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('allows extensions without leading dot', () => {
|
|
68
|
-
(0, _vitest.expect)((0, _accepts.accepts)(dropImage, 'jpg, png')).toBe(true);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _getEventFiles = require("../getEventFiles");
|
|
5
|
-
/*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
9
|
-
*
|
|
10
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
* in the Software without restriction, including without limitation the rights
|
|
13
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
* furnished to do so, subject to the following conditions:
|
|
16
|
-
*
|
|
17
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
* copies or substantial portions of the Software.
|
|
19
|
-
*
|
|
20
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
* SOFTWARE.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
describe('getEventFiles', () => {
|
|
30
|
-
const chromeDragEnter = {
|
|
31
|
-
dataTransfer: {
|
|
32
|
-
dropEffect: 'none',
|
|
33
|
-
effectAllowed: 'all',
|
|
34
|
-
files: [],
|
|
35
|
-
items: [{
|
|
36
|
-
kind: 'file',
|
|
37
|
-
type: 'image/jpeg'
|
|
38
|
-
}],
|
|
39
|
-
types: ['Files']
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const firefoxDragEnter = {
|
|
43
|
-
dataTransfer: {
|
|
44
|
-
dropEffect: 'move',
|
|
45
|
-
effectAllowed: 'uninitialized',
|
|
46
|
-
files: [],
|
|
47
|
-
items: [{
|
|
48
|
-
kind: 'file',
|
|
49
|
-
type: 'application/x-moz-file'
|
|
50
|
-
}],
|
|
51
|
-
types: ['application/x-moz-file', 'Files']
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const safariDragEnter = {
|
|
55
|
-
dataTransfer: {
|
|
56
|
-
dropEffect: 'none',
|
|
57
|
-
effectAllowed: 'all',
|
|
58
|
-
files: [],
|
|
59
|
-
types: []
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
it('should return items on chrome dragenter event', () => {
|
|
63
|
-
(0, _vitest.expect)((0, _getEventFiles.getEventFiles)(chromeDragEnter)).toEqual(chromeDragEnter.dataTransfer.items);
|
|
64
|
-
});
|
|
65
|
-
it('should return items on a firefox dragenter event', () => {
|
|
66
|
-
(0, _vitest.expect)((0, _getEventFiles.getEventFiles)(firefoxDragEnter)).toEqual(firefoxDragEnter.dataTransfer.items);
|
|
67
|
-
});
|
|
68
|
-
it('should return empty array on a safari dragenter event', () => {
|
|
69
|
-
(0, _vitest.expect)((0, _getEventFiles.getEventFiles)(safariDragEnter).length).toEqual(0);
|
|
70
|
-
});
|
|
71
|
-
});
|