@popsure/dirty-swan 0.38.1 → 0.38.3

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.
@@ -19,21 +19,21 @@ import '../../index-da10b7ad.js';
19
19
  var mockOnFileSelect = jest.fn();
20
20
  var mockOnRemoveFile = jest.fn();
21
21
  var file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });
22
- var inputTestId = "ds-drop-input";
23
- var spinnerTestId = "ds-filecell-spinner";
24
- var progressbarTestId = "ds-filecell-progressbar";
22
+ var inputTestId = 'ds-drop-input';
23
+ var spinnerTestId = 'ds-filecell-spinner';
24
+ var progressbarTestId = 'ds-filecell-progressbar';
25
25
  var uploadedFilesMock = {
26
- id: "123",
27
- name: "File name",
26
+ id: '123',
27
+ name: 'File name',
28
28
  progress: 100,
29
- type: "jpg",
29
+ type: 'jpg',
30
30
  };
31
31
  var setup = function (_a) {
32
32
  var _b = _a.uploadedFiles, uploadedFiles = _b === void 0 ? [] : _b, _c = _a.uploading, uploading = _c === void 0 ? false : _c, rest = __rest(_a, ["uploadedFiles", "uploading"]);
33
33
  return customRender(jsx(MultiDropzone, __assign({}, rest, { uploadedFiles: uploadedFiles, uploading: uploading, onFileSelect: mockOnFileSelect, onRemoveFile: mockOnRemoveFile }), void 0));
34
34
  };
