-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathbasic-types.test.ts
More file actions
74 lines (63 loc) · 1.91 KB
/
Copy pathbasic-types.test.ts
File metadata and controls
74 lines (63 loc) · 1.91 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2015-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
// This file tests that TypeScript types work correctly
// Run with: npm run test:types
import marklogic from 'marklogic';
// Test 1: Valid configuration should compile without errors
const validConfig: marklogic.DatabaseClientConfig = {
host: 'localhost',
port: 8000,
user: 'admin',
password: 'admin',
authType: 'digest'
};
const db = marklogic.createDatabaseClient(validConfig);
// Test 2: Another valid configuration with SSL
const sslConfig: marklogic.DatabaseClientConfig = {
host: 'secure.marklogic.com',
port: 8443,
user: 'admin',
password: 'admin',
authType: 'basic',
ssl: true,
rejectUnauthorized: true
};
const secureDb = marklogic.createDatabaseClient(sslConfig);
// Test 3: This should cause a type error if uncommented (invalid authType)
// const invalidConfig: marklogic.DatabaseClientConfig = {
// host: 'localhost',
// authType: 'invalid-auth-type' // ERROR: not a valid authType
// };
// Test 4: Type inference should work (no explicit type annotation needed)
const inferredConfig = {
host: 'localhost',
port: 8000,
user: 'admin',
password: 'admin'
};
const db2 = marklogic.createDatabaseClient(inferredConfig);
// Test 5: Testing optional fields - this should compile fine
const minimalConfig: marklogic.DatabaseClientConfig = {
user: 'admin',
password: 'admin'
};
// Test 6: Testing all auth types (all should be valid)
const authTypes: Array<marklogic.DatabaseClientConfig['authType']> = [
'basic',
'digest',
'application-level',
'certificate',
'kerberos',
'saml',
'cloud'
];
// Test 7: Testing SSL certificate options
const certConfig: marklogic.DatabaseClientConfig = {
host: 'localhost',
ssl: true,
ca: Buffer.from('certificate'),
cert: 'string-cert',
key: Buffer.from('key')
};
console.log('✅ TypeScript types validated successfully!');