Test import/export of module state and priority.

This commit is contained in:
Jonathan Harris
2015-08-30 06:52:44 +01:00
parent fda966be02
commit 38dc4319c0
4 changed files with 32 additions and 25 deletions

View File

@@ -97,7 +97,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.bulkheads.c = null;
this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true);
this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0;
this.cargoScoop.enabled = enabled ? Boolean(enabled[0]) : true;
this.cargoScoop.enabled = enabled ? enabled[0] * true : true;
for (i = 0, l = this.priorityBands.length; i < l; i++) {
this.priorityBands[i].deployed = 0;
@@ -111,7 +111,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (i = 0; i < cl; i++) {
common[i].cat = 0;
common[i].enabled = enabled ? Boolean(enabled[i + 1]) : true;
common[i].enabled = enabled ? enabled[i + 1] * true : true;
common[i].priority = priorities ? priorities[i + 1] * 1 : 0;
common[i].type = 'SYS';
common[i].c = common[i].id = null; // Resetting 'old' component if there was one
@@ -128,7 +128,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (i = 0, l = hps.length; i < l; i++) {
hps[i].cat = 1;
hps[i].enabled = enabled ? Boolean(enabled[cl + i]) : true;
hps[i].enabled = enabled ? enabled[cl + i] * true : true;
hps[i].priority = priorities ? priorities[cl + i] * 1 : 0;
hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS';
hps[i].c = hps[i].id = null; // Resetting 'old' component if there was one
@@ -143,7 +143,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (i = 0, l = internal.length; i < l; i++) {
internal[i].cat = 2;
internal[i].enabled = enabled ? Boolean(enabled[cl + i]) : true;
internal[i].enabled = enabled ? enabled[cl + i] * true : true;
internal[i].priority = priorities ? priorities[cl + i] * 1 : 0;
internal[i].type = 'SYS';
internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one

View File

@@ -5,8 +5,8 @@
"references": [
{
"name": "Coriolis.io",
"url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b?bn=Test",
"code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b",
"url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA%3D%3D%3D.AwhMJBGaei%2BJCyyiA%3D%3D%3D?bn=Test",
"code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===",
"shipId": "anaconda"
}
],
@@ -29,7 +29,7 @@
"class": 6,
"rating": "A",
"enabled": true,
"priority": 1
"priority": 3
},
"lifeSupport": {
"class": 5,
@@ -61,7 +61,7 @@
"class": 4,
"rating": "A",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Plasma Accelerator",
"mount": "Fixed"
},
@@ -69,7 +69,7 @@
"class": 3,
"rating": "D",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Beam Laser",
"mount": "Turret"
},
@@ -77,7 +77,7 @@
"class": 3,
"rating": "D",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Beam Laser",
"mount": "Turret"
},
@@ -85,7 +85,7 @@
"class": 3,
"rating": "D",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Beam Laser",
"mount": "Turret"
},
@@ -93,7 +93,7 @@
"class": 2,
"rating": "E",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Cannon",
"mount": "Turret"
},
@@ -101,7 +101,7 @@
"class": 2,
"rating": "E",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Cannon",
"mount": "Turret"
},
@@ -109,7 +109,7 @@
"class": 1,
"rating": "F",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Beam Laser",
"mount": "Turret"
},
@@ -117,7 +117,7 @@
"class": 1,
"rating": "F",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Beam Laser",
"mount": "Turret"
}
@@ -142,20 +142,20 @@
"class": 0,
"rating": "C",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Kill Warrant Scanner"
},
{
"class": 0,
"rating": "C",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Cargo Scanner"
},
{
"class": 0,
"rating": "F",
"enabled": true,
"enabled": false,
"priority": 1,
"group": "Countermeasure",
"name": "Electronic Countermeasure"
@@ -172,7 +172,7 @@
"class": 0,
"rating": "I",
"enabled": true,
"priority": 1,
"priority": 2,
"group": "Countermeasure",
"name": "Point Defence"
}
@@ -233,14 +233,14 @@
"class": 4,
"rating": "A",
"enabled": true,
"priority": 1,
"priority": 3,
"group": "Fuel Scoop"
},
{
"class": 2,
"rating": "A",
"enabled": true,
"priority": 1,
"priority": 3,
"group": "FSD Interdictor"
}
]
@@ -270,7 +270,7 @@
"totalDps": 29,
"powerAvailable": 36,
"powerRetracted": 23.93,
"powerDeployed": 35.56,
"powerDeployed": 35.36,
"unladenRange": 18.49,
"fullTankRange": 18.12,
"ladenRange": 16.39,

View File

@@ -108,7 +108,7 @@ describe('Import Controller', function() {
expect(scope.processed).toBeTruthy();
scope.import();
expect(angular.fromJson(localStorage.getItem('builds'))).toEqual({
anaconda: { 'Test': '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA=' }
anaconda: { 'Test': '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===' }
});
});

View File

@@ -3,7 +3,7 @@ describe("Serializer Service", function() {
var Ship,
Serializer,
code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b',
code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===',
anaconda = DB.ships['anaconda'],
testBuild,
exportData;
@@ -21,13 +21,20 @@ describe("Serializer Service", function() {
exportData = Serializer.toDetailedBuild('Test', testBuild, code);
});
it("conforms to the ship-loadout schema", function() {
it("conforms to the v1 ship-loadout schema", function() {
var shipLoadoutSchema = __json__['schemas/ship-loadout/1'];
var validate = jsen(shipLoadoutSchema);
var valid = validate(exportData);
expect(valid).toBeTruthy();
});
it("conforms to the v2 ship-loadout schema", function() {
var shipLoadoutSchema = __json__['schemas/ship-loadout/2'];
var validate = jsen(shipLoadoutSchema);
var valid = validate(exportData);
expect(valid).toBeTruthy();
});
it("contains the correct components and stats", function() {
var anacondaTestExport = __json__['fixtures/anaconda-test-detailed-export'];
expect(exportData.components).toEqual(anacondaTestExport.components);