forked from super-productivity/super-productivity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-headers.spec.ts
More file actions
46 lines (39 loc) · 1.3 KB
/
Copy pathdebug-headers.spec.ts
File metadata and controls
46 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { WebdavApi } from './src/app/pfapi/api/sync/providers/webdav/webdav-api';
import { createMockResponse } from './src/app/pfapi/api/sync/providers/webdav/webdav-api-test-utils';
import { WebdavPrivateCfg } from './src/app/pfapi/api/sync/providers/webdav/webdav.model';
describe('Debug Headers', () => {
let mockFetch: jasmine.Spy;
let api: WebdavApi;
const mockConfig: WebdavPrivateCfg = {
baseUrl: 'https://webdav.example.com',
userName: 'testuser',
password: 'testpass',
syncFolderPath: '/sync',
serverCapabilities: {
supportsETags: true,
supportsLastModified: false,
supportsIfHeader: true,
supportsLocking: false,
},
};
beforeEach(() => {
mockFetch = spyOn(globalThis, 'fetch');
api = new WebdavApi(async () => mockConfig);
});
it('should set If-None-Match for new file creation', async () => {
const uploadResponse = createMockResponse(201, {
etag: '"v1"',
});
mockFetch.and.callFake((url, options) => {
console.log('Called with:', url, JSON.stringify(options));
return Promise.resolve(uploadResponse);
});
const result = await api.upload({
path: '/test.txt',
data: 'content',
isOverwrite: false,
});
expect(result).toBe('v1');
expect(mockFetch).toHaveBeenCalled();
});
});