mirror of
https://github.com/EDCD/coriolis-data.git
synced 2025-12-08 15:13:23 +00:00
clean up data spec
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
var Modules = require('../modules');
|
||||
var Ships = require('../ships');
|
||||
var Modifications = require('../modifications');
|
||||
const Modules = require('../modules');
|
||||
const Ships = require('../ships');
|
||||
const Modifications = require('../modifications');
|
||||
|
||||
describe('JSON Data', function() {
|
||||
|
||||
var shipProperties = [
|
||||
describe('JSON Data', () => {
|
||||
const shipProperties = [
|
||||
'name',
|
||||
'manufacturer',
|
||||
'class',
|
||||
@@ -24,21 +23,21 @@ describe('JSON Data', function() {
|
||||
'crew'
|
||||
];
|
||||
|
||||
var edIDs = {};
|
||||
var eddbIDs = {};
|
||||
const edIDs = {};
|
||||
const eddbIDs = {};
|
||||
|
||||
it('has an up-to-date distribution', function() {
|
||||
var dist = require('../dist/index.js');
|
||||
it('has an up-to-date distribution', () => {
|
||||
const dist = require('../dist');
|
||||
expect(dist.Ships).toEqual(Ships, 'Distribution ships does not match. Did you run `npm start`?');
|
||||
expect(dist.Modules).toEqual(Modules, 'Distribution modules does not match. Did you run `npm start`?');
|
||||
});
|
||||
|
||||
it('has valid standard modules', function() {
|
||||
var ids = {};
|
||||
for (var s in Modules.standard) {
|
||||
var group = Modules.standard[s];
|
||||
for (var i = 0; i < group.length; i++) {
|
||||
var id = group[i].id;
|
||||
it('has valid standard modules', () => {
|
||||
const ids = {};
|
||||
for (const s in Modules.standard) {
|
||||
const group = Modules.standard[s];
|
||||
for (let i = 0; i < group.length; i++) {
|
||||
const id = group[i].id;
|
||||
expect(ids[id]).toBeFalsy('ID already exists: ' + id);
|
||||
expect(group[i].edID > 0).toBeTruthy('Standard module ' + id + ' is missing E:D ID');
|
||||
expect(group[i].eddbID > 0).toBeTruthy('Standard module ' + id + ' is missing EDDB ID');
|
||||
@@ -46,8 +45,8 @@ describe('JSON Data', function() {
|
||||
expect(group[i].integrity).toBeDefined('Standard module ' + id + ' is missing integrity');
|
||||
}
|
||||
expect(group[i].grp).toBeDefined(`No group defined, Type: ${s}, ID: ${id}, Index: ${i}`);
|
||||
expect(eddbIDs[group[i].eddbID]).toBeFalsy(`EDDB ID [${group[i].eddbID}] already exists for ID: ${id}, Index: ${i}`);
|
||||
expect(edIDs[group[i].edID]).toBeFalsy(`E:D ID [${group[i].edID}] already exists for ID: ${id}, Index: ${i}`);
|
||||
expect(eddbIDs[group[i].eddbID]).toBeFalsy(`EDDB ID [${group[i].eddbID}] already exists: ${group[i].grp}:${id} ${group[i].name ? group[i].name : ''}`);
|
||||
expect(edIDs[group[i].edID]).toBeFalsy(`E:D ID [${group[i].edID}] already exists: ${group[i].grp}:${id} ${group[i].name ? group[i].name : ''}`);
|
||||
if (group[i].eddbID) {
|
||||
eddbIDs[group[i].eddbID] = true;
|
||||
}
|
||||
@@ -59,13 +58,13 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid hardpoints', function() {
|
||||
var ids = {};
|
||||
it('has valid hardpoints', () => {
|
||||
const ids = {};
|
||||
|
||||
for (var g in Modules.hardpoints) {
|
||||
var group = Modules.hardpoints[g];
|
||||
for (var i = 0; i < group.length; i++) {
|
||||
var id = group[i].id;
|
||||
for (const g in Modules.hardpoints) {
|
||||
const group = Modules.hardpoints[g];
|
||||
for (let i = 0; i < group.length; i++) {
|
||||
const id = group[i].id;
|
||||
expect(ids[id]).toBeFalsy('ID already exists: ' + id);
|
||||
expect(group[i].grp).toBeDefined('Hardpoint has no group defined, ID:' + id);
|
||||
expect(group[i].mass).toBeDefined(`Hardpoint ${group[i].grp}:${id} ${group[i].name ? group[i].name : ''} is missing mass`);
|
||||
@@ -102,13 +101,13 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid internal modules', function() {
|
||||
var ids = {};
|
||||
it('has valid internal modules', () => {
|
||||
const ids = {};
|
||||
|
||||
for (var g in Modules.internal) {
|
||||
var group = Modules.internal[g];
|
||||
for (var i = 0; i < group.length; i++) {
|
||||
var id = group[i].id;
|
||||
for (const g in Modules.internal) {
|
||||
const group = Modules.internal[g];
|
||||
for (let i = 0; i < group.length; i++) {
|
||||
const id = group[i].id;
|
||||
expect(group[i].grp).toBeDefined(`No group defined, ID: ${id}`);
|
||||
expect(ids[id]).toBeFalsy('ID already exists: ' + id);
|
||||
expect(group[i].eddbID > 0).toBeTruthy(`${group[i].grp}:${id} ${group[i].name ? group[i].name : ''} is missing EDDB ID`);
|
||||
@@ -128,11 +127,11 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has data for every ship', function() {
|
||||
var bulkheadIds = {};
|
||||
it('has data for every ship', () => {
|
||||
const bulkheadIds = {};
|
||||
|
||||
for (var s in Ships) {
|
||||
for (var p = 0; p < shipProperties.length; p++) {
|
||||
for (const s in Ships) {
|
||||
for (let p = 0; p < shipProperties.length; p++) {
|
||||
expect(Ships[s].properties[shipProperties[p]]).toBeDefined(shipProperties[p] + ' is missing for ' + s);
|
||||
}
|
||||
expect(Ships[s].eddbID > 0).toBeTruthy(s + ' is missing EDDB ID');
|
||||
@@ -149,8 +148,8 @@ describe('JSON Data', function() {
|
||||
edIDs[Ships[s].edID] = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < Ships[s].bulkheads.length; i++) {
|
||||
var b = Ships[s].bulkheads[i];
|
||||
for (let i = 0; i < Ships[s].bulkheads.length; i++) {
|
||||
const b = Ships[s].bulkheads[i];
|
||||
expect(b.id).toBeDefined(`${s} bulkhead [${i}] is missing an ID`);
|
||||
expect(bulkheadIds[b.id]).toBeFalsy(`${s} bulkhead [${i} - ${b.id}] ID already exists`);
|
||||
expect(b.eddbID > 0).toBeTruthy(`${s} bulkhead [${i} - ${b.id}] is missing EDDB ID`);
|
||||
@@ -168,11 +167,11 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid blueprints', function() {
|
||||
var ids = {};
|
||||
var names = {};
|
||||
it('has valid blueprints', () => {
|
||||
const ids = {};
|
||||
const names = {};
|
||||
|
||||
for (var blueprintname in Modifications.blueprints) {
|
||||
for (const blueprintname in Modifications.blueprints) {
|
||||
const blueprint = Modifications.blueprints[blueprintname];
|
||||
expect(names[blueprintname]).toBeFalsy('Name already exists: ' + blueprintname);
|
||||
names[blueprintname] = true;
|
||||
@@ -181,8 +180,8 @@ describe('JSON Data', function() {
|
||||
expect(blueprint.name).toBeDefined('Blueprint has no name, ID:' + blueprint.id);
|
||||
expect(blueprint.grades).toBeDefined('Blueprint has no grades, ID:' + blueprint.id);
|
||||
|
||||
grades = {}
|
||||
for (var grade in blueprint.grades) {
|
||||
grades = {};
|
||||
for (const grade in blueprint.grades) {
|
||||
expect(grades[grade]).toBeFalsy('Grade already exists: ' + grade + ' for ' + blueprintname);
|
||||
grades[grade] = true;
|
||||
|
||||
@@ -193,10 +192,10 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid modifications', function() {
|
||||
var ids = {};
|
||||
it('has valid modifications', () => {
|
||||
const ids = {};
|
||||
|
||||
for (var k in Modifications.modifications) {
|
||||
for (const k in Modifications.modifications) {
|
||||
const modification = Modifications.modifications[k];
|
||||
expect(ids[modification.id]).toBeFalsy('ID already exists: ' + modification.id);
|
||||
expect(modification.name).toBeDefined('Modification has no name, ID:' + modification.id);
|
||||
@@ -206,27 +205,26 @@ describe('JSON Data', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid module modifications', function() {
|
||||
for (var m in Modifications.modules) {
|
||||
it('has valid module modifications', () => {
|
||||
for (const m in Modifications.modules) {
|
||||
const module = Modifications.modules[m];
|
||||
for (var bp in module.blueprints) {
|
||||
for (const bp in module.blueprints) {
|
||||
expect(Modifications.blueprints[bp]).toBeDefined('Missing ' + bp + ' for ' + m);
|
||||
for (var grade in module.blueprints[bp].grades) {
|
||||
for (const grade in module.blueprints[bp].grades) {
|
||||
expect(Modifications.blueprints[bp].grades[grade]).toBeDefined('Missing ' + bp + ' grade ' + grade + ' for ' + m);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('has valid specials', function() {
|
||||
var ids = {};
|
||||
it('has valid specials', () => {
|
||||
const ids = {};
|
||||
|
||||
for (var k in Modifications.specials) {
|
||||
for (const k in Modifications.specials) {
|
||||
const special = Modifications.specials[k];
|
||||
expect(ids[special.id]).toBeFalsy('ID already exists: ' + special.id);
|
||||
expect(special.name).toBeDefined('Special has no name, ID:' + special.id);
|
||||
ids[special.id] = true;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user