-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
43 lines (35 loc) · 1.38 KB
/
test.js
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
const fs = require('fs');
function validateMainlandIds() {
const data = fs.readFileSync('mainlandIds.txt', 'utf-8');
const ids = data.split('\n').map(line => line.split(':')[1]); // Split to get only the ids
let valid = true;
// Validate Croatia, Greece, and Denmark have only their mainland
['HR', 'GR', 'DA'].forEach(countryCode => {
if (ids.filter(id => id.startsWith(countryCode)).length !== 1) {
console.error(`Validation error: ${countryCode} has none, or more than one mainland.`);
valid = false;
}
});
// Validate US should have exactly 2 IDs
if (ids.filter(id => id.startsWith('US')).length !== 2) {
console.error(`Validation error: US should have 2 mainlands.`);
valid = false;
}
// Validate Japan should have exactly 4 IDs
if (ids.filter(id => id.startsWith('JA')).length !== 4) {
console.error(`Validation error: Japan should have 4 mainlands.`);
valid = false;
}
// Validate New Zealand should have exactly 2 IDs
if (ids.filter(id => id.startsWith('NZ')).length !== 2) {
console.error(`Validation error: New Zealand should have 2 mainlands.`);
valid = false;
}
// Final validation message
if (valid) {
console.log('Validation successful!');
} else {
console.log('Validation failed.');
}
}
validateMainlandIds();