@onlineapps/conn-base-storage 1.0.2 → 1.0.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.
@@ -12,6 +12,14 @@
12
12
  const StorageConnector = require('../../src/index');
13
13
  const crypto = require('crypto');
14
14
 
15
+ // Minimal required MinIO config for tests (all external I/O is mocked)
16
+ const MINIO_CONFIG = {
17
+ endPoint: 'localhost',
18
+ port: 9000,
19
+ accessKey: 'test',
20
+ secretKey: 'test',
21
+ };
22
+
15
23
  // Mock MinIO client kompletně
16
24
  jest.mock('minio', () => {
17
25
  return {
@@ -38,7 +46,7 @@ jest.mock('minio', () => {
38
46
  describe('StorageConnector Unit Tests @unit', () => {
39
47
  describe('Initialization', () => {
40
48
  test('should create instance with default config', () => {
41
- const storage = new StorageConnector();
49
+ const storage = new StorageConnector(MINIO_CONFIG);
42
50
  expect(storage).toBeDefined();
43
51
  expect(storage.config).toBeDefined();
44
52
  expect(storage.config.endPoint).toBe('localhost');
@@ -67,7 +75,7 @@ describe('StorageConnector Unit Tests @unit', () => {
67
75
  let storage;
68
76
 
69
77
  beforeEach(() => {
70
- storage = new StorageConnector();
78
+ storage = new StorageConnector(MINIO_CONFIG);
71
79
  });
72
80
 
73
81
  test('should generate fingerprint for string content', () => {
@@ -144,7 +152,7 @@ describe('StorageConnector Unit Tests @unit', () => {
144
152
  let storage;
145
153
 
146
154
  beforeEach(() => {
147
- storage = new StorageConnector({ cacheMaxSize: 3 });
155
+ storage = new StorageConnector({ ...MINIO_CONFIG, cacheMaxSize: 3 });
148
156
  });
149
157
 
150
158
  test('should add items to cache', () => {
@@ -189,7 +197,7 @@ describe('StorageConnector Unit Tests @unit', () => {
189
197
  let storage;
190
198
 
191
199
  beforeEach(() => {
192
- storage = new StorageConnector();
200
+ storage = new StorageConnector(MINIO_CONFIG);
193
201
  });
194
202
 
195
203
  test('should handle invalid content types for fingerprinting', () => {
@@ -202,13 +210,13 @@ describe('StorageConnector Unit Tests @unit', () => {
202
210
  const invalidNames = ['', 'a', 'UPPERCASE', 'bucket_name', 'bucket-'];
203
211
 
204
212
  validNames.forEach(name => {
205
- const s = new StorageConnector({ bucketName: name });
213
+ const s = new StorageConnector({ ...MINIO_CONFIG, bucketName: name });
206
214
  expect(s.config.bucketName).toBe(name);
207
215
  });
208
216
 
209
217
  // Invalid names should use default
210
218
  invalidNames.forEach(name => {
211
- const s = new StorageConnector({ bucketName: name });
219
+ const s = new StorageConnector({ ...MINIO_CONFIG, bucketName: name });
212
220
  expect(s.config.bucketName).toBe('oa-drive-storage');
213
221
  });
214
222
  });
@@ -218,7 +226,7 @@ describe('StorageConnector Unit Tests @unit', () => {
218
226
  let storage;
219
227
 
220
228
  beforeEach(() => {
221
- storage = new StorageConnector();
229
+ storage = new StorageConnector(MINIO_CONFIG);
222
230
  });
223
231
 
224
232
  test('should generate object name with fingerprint', () => {
@@ -255,7 +263,7 @@ describe('StorageConnector Unit Tests @unit', () => {
255
263
 
256
264
  beforeEach(() => {
257
265
  jest.clearAllMocks();
258
- storage = new StorageConnector();
266
+ storage = new StorageConnector(MINIO_CONFIG);
259
267
  mockClient = storage.minioClient;
260
268
  });
261
269