timezones-ical-library 1.11.1 ā 2.0.0
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 +92 -76
- package/dist/cjs/index.js +7 -209
- package/dist/cjs/package.json +3 -1
- package/dist/mjs/index.js +7 -209
- package/dist/mjs/package.json +3 -1
- package/dist/tzlib.js +8 -208
- package/package.json +12 -19
- package/test/load-commonjs.cjs +32 -3
- package/test/load-module.mjs +32 -3
- package/test/tests.js +55 -14
- package/dist/cjs/.eslintrc.json +0 -1
- package/test/.eslintrc.json +0 -7
package/test/tests.js
CHANGED
|
@@ -1,23 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const { execSync, spawnSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const testCases = [
|
|
4
|
+
'CST6CDT',
|
|
5
|
+
'GMT0',
|
|
6
|
+
'Europe/Berlin',
|
|
7
|
+
'America/New_York',
|
|
8
|
+
'America/Argentina/Buenos_Aires',
|
|
9
|
+
'Antarctica/Casey',
|
|
10
|
+
'Africa/Bangui',
|
|
11
|
+
];
|
|
4
12
|
|
|
5
13
|
try {
|
|
6
|
-
execSync('npm run build', { stdio: [0, 1, 2] });
|
|
14
|
+
execSync('npm run build:lib-only', { stdio: [0, 1, 2] });
|
|
15
|
+
|
|
16
|
+
const testCasesString = JSON.stringify(testCases);
|
|
17
|
+
|
|
18
|
+
console.log('\nšļø Running Tests...');
|
|
19
|
+
|
|
20
|
+
// Test ES Module import
|
|
21
|
+
try {
|
|
22
|
+
const result = spawnSync('node', ['test/load-module.mjs', testCasesString], { encoding: 'utf8' });
|
|
23
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
24
|
+
if (result.status !== 0 || (result.stderr && result.stderr.length > 0)) {
|
|
25
|
+
throw new Error('Test script passed with errors');
|
|
26
|
+
}
|
|
27
|
+
console.log('ā
Importing the script as module and running tests\n');
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('ā Something went wrong with testing the ES Module setup\n');
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
7
32
|
|
|
33
|
+
// Test CommonJS require
|
|
8
34
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
35
|
+
const result = spawnSync('node', ['test/load-commonjs.cjs', testCasesString], { encoding: 'utf8' });
|
|
36
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
37
|
+
if (result.status !== 0 || (result.stderr && result.stderr.length > 0)) {
|
|
38
|
+
throw new Error('Test script passed with errors');
|
|
39
|
+
}
|
|
40
|
+
console.log('ā
CommonJS init via require and running tests\n');
|
|
11
41
|
} catch (error) {
|
|
12
|
-
console.
|
|
42
|
+
console.error('ā Something went wrong with testing the CommonJS setup\n');
|
|
13
43
|
throw error;
|
|
14
44
|
}
|
|
15
45
|
|
|
46
|
+
// Test whether there is an ics file per test case in the api folder
|
|
47
|
+
console.log('\nāļø Testing for ics files in the API folder:\n');
|
|
16
48
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
testCases.forEach((tz) => {
|
|
50
|
+
const fs = require('fs');
|
|
51
|
+
const path = `api/${tz}.ics`;
|
|
52
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
53
|
+
if (!fs.existsSync(path)) {
|
|
54
|
+
throw new Error(`š“ Missing file for time zone ${tz} at API folder`);
|
|
55
|
+
}
|
|
56
|
+
console.log(`š¢ Found ics file for time zone ${tz} at API folder`);
|
|
57
|
+
});
|
|
58
|
+
console.log('ā
All time zones have a corresponding ics file in the API folder\n');
|
|
19
59
|
} catch (error) {
|
|
20
|
-
console.
|
|
60
|
+
console.error(error.message);
|
|
61
|
+
console.error('ā Could not find all ics files in the API folder\n');
|
|
21
62
|
throw error;
|
|
22
63
|
}
|
|
23
64
|
|
|
@@ -27,10 +68,10 @@ try {
|
|
|
27
68
|
if (error) {
|
|
28
69
|
throw error;
|
|
29
70
|
}
|
|
30
|
-
console.log(
|
|
31
|
-
console.log('All Tests SUCCESSFUL!\n');
|
|
71
|
+
console.log(`... ${dirToDrop} directory deleted again`);
|
|
72
|
+
console.log('\nš All Tests SUCCESSFUL!\n');
|
|
32
73
|
});
|
|
74
|
+
// eslint-disable-next-line no-unused-vars
|
|
33
75
|
} catch (error) {
|
|
34
|
-
console.
|
|
35
|
-
throw error;
|
|
76
|
+
console.error('\nš FAILED: Tests did not pass unfortunately.\n');
|
|
36
77
|
}
|
package/dist/cjs/.eslintrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }
|