Refactor many variable names, adding detailed json dump and schema

This commit is contained in:
Colin McLeod
2015-07-14 21:44:12 -07:00
parent cd48ef6f86
commit 4578dbf906
34 changed files with 560 additions and 190 deletions

View File

@@ -1,23 +1,25 @@
// Karma configuration
// Generated on Thu Jun 11 2015 19:39:40 GMT-0700 (PDT)
module.exports = function(config) {
config.set({
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
frameworks: ['jasmine', 'fixture'],
preprocessors: {
'../build/schemas/**/*.json': ['json_fixtures']
},
files: [
'../build/lib*.js',
'../node_modules/angular-mocks/angular-mocks.js',
'../node_modules/jsen/dist/jsen.js',
'../build/app*.js',
'tests/**/*.js'
'../build/schemas/**/*.json',
'tests/**/*.js',
],
jsonFixturesPreprocessor: {
stripPrefix: '.*build',
variableName: '__json__'
},
reporters: ['mocha'],
port: 9876,
colors: true,
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],

View File

@@ -1,8 +1,8 @@
describe("Database", function() {
describe('Database', function() {
var shipProperties = ["grp", "name", "manufacturer", "class", "cost", "speed", "boost", "agility", "shields", "armour", "fuelcost", "mass"];
var shipProperties = ['name', 'manufacturer', 'class', 'hullCost', 'speed', 'boost', 'agility', 'baseShieldStrength', 'baseArmour', 'hullMass', 'masslock'];
it("has ships and components", function() {
it('has ships and components', function() {
expect(DB.ships).toBeDefined()
expect(DB.components.common).toBeDefined();
expect(DB.components.hardpoints).toBeDefined();
@@ -10,7 +10,7 @@ describe("Database", function() {
expect(DB.components.bulkheads).toBeDefined();
});
it("has unique IDs for every hardpoint", function() {
it('has unique IDs for every hardpoint', function() {
var ids = {};
var groups = DB.components.hardpoints;
@@ -25,7 +25,7 @@ describe("Database", function() {
}
});
it("has valid internal components", function() {
it('has valid internal components', function() {
var ids = {};
var groups = DB.components.internal;
@@ -40,7 +40,7 @@ describe("Database", function() {
}
});
it("has data for every ship", function() {
it('has data for every ship', function() {
for (var s in DB.ships) {
for (var p = 0; p < shipProperties.length; p++) {
expect(DB.ships[s].properties[shipProperties[p]]).toBeDefined(shipProperties[p] + ' is missing for ' + s);
@@ -49,12 +49,12 @@ describe("Database", function() {
expect(DB.ships[s].defaults.common.length).toEqual(7, s + ' is missing common defaults');
expect(DB.ships[s].slots.hardpoints.length).toEqual(DB.ships[s].defaults.hardpoints.length, s + ' hardpoint slots and defaults dont match');
expect(DB.ships[s].slots.internal.length).toEqual(DB.ships[s].defaults.internal.length, s + ' hardpoint slots and defaults dont match');
expect(DB.ships[s].retailCost).toBeGreaterThan(DB.ships[s].properties.cost, s + ' has invalid retail cost');
expect(DB.ships[s].retailCost).toBeGreaterThan(DB.ships[s].properties.hullCost, s + ' has invalid retail cost');
expect(DB.components.bulkheads[s]).toBeDefined(s + ' is missing bulkheads');
}
});
it("has components with a group defined", function() {
it('has components with a group defined', function() {
for (var i = 0; i < DB.components.common.length; i++) {
var group = DB.components.common[i];
for (var c in group) {

View File

@@ -29,7 +29,7 @@ describe("Ship Factory", function() {
expect(ship.unladenTotalRange).toBeGreaterThan(0, s + ' unladenTotalRange');
expect(ship.ladenTotalRange).toBeGreaterThan(0, s + ' ladenTotalRange');
expect(ship.shieldStrength).toBeGreaterThan(0, s + ' shieldStrength');
expect(ship.armourTotal).toBeGreaterThan(0, s + ' armourTotal');
expect(ship.armour).toBeGreaterThan(0, s + ' armour');
}
});
@@ -74,7 +74,7 @@ describe("Ship Factory", function() {
var testShip = new Ship(id, cobra.properties, cobra.slots);
testShip.buildWith(cobra.defaults);
var originalHullCost = testShip.cost;
var originalHullCost = testShip.hullCost;
var originalTotalCost = testShip.totalCost;
var discount = 0.9;

View File

@@ -0,0 +1,41 @@
describe("Serializer Service", function() {
beforeEach(module('app'));
var Ship, Serializer;
beforeEach(inject(function (_Ship_, _Serializer_) {
Ship = _Ship_;
Serializer = _Serializer_;
}));
describe("Detailed Export", function() {
var code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4yo5dig=.MwBhEYy6duwEziA',
url = 'http://a.test.url.com',
anaconda = DB.ships['anaconda'],
testBuild,
exportData;
beforeEach(function() {
testBuild = new Ship('anaconda', anaconda.properties, anaconda.slots);
Serializer.toShip(testBuild, code);
exportData = Serializer.toJsonBuild('Test Build', testBuild, url, code);
});
it("conforms to the ship-loadout schema", function() {
var shipLoadoutSchema = __json__['/schemas/ship-loadout/1-draft'];
var validate = jsen(shipLoadoutSchema);
var valid = validate(exportData);
expect(valid).toBeTruthy();
});
xit("contains the correct components", function() {
// TODO: implement
});
xit("contains the correct stats", function() {
// TODO: implement
});
});
});