35
35
  describe('MultiDropzone component', function () {
36
- it("should call onFileSelect on files change", function () { return __awaiter(void 0, void 0, void 0, function () {
36
+ it('should call onFileSelect on files change', function () { return __awaiter(void 0, void 0, void 0, function () {
37
37
  var _a, getByTestId, user, files;
38
38
  return __generator(this, function (_b) {
39
39
  switch (_b.label) {
@@ -49,14 +49,17 @@ describe('MultiDropzone component', function () {
49
49
  });
50
50
  }); });
51
51
  describe('Error states', function () {
52
- it("should show max files error message", function () {
52
+ it('should show max files error message', function () {
53
53
  var screen = setup({
54
54
  maxFiles: 1,
55
- uploadedFiles: [uploadedFilesMock, __assign(__assign({}, uploadedFilesMock), { id: "222" })],
55
+ uploadedFiles: [
56
+ uploadedFilesMock,
57
+ __assign(__assign({}, uploadedFilesMock), { id: '222' }),
58
+ ],
56
59
  });
57
- expect(screen.getByText("Too many files.")).toBeVisible();
60
+ expect(screen.getByText('Too many files.')).toBeVisible();
58
61
  });
59
- it("should show max file size error message", function () { return __awaiter(void 0, void 0, void 0, function () {
62
+ it('should show max file size error message', function () { return __awaiter(void 0, void 0, void 0, function () {
60
63
  var _a, getByTestId, getByText, user, bigFile;
61
64
  return __generator(this, function (_b) {
62
65
  switch (_b.label) {
@@ -67,17 +70,17 @@ describe('MultiDropzone component', function () {
67
70
  return [4 /*yield*/, user.upload(getByTestId(inputTestId), [bigFile])];
68
71
  case 1:
69
72
  _b.sent();
70
- expect(getByText("File is too large. It must be less than 10 Bytes.")).toBeInTheDocument();
73
+ expect(getByText('File is too large. It must be less than 10 Bytes.')).toBeInTheDocument();
71
74
  return [2 /*return*/];
72
75
  }
73
76
  });
74
77
  }); });
75
- it("should show wrong filetype error message", function () { return __awaiter(void 0, void 0, void 0, function () {
78
+ it('should show wrong filetype error message', function () { return __awaiter(void 0, void 0, void 0, function () {
76
79
  var _a, getByTestId, getByText, input;
77
80
  return __generator(this, function (_b) {
78
81
  switch (_b.label) {
79
82
  case 0:
80
- _a = setup({ accept: "document" }), getByTestId = _a.getByTestId, getByText = _a.getByText;
83
+ _a = setup({ accept: 'document' }), getByTestId = _a.getByTestId, getByText = _a.getByText;
81
84
  input = getByTestId(inputTestId);
82
85
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
83
86
  return __generator(this, function (_a) {
@@ -89,17 +92,19 @@ describe('MultiDropzone component', function () {
89
92
  }); })];
90
93
  case 1:
91
94
  _b.sent();
92
- expect(getByText("File type must be one of DOC, DOCX, PDF")).toBeInTheDocument();
95
+ expect(getByText('File type must be one of DOC, DOCX, PDF')).toBeInTheDocument();
93
96
  return [2 /*return*/];
94
97
  }
95
98
  });
96
99
  }); });
97
- it("should remove wrong filetype error message", function () { return __awaiter(void 0, void 0, void 0, function () {
100
+ it('should remove wrong filetype error message', function () { return __awaiter(void 0, void 0, void 0, function () {
98
101
  var _a, getByAltText, getByTestId, queryByText, user, input;
99
102
  return __generator(this, function (_b) {
100
103
  switch (_b.label) {
101
104
  case 0:
102
- _a = setup({ accept: "document" }), getByAltText = _a.getByAltText, getByTestId = _a.getByTestId, queryByText = _a.queryByText, user = _a.user;
105
+ _a = setup({
106
+ accept: 'document',
107
+ }), getByAltText = _a.getByAltText, getByTestId = _a.getByTestId, queryByText = _a.queryByText, user = _a.user;
103
108
  input = getByTestId(inputTestId);
104
109
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
105
110
  return __generator(this, function (_a) {
@@ -111,88 +116,103 @@ describe('MultiDropzone component', function () {
111
116
  }); })];
112
117
  case 1:
113
118
  _b.sent();
114
- return [4 /*yield*/, user.click(getByAltText("remove"))];
119
+ return [4 /*yield*/, user.click(getByAltText('remove'))];
115
120
  case 2:
116
121
  _b.sent();
117
- expect(queryByText("File type must be one of DOC, DOCX, PDF")).not.toBeInTheDocument();
122
+ expect(queryByText('File type must be one of DOC, DOCX, PDF')).not.toBeInTheDocument();
118
123
  return [2 /*return*/];
119
124
  }
120
125
  });
121
126
  }); });
122
127
  });
123
128
  describe('Copy text', function () {
124
- it("should show uploader text", function () {
129
+ it('should show uploader text', function () {
125
130
  var screen = setup({});
126
- expect(screen.getByText("Choose file or drag & drop")).toBeInTheDocument();
131
+ expect(screen.getByText('Choose file or drag & drop')).toBeInTheDocument();
127
132
  });
128
- it("should show uploader text translated", function () {
129
- var instructionsText = "Drag drop file";
133
+ it('should show uploader text translated', function () {
134
+ var instructionsText = 'Drag drop file';
130
135
  var screen = setup({
131
- textOverrides: { instructionsText: instructionsText }
136
+ textOverrides: { instructionsText: instructionsText },
132
137
  });
133
138
  expect(screen.getByText(instructionsText)).toBeInTheDocument();
134
139
  });
135
- it("should show image accept file type label", function () {
136
- var screen = setup({ accept: "image" });
137
- expect(screen.getByText("Supports HEIC, BMP, JPEG, JPG, PNG")).toBeInTheDocument();
140
+ it('should show image accept file type label', function () {
141
+ var screen = setup({ accept: 'image' });
142
+ expect(screen.getByText('Supports HEIC, BMP, JPEG, JPG, PNG')).toBeInTheDocument();
138
143
  });
139
- it("should show document accept file type label", function () {
140
- var screen = setup({ accept: "document" });
141
- expect(screen.getByText("Supports DOC, DOCX, PDF")).toBeInTheDocument();
144
+ it('should show document accept file type label', function () {
145
+ var screen = setup({ accept: 'document' });
146
+ expect(screen.getByText('Supports DOC, DOCX, PDF')).toBeInTheDocument();
142
147
  });
143
- it("should custom document accept file type label", function () {
144
- var screen = setup({ accept: {
145
- "application/pdf": [".pdf"],
146
- "image/jpg": [".jpg"],
147
- } });
148
- expect(screen.getByText("Supports PDF, JPG")).toBeInTheDocument();
148
+ it('should custom document accept file type label', function () {
149
+ var screen = setup({
150
+ accept: {
151
+ 'application/pdf': ['.pdf'],
152
+ 'image/jpg': ['.jpg'],
153
+ },
154
+ });
155
+ expect(screen.getByText('Supports PDF, JPG')).toBeInTheDocument();
149
156
  });
150
- it("should show disabled text if is uploading", function () {
157
+ it('should show disabled text if is uploading', function () {
151
158
  var screen = setup({ uploading: true });
152
- expect(screen.getByText("Please wait while uploading file...")).toBeInTheDocument();
159
+ expect(screen.getByText('Please wait while uploading file...')).toBeInTheDocument();
160
+ });
161
+ it('should associate input with its label', function () {
162
+ var getByLabelText = setup({}).getByLabelText;
163
+ var input = getByLabelText('Choose file or drag & drop');
164
+ expect(input).toBeInTheDocument();
153
165
  });
154
166
  });
155
167
  describe('Uploaded files', function () {
156
- it("should show uploaded files", function () {
168
+ it('should show uploaded files', function () {
157
169
  var screen = setup({
158
170
  uploadedFiles: [uploadedFilesMock],
159
171
  });
160
172
  expect(screen.getByText(uploadedFilesMock.name)).toBeInTheDocument();
161
173
  });
162
- it("should call onRemoveFile with uploaded file id", function () {
174
+ it('should call onRemoveFile with uploaded file id', function () {
163
175
  var screen = setup({
164
176
  uploadedFiles: [uploadedFilesMock],
165
177
  });
166
- screen.getByAltText("remove").click();
178
+ screen.getByAltText('remove').click();
167
179
  expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);
168
180
  });
169
- it("should show uploaded file with uploading label", function () {
181
+ it('should show uploaded file with uploading label', function () {
170
182
  var screen = setup({
171
183
  uploadedFiles: [__assign(__assign({}, uploadedFilesMock), { progress: 50 })],
172
184
  });
173
- expect(screen.getByText("Uploading...")).toBeInTheDocument();
185
+ expect(screen.getByText('Uploading...')).toBeInTheDocument();
174
186
  });
175
- it("should show uploaded file with progress bar", function () {
187
+ it('should show uploaded file with progress bar', function () {
176
188
  var screen = setup({
177
- uploadedFiles: [__assign(__assign({}, uploadedFilesMock), { progress: 50 })],
189
+ uploadedFiles: [
190
+ __assign(__assign({}, uploadedFilesMock), { progress: 50 }),
191
+ ],
178
192
  });
179
193
  expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();
180
194
  });
181
- it("should show uploaded file with no progress bar", function () {
195
+ it('should show uploaded file with no progress bar', function () {
182
196
  var screen = setup({
183
- uploadedFiles: [__assign(__assign({}, uploadedFilesMock), { progress: 50, showProgressBar: false })],
197
+ uploadedFiles: [
198
+ __assign(__assign({}, uploadedFilesMock), { progress: 50, showProgressBar: false }),
199
+ ],
184
200
  });
185
201
  expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();
186
202
  });
187
- it("should show uploaded file with loading spinner", function () {
203
+ it('should show uploaded file with loading spinner', function () {
188
204
  var screen = setup({
189
- uploadedFiles: [__assign(__assign({}, uploadedFilesMock), { progress: 50, showLoadingSpinner: true })],
205
+ uploadedFiles: [
206
+ __assign(__assign({}, uploadedFilesMock), { progress: 50, showLoadingSpinner: true }),
207
+ ],
190
208
  });
191
209
  expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();
192
210
  });
193
- it("should show uploaded file with no loading spinner", function () {
211
+ it('should show uploaded file with no loading spinner', function () {
194
212
  var screen = setup({
195
- uploadedFiles: [__assign(__assign({}, uploadedFilesMock), { progress: 50, showLoadingSpinner: false })],
213
+ uploadedFiles: [
214
+ __assign(__assign({}, uploadedFilesMock), { progress: 50, showLoadingSpinner: false }),
215
+ ],
196
216
  });
197
217
  expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();
198
218
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/multiDropzone/index.test.tsx"],"sourcesContent":["import { act, fireEvent, render } from '../../util/testUtils';\nimport '@testing-library/jest-dom';\n\nimport { MultiDropzone, MultiDropzoneProps } from '.';\n\nconst mockOnFileSelect = jest.fn();\nconst mockOnRemoveFile = jest.fn();\nconst file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });\n\nconst inputTestId = \"ds-drop-input\";\nconst spinnerTestId = \"ds-filecell-spinner\";\nconst progressbarTestId = \"ds-filecell-progressbar\";\nconst uploadedFilesMock = {\n id: \"123\",\n name: \"File name\",\n progress: 100,\n type: \"jpg\",\n};\n\nconst setup = ({\n uploadedFiles = [],\n uploading = false,\n ...rest\n}: Partial<MultiDropzoneProps>) => {\n return render(\n <MultiDropzone\n {...rest}\n uploadedFiles={uploadedFiles}\n uploading={uploading}\n onFileSelect={mockOnFileSelect}\n onRemoveFile={mockOnRemoveFile}\n />\n );\n};\n\ndescribe('MultiDropzone component', () => {\n it(\"should call onFileSelect on files change\", async () => {\n const { getByTestId, user } = setup({});\n const files = [file, file];\n\n await user.upload(getByTestId(inputTestId), files);\n\n expect(mockOnFileSelect).toHaveBeenCalledWith(files);\n });\n\n describe('Error states', () => {\n it(\"should show max files error message\", () => {\n const screen = setup({\n maxFiles: 1,\n uploadedFiles: [uploadedFilesMock, {\n ...uploadedFilesMock,\n id: \"222\"\n }],\n });\n \n expect(screen.getByText(\"Too many files.\")).toBeVisible();\n });\n\n it(\"should show max file size error message\", async () => {\n const { getByTestId, getByText, user } = setup({ maxSize: 10 });\n const bigFile = file;\n Object.defineProperty(bigFile, 'size', { value: 1024 });\n\n await user.upload(getByTestId(inputTestId), [bigFile]);\n\n expect(\n getByText(\"File is too large. It must be less than 10 Bytes.\")\n ).toBeInTheDocument();\n });\n\n it(\"should show wrong filetype error message\", async () => {\n const { getByTestId, getByText } = setup({ accept: \"document\" });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n expect(\n getByText(\"File type must be one of DOC, DOCX, PDF\")\n ).toBeInTheDocument();\n });\n\n it(\"should remove wrong filetype error message\", async () => {\n const { getByAltText, getByTestId, queryByText, user } = setup({ accept: \"document\" });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n await user.click(getByAltText(\"remove\"));\n\n expect(queryByText(\"File type must be one of DOC, DOCX, PDF\")).not.toBeInTheDocument();\n });\n });\n\n describe('Copy text', () => {\n it(\"should show uploader text\", () => {\n const screen = setup({});\n\n expect(screen.getByText(\"Choose file or drag & drop\")).toBeInTheDocument();\n });\n\n it(\"should show uploader text translated\", () => {\n const instructionsText = \"Drag drop file\";\n const screen = setup({\n textOverrides: { instructionsText }\n });\n\n expect(screen.getByText(instructionsText)).toBeInTheDocument();\n });\n\n it(\"should show image accept file type label\", () => {\n const screen = setup({ accept: \"image\" });\n\n expect(\n screen.getByText(\"Supports HEIC, BMP, JPEG, JPG, PNG\")\n ).toBeInTheDocument();\n });\n\n it(\"should show document accept file type label\", () => {\n const screen = setup({ accept: \"document\" });\n\n expect(\n screen.getByText(\"Supports DOC, DOCX, PDF\")\n ).toBeInTheDocument();\n });\n\n it(\"should custom document accept file type label\", () => {\n const screen = setup({ accept: {\n \"application/pdf\": [\".pdf\"],\n \"image/jpg\": [\".jpg\"],\n } });\n\n expect(\n screen.getByText(\"Supports PDF, JPG\")\n ).toBeInTheDocument();\n });\n\n it(\"should show disabled text if is uploading\", () => {\n const screen = setup({ uploading: true });\n\n expect(\n screen.getByText(\"Please wait while uploading file...\")\n ).toBeInTheDocument();\n });\n });\n\n describe('Uploaded files', () => {\n it(\"should show uploaded files\", () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n expect(\n screen.getByText(uploadedFilesMock.name)\n ).toBeInTheDocument();\n });\n\n it(\"should call onRemoveFile with uploaded file id\", () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n screen.getByAltText(\"remove\").click();\n\n expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);\n });\n\n it(\"should show uploaded file with uploading label\", () => {\n const screen = setup({\n uploadedFiles: [{ ...uploadedFilesMock, progress: 50 }],\n });\n\n expect(screen.getByText(\"Uploading...\")).toBeInTheDocument();\n });\n\n it(\"should show uploaded file with progress bar\", () => {\n const screen = setup({\n uploadedFiles: [{\n ...uploadedFilesMock,\n progress: 50,\n }],\n });\n\n expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();\n });\n\n it(\"should show uploaded file with no progress bar\", () => {\n const screen = setup({\n uploadedFiles: [{\n ...uploadedFilesMock,\n progress: 50,\n showProgressBar: false\n }],\n });\n\n expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();\n });\n\n it(\"should show uploaded file with loading spinner\", () => {\n const screen = setup({\n uploadedFiles: [{\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: true\n }],\n });\n\n expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();\n });\n\n it(\"should show uploaded file with no loading spinner\", () => {\n const screen = setup({\n uploadedFiles: [{\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: false\n }],\n });\n\n expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();\n });\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAM,gBAAgB,GAAG,IAAI,CAAC,EA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EAAE,uBACV,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,EAAE,IAAI,IACxB;aACH,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;SAC/D,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE;YACtD,IAAM,MAAM,GAAG,KAAK,CAAC;gBACnB,aAAa,EAAE,uBACV,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,EAAE,KAAK,IACzB;aACH,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;SACrE,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/multiDropzone/index.test.tsx"],"sourcesContent":["import { act, fireEvent, render } from '../../util/testUtils';\nimport '@testing-library/jest-dom';\n\nimport { MultiDropzone, MultiDropzoneProps } from '.';\n\nconst mockOnFileSelect = jest.fn();\nconst mockOnRemoveFile = jest.fn();\nconst file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });\n\nconst inputTestId = 'ds-drop-input';\nconst spinnerTestId = 'ds-filecell-spinner';\nconst progressbarTestId = 'ds-filecell-progressbar';\nconst uploadedFilesMock = {\n id: '123',\n name: 'File name',\n progress: 100,\n type: 'jpg',\n};\n\nconst setup = ({\n uploadedFiles = [],\n uploading = false,\n ...rest\n}: Partial<MultiDropzoneProps>) => {\n return render(\n <MultiDropzone\n {...rest}\n uploadedFiles={uploadedFiles}\n uploading={uploading}\n onFileSelect={mockOnFileSelect}\n onRemoveFile={mockOnRemoveFile}\n />\n );\n};\n\ndescribe('MultiDropzone component', () => {\n it('should call onFileSelect on files change', async () => {\n const { getByTestId, user } = setup({});\n const files = [file, file];\n\n await user.upload(getByTestId(inputTestId), files);\n\n expect(mockOnFileSelect).toHaveBeenCalledWith(files);\n });\n\n describe('Error states', () => {\n it('should show max files error message', () => {\n const screen = setup({\n maxFiles: 1,\n uploadedFiles: [\n uploadedFilesMock,\n {\n ...uploadedFilesMock,\n id: '222',\n },\n ],\n });\n\n expect(screen.getByText('Too many files.')).toBeVisible();\n });\n\n it('should show max file size error message', async () => {\n const { getByTestId, getByText, user } = setup({ maxSize: 10 });\n const bigFile = file;\n Object.defineProperty(bigFile, 'size', { value: 1024 });\n\n await user.upload(getByTestId(inputTestId), [bigFile]);\n\n expect(\n getByText('File is too large. It must be less than 10 Bytes.')\n ).toBeInTheDocument();\n });\n\n it('should show wrong filetype error message', async () => {\n const { getByTestId, getByText } = setup({ accept: 'document' });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n expect(\n getByText('File type must be one of DOC, DOCX, PDF')\n ).toBeInTheDocument();\n });\n\n it('should remove wrong filetype error message', async () => {\n const { getByAltText, getByTestId, queryByText, user } = setup({\n accept: 'document',\n });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n await user.click(getByAltText('remove'));\n\n expect(\n queryByText('File type must be one of DOC, DOCX, PDF')\n ).not.toBeInTheDocument();\n });\n });\n\n describe('Copy text', () => {\n it('should show uploader text', () => {\n const screen = setup({});\n\n expect(\n screen.getByText('Choose file or drag & drop')\n ).toBeInTheDocument();\n });\n\n it('should show uploader text translated', () => {\n const instructionsText = 'Drag drop file';\n const screen = setup({\n textOverrides: { instructionsText },\n });\n\n expect(screen.getByText(instructionsText)).toBeInTheDocument();\n });\n\n it('should show image accept file type label', () => {\n const screen = setup({ accept: 'image' });\n\n expect(\n screen.getByText('Supports HEIC, BMP, JPEG, JPG, PNG')\n ).toBeInTheDocument();\n });\n\n it('should show document accept file type label', () => {\n const screen = setup({ accept: 'document' });\n\n expect(screen.getByText('Supports DOC, DOCX, PDF')).toBeInTheDocument();\n });\n\n it('should custom document accept file type label', () => {\n const screen = setup({\n accept: {\n 'application/pdf': ['.pdf'],\n 'image/jpg': ['.jpg'],\n },\n });\n\n expect(screen.getByText('Supports PDF, JPG')).toBeInTheDocument();\n });\n\n it('should show disabled text if is uploading', () => {\n const screen = setup({ uploading: true });\n\n expect(\n screen.getByText('Please wait while uploading file...')\n ).toBeInTheDocument();\n });\n\n it('should associate input with its label', () => {\n const { getByLabelText } = setup({});\n const input = getByLabelText('Choose file or drag & drop');\n\n expect(input).toBeInTheDocument();\n });\n });\n\n describe('Uploaded files', () => {\n it('should show uploaded files', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n expect(screen.getByText(uploadedFilesMock.name)).toBeInTheDocument();\n });\n\n it('should call onRemoveFile with uploaded file id', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n screen.getByAltText('remove').click();\n\n expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);\n });\n\n it('should show uploaded file with uploading label', () => {\n const screen = setup({\n uploadedFiles: [{ ...uploadedFilesMock, progress: 50 }],\n });\n\n expect(screen.getByText('Uploading...')).toBeInTheDocument();\n });\n\n it('should show uploaded file with progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n },\n ],\n });\n\n expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showProgressBar: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();\n });\n\n it('should show uploaded file with loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: true,\n },\n ],\n });\n\n expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();\n });\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAEzE,IAAM,WAAW,GAAG,eAAe,CAAC;AACpC,IAAM,aAAa,GAAG,qBAAqB,CAAC;AAC5C,IAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,IAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,IAAM,KAAK,GAAG,UAAC,EAIe;IAH5B,IAAA,qBAAkB,EAAlB,aAAa,mBAAG,EAAE,KAAA,EAClB,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACd,IAAI,cAHM,8BAId,CADQ;IAEP,OAAOA,YAAM,CACXC,IAAC,aAAa,eACR,IAAI,IACR,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,YAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,yBAAyB,EAAE;IAClC,EAAE,CAAC,0CAA0C,EAAE;;;;;oBACvC,KAAwB,KAAK,CAAC,EAAE,CAAC,EAA/B,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AE;0CAER,iBAAiB,KACpB,QAAQ,EAAE,EAAE;iBAEf;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;SACnE,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,MAAM,GAAG,KAAK,CAAC;gBACnB,aAAa,EAAE;0CAER,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,eAAe,EAAE,KAAK;iBAEzB;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;SACzE,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,MAAM,GAAG,KAAK,CAAC;gBACnB,aAAa,EAAE;0CAER,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,EAAE,IAAI;iBAE3B;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;SAC/D,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE;YACtD,IAAM,MAAM,GAAG,KAAK,CAAC;gBACnB,aAAa,EAAE;0CAER,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,EAAE,KAAK;iBAE5B;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;SACrE,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -726,4 +726,4 @@ var icons = /*#__PURE__*/Object.freeze({
726
726
  });
727
727
 
728
728
  export { icons as i };
729
- //# sourceMappingURL=index-38cf6d96.js.map
729
+ //# sourceMappingURL=index-dcf47451.js.map
@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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.38.1",
3
+ "version": "0.38.3",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -21,8 +21,12 @@ const IconWrapper = ({
21
21
  className={classNames('d-inline-block', styles.wrapper, className ?? '', {
22
22
  [`tc-${color}`]: !!color,
23
23
  })}
24
+ style={{
25
+ width: `${size}px`,
26
+ height: `${size}px`
27
+ }}
24
28
  >
25
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
29
+ <svg className='w100' viewBox="0 0 24 24" fill="none">
26
30
  {children}
27
31
  </svg>
28
32
  </span>
@@ -7,20 +7,20 @@ const mockOnFileSelect = jest.fn();
7
7
  const mockOnRemoveFile = jest.fn();
8
8
  const file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });
9
9
 
10
- const inputTestId = "ds-drop-input";
11
- const spinnerTestId = "ds-filecell-spinner";
12
- const progressbarTestId = "ds-filecell-progressbar";
10
+ const inputTestId = 'ds-drop-input';
11
+ const spinnerTestId = 'ds-filecell-spinner';
12
+ const progressbarTestId = 'ds-filecell-progressbar';
13
13
  const uploadedFilesMock = {
14
- id: "123",
15
- name: "File name",
16
- progress: 100,
17
- type: "jpg",
14
+ id: '123',
15
+ name: 'File name',
16
+ progress: 100,
17
+ type: 'jpg',
18
18
  };
19
19
 
20
20
  const setup = ({
21
- uploadedFiles = [],
22
- uploading = false,
23
- ...rest
21
+ uploadedFiles = [],
22
+ uploading = false,
23
+ ...rest
24
24
  }: Partial<MultiDropzoneProps>) => {
25
25
  return render(
26
26
  <MultiDropzone
@@ -34,7 +34,7 @@ const setup = ({
34
34
  };
35
35
 
36
36
  describe('MultiDropzone component', () => {
37
- it("should call onFileSelect on files change", async () => {
37
+ it('should call onFileSelect on files change', async () => {
38
38
  const { getByTestId, user } = setup({});
39
39
  const files = [file, file];
40
40
 
@@ -44,19 +44,22 @@ describe('MultiDropzone component', () => {
44
44
  });
45
45
 
46
46
  describe('Error states', () => {
47
- it("should show max files error message", () => {
47
+ it('should show max files error message', () => {
48
48
  const screen = setup({
49
49
  maxFiles: 1,
50
- uploadedFiles: [uploadedFilesMock, {
51
- ...uploadedFilesMock,
52
- id: "222"
53
- }],
50
+ uploadedFiles: [
51
+ uploadedFilesMock,
52
+ {
53
+ ...uploadedFilesMock,
54
+ id: '222',
55
+ },
56
+ ],
54
57
  });
55
-
56
- expect(screen.getByText("Too many files.")).toBeVisible();
58
+
59
+ expect(screen.getByText('Too many files.')).toBeVisible();
57
60
  });
58
61
 
59
- it("should show max file size error message", async () => {
62
+ it('should show max file size error message', async () => {
60
63
  const { getByTestId, getByText, user } = setup({ maxSize: 10 });
61
64
  const bigFile = file;
62
65
  Object.defineProperty(bigFile, 'size', { value: 1024 });
@@ -64,12 +67,12 @@ describe('MultiDropzone component', () => {
64
67
  await user.upload(getByTestId(inputTestId), [bigFile]);
65
68
 
66
69
  expect(
67
- getByText("File is too large. It must be less than 10 Bytes.")
70
+ getByText('File is too large. It must be less than 10 Bytes.')
68
71
  ).toBeInTheDocument();
69
72
  });
70
73
 
71
- it("should show wrong filetype error message", async () => {
72
- const { getByTestId, getByText } = setup({ accept: "document" });
74
+ it('should show wrong filetype error message', async () => {
75
+ const { getByTestId, getByText } = setup({ accept: 'document' });
73
76
  const input = getByTestId(inputTestId);
74
77
 
75
78
  await act(async () => {
@@ -79,12 +82,14 @@ describe('MultiDropzone component', () => {
79
82
  });
80
83
 
81
84
  expect(
82
- getByText("File type must be one of DOC, DOCX, PDF")
85
+ getByText('File type must be one of DOC, DOCX, PDF')
83
86
  ).toBeInTheDocument();
84
87
  });
85
88
 
86
- it("should remove wrong filetype error message", async () => {
87
- const { getByAltText, getByTestId, queryByText, user } = setup({ accept: "document" });
89
+ it('should remove wrong filetype error message', async () => {
90
+ const { getByAltText, getByTestId, queryByText, user } = setup({
91
+ accept: 'document',
92
+ });
88
93
  const input = getByTestId(inputTestId);
89
94
 
90
95
  await act(async () => {
@@ -93,135 +98,150 @@ describe('MultiDropzone component', () => {
93
98
  fireEvent.change(input, { target: { files: [file] } });
94
99
  });
95
100
 
96
- await user.click(getByAltText("remove"));
101
+ await user.click(getByAltText('remove'));
97
102
 
98
- expect(queryByText("File type must be one of DOC, DOCX, PDF")).not.toBeInTheDocument();
103
+ expect(
104
+ queryByText('File type must be one of DOC, DOCX, PDF')
105
+ ).not.toBeInTheDocument();
99
106
  });
100
107
  });
101
108
 
102
109
  describe('Copy text', () => {
103
- it("should show uploader text", () => {
110
+ it('should show uploader text', () => {
104
111
  const screen = setup({});
105
112
 
106
- expect(screen.getByText("Choose file or drag & drop")).toBeInTheDocument();
113
+ expect(
114
+ screen.getByText('Choose file or drag & drop')
115
+ ).toBeInTheDocument();
107
116
  });
108
117
 
109
- it("should show uploader text translated", () => {
110
- const instructionsText = "Drag drop file";
118
+ it('should show uploader text translated', () => {
119
+ const instructionsText = 'Drag drop file';
111
120
  const screen = setup({
112
- textOverrides: { instructionsText }
121
+ textOverrides: { instructionsText },
113
122
  });
114
123
 
115
124
  expect(screen.getByText(instructionsText)).toBeInTheDocument();
116
125
  });
117
126
 
118
- it("should show image accept file type label", () => {
119
- const screen = setup({ accept: "image" });
127
+ it('should show image accept file type label', () => {
128
+ const screen = setup({ accept: 'image' });
120
129
 
121
130
  expect(
122
- screen.getByText("Supports HEIC, BMP, JPEG, JPG, PNG")
131
+ screen.getByText('Supports HEIC, BMP, JPEG, JPG, PNG')
123
132
  ).toBeInTheDocument();
124
133
  });
125
134
 
126
- it("should show document accept file type label", () => {
127
- const screen = setup({ accept: "document" });
135
+ it('should show document accept file type label', () => {
136
+ const screen = setup({ accept: 'document' });
128
137
 
129
- expect(
130
- screen.getByText("Supports DOC, DOCX, PDF")
131
- ).toBeInTheDocument();
138
+ expect(screen.getByText('Supports DOC, DOCX, PDF')).toBeInTheDocument();
132
139
  });
133
140
 
134
- it("should custom document accept file type label", () => {
135
- const screen = setup({ accept: {
136
- "application/pdf": [".pdf"],
137
- "image/jpg": [".jpg"],
138
- } });
141
+ it('should custom document accept file type label', () => {
142
+ const screen = setup({
143
+ accept: {
144
+ 'application/pdf': ['.pdf'],
145
+ 'image/jpg': ['.jpg'],
146
+ },
147
+ });
139
148
 
140
- expect(
141
- screen.getByText("Supports PDF, JPG")
142
- ).toBeInTheDocument();
149
+ expect(screen.getByText('Supports PDF, JPG')).toBeInTheDocument();
143
150
  });
144
151
 
145
- it("should show disabled text if is uploading", () => {
152
+ it('should show disabled text if is uploading', () => {
146
153
  const screen = setup({ uploading: true });
147
154
 
148
155
  expect(
149
- screen.getByText("Please wait while uploading file...")
156
+ screen.getByText('Please wait while uploading file...')
150
157
  ).toBeInTheDocument();
151
158
  });
159
+
160
+ it('should associate input with its label', () => {
161
+ const { getByLabelText } = setup({});
162
+ const input = getByLabelText('Choose file or drag & drop');
163
+
164
+ expect(input).toBeInTheDocument();
165
+ });
152
166
  });
153
167
 
154
168
  describe('Uploaded files', () => {
155
- it("should show uploaded files", () => {
169
+ it('should show uploaded files', () => {
156
170
  const screen = setup({
157
171
  uploadedFiles: [uploadedFilesMock],
158
172
  });
159
173
 
160
- expect(
161
- screen.getByText(uploadedFilesMock.name)
162
- ).toBeInTheDocument();
174
+ expect(screen.getByText(uploadedFilesMock.name)).toBeInTheDocument();
163
175
  });
164
176
 
165
- it("should call onRemoveFile with uploaded file id", () => {
177
+ it('should call onRemoveFile with uploaded file id', () => {
166
178
  const screen = setup({
167
179
  uploadedFiles: [uploadedFilesMock],
168
180
  });
169
181
 
170
- screen.getByAltText("remove").click();
182
+ screen.getByAltText('remove').click();
171
183
 
172
184
  expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);
173
185
  });
174
186
 
175
- it("should show uploaded file with uploading label", () => {
187
+ it('should show uploaded file with uploading label', () => {
176
188
  const screen = setup({
177
189
  uploadedFiles: [{ ...uploadedFilesMock, progress: 50 }],
178
190
  });
179
191
 
180
- expect(screen.getByText("Uploading...")).toBeInTheDocument();
192
+ expect(screen.getByText('Uploading...')).toBeInTheDocument();
181
193
  });
182
194
 
183
- it("should show uploaded file with progress bar", () => {
195
+ it('should show uploaded file with progress bar', () => {
184
196
  const screen = setup({
185
- uploadedFiles: [{
186
- ...uploadedFilesMock,
187
- progress: 50,
188
- }],
197
+ uploadedFiles: [
198
+ {
199
+ ...uploadedFilesMock,
200
+ progress: 50,
201
+ },
202
+ ],
189
203
  });
190
204
 
191
205
  expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();
192
206
  });
193
207
 
194
- it("should show uploaded file with no progress bar", () => {
208
+ it('should show uploaded file with no progress bar', () => {
195
209
  const screen = setup({
196
- uploadedFiles: [{
197
- ...uploadedFilesMock,
198
- progress: 50,
199
- showProgressBar: false
200
- }],
210
+ uploadedFiles: [
211
+ {
212
+ ...uploadedFilesMock,
213
+ progress: 50,
214
+ showProgressBar: false,
215
+ },
216
+ ],
201
217
  });
202
218
 
203
219
  expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();
204
220
  });
205
221
 
206
- it("should show uploaded file with loading spinner", () => {
222
+ it('should show uploaded file with loading spinner', () => {
207
223
  const screen = setup({
208
- uploadedFiles: [{
209
- ...uploadedFilesMock,
210
- progress: 50,
211
- showLoadingSpinner: true
212
- }],
224
+ uploadedFiles: [
225
+ {
226
+ ...uploadedFilesMock,
227
+ progress: 50,
228
+ showLoadingSpinner: true,
229
+ },
230
+ ],
213
231
  });
214
232
 
215
233
  expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();
216
234
  });
217
235
 
218
- it("should show uploaded file with no loading spinner", () => {
236
+ it('should show uploaded file with no loading spinner', () => {
219
237
  const screen = setup({
220
- uploadedFiles: [{
221
- ...uploadedFilesMock,
222
- progress: 50,
223
- showLoadingSpinner: false
224
- }],
238
+ uploadedFiles: [
239
+ {
240
+ ...uploadedFilesMock,
241
+ progress: 50,
242
+ showLoadingSpinner: false,
243
+ },
244
+ ],
225
245
  });
226
246
 
227
247
  expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();