@shipstatic/drop 0.2.1 → 0.2.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.
- package/README.md +64 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -158,6 +158,70 @@ const files = drop.getFilesForUpload();
|
|
|
158
158
|
await ship.deployments.create(files);
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
+
## Testing
|
|
162
|
+
|
|
163
|
+
The `/testing` subpath provides mock utilities for testing components that use `useDrop`:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import {
|
|
167
|
+
createMockDrop,
|
|
168
|
+
createMockDropWithSpies,
|
|
169
|
+
createMockProcessedFile,
|
|
170
|
+
} from '@shipstatic/drop/testing';
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Testing Component States
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
import { render, screen } from '@testing-library/react';
|
|
177
|
+
import { createMockDrop, createMockProcessedFile } from '@shipstatic/drop/testing';
|
|
178
|
+
|
|
179
|
+
it('shows file count when ready', () => {
|
|
180
|
+
const drop = createMockDrop({
|
|
181
|
+
phase: 'ready',
|
|
182
|
+
files: [
|
|
183
|
+
createMockProcessedFile('index.html'),
|
|
184
|
+
createMockProcessedFile('style.css'),
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
render(<MyDropzone drop={drop} />);
|
|
189
|
+
expect(screen.getByText('2 files ready')).toBeInTheDocument();
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Testing Interactions
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import userEvent from '@testing-library/user-event';
|
|
197
|
+
import { createMockDropWithSpies, createMockProcessedFile } from '@shipstatic/drop/testing';
|
|
198
|
+
|
|
199
|
+
it('calls reset when Clear is clicked', async () => {
|
|
200
|
+
const { drop, spies } = createMockDropWithSpies({
|
|
201
|
+
phase: 'ready',
|
|
202
|
+
files: [createMockProcessedFile('index.html')],
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
render(<MyDropzone drop={drop} />);
|
|
206
|
+
await userEvent.click(screen.getByText('Clear'));
|
|
207
|
+
|
|
208
|
+
expect(spies.reset.toHaveBeenCalled()).toBe(true);
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Available Utilities
|
|
213
|
+
|
|
214
|
+
| Function | Purpose |
|
|
215
|
+
|----------|---------|
|
|
216
|
+
| `createMockDrop(options?)` | Mock `DropReturn` for rendering tests |
|
|
217
|
+
| `createMockDropWithSpies(options?)` | Mock with call tracking for interaction tests |
|
|
218
|
+
| `createMockProcessedFile(name, options?)` | Mock `ProcessedFile` |
|
|
219
|
+
| `createMockFile(name, content?, type?)` | Mock `File` object |
|
|
220
|
+
| `createMockFileWithPath(name, path, ...)` | Mock `File` with `webkitRelativePath` |
|
|
221
|
+
| `createMockErrorStatus(title?, details?, errors?)` | Mock error status |
|
|
222
|
+
| `createMockProcessingStatus(title?, details?)` | Mock processing status |
|
|
223
|
+
| `createMockReadyStatus(count)` | Mock ready status |
|
|
224
|
+
|
|
161
225
|
## Requirements
|
|
162
226
|
|
|
163
227
|
- React 18+ or 19+
|
package/dist/index.cjs
CHANGED
|
@@ -11702,7 +11702,7 @@ var require_mime_db = __commonJS({
|
|
|
11702
11702
|
}
|
|
11703
11703
|
});
|
|
11704
11704
|
|
|
11705
|
-
// node_modules/.pnpm/@shipstatic+types@0.4.
|
|
11705
|
+
// node_modules/.pnpm/@shipstatic+types@0.4.12/node_modules/@shipstatic/types/dist/index.js
|
|
11706
11706
|
var ErrorType;
|
|
11707
11707
|
(function(ErrorType2) {
|
|
11708
11708
|
ErrorType2["Validation"] = "validation_failed";
|