mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Continued porting to react
This commit is contained in:
@@ -6,10 +6,9 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import TU from 'react-testutils-additions';
|
||||
import Utils from './testUtils';
|
||||
import Persist from '../src/app/stores/Persist';
|
||||
import { getLanguage } from '../src/app/i18n/Language';
|
||||
|
||||
describe('Import Controller', function() {
|
||||
describe('Import Modal', function() {
|
||||
|
||||
const Persist = require('../src/app/stores/Persist').default;
|
||||
const ModalImport = require('../src/app/components/ModalImport').default;
|
||||
@@ -90,8 +89,8 @@ describe('Import Controller', function() {
|
||||
});
|
||||
|
||||
it('imports an old valid backup', function() {
|
||||
let importData = require('./fixtures/old-valid-export');
|
||||
let importStr = JSON.stringify(importData);
|
||||
const importData = require('./fixtures/old-valid-export');
|
||||
const importStr = JSON.stringify(importData);
|
||||
|
||||
pasteText(importStr);
|
||||
expect(modal.state.builds).toEqual(importData.builds);
|
||||
@@ -104,7 +103,7 @@ describe('Import Controller', function() {
|
||||
});
|
||||
|
||||
it('catches an invalid backup', function() {
|
||||
let importData = require('./fixtures/valid-backup');
|
||||
const importData = require('./fixtures/valid-backup');
|
||||
let invalidImportData = Object.assign({}, importData);
|
||||
invalidImportData.builds.asp = null; // Remove Asp Miner build used in comparison
|
||||
|
||||
@@ -131,7 +130,7 @@ describe('Import Controller', function() {
|
||||
beforeEach(reset);
|
||||
|
||||
it('imports a valid v3 build', function() {
|
||||
let importData = require('./fixtures/anaconda-test-detailed-export-v3');
|
||||
const importData = require('./fixtures/anaconda-test-detailed-export-v3');
|
||||
pasteText(JSON.stringify(importData));
|
||||
|
||||
expect(modal.state.importValid).toBeTruthy();
|
||||
@@ -149,7 +148,7 @@ describe('Import Controller', function() {
|
||||
});
|
||||
|
||||
it('catches an invalid build', function() {
|
||||
let importData = require('./fixtures/anaconda-test-detailed-export-v3');
|
||||
const importData = require('./fixtures/anaconda-test-detailed-export-v3');
|
||||
pasteText(JSON.stringify(importData).replace('components', 'comps'));
|
||||
|
||||
expect(modal.state.importValid).toBeFalsy();
|
||||
@@ -162,8 +161,8 @@ describe('Import Controller', function() {
|
||||
beforeEach(reset);
|
||||
|
||||
it('imports all builds', function() {
|
||||
let importData = require('./fixtures/valid-detailed-export');
|
||||
let expectedBuilds = require('./fixtures/expected-builds');
|
||||
const importData = require('./fixtures/valid-detailed-export');
|
||||
const expectedBuilds = require('./fixtures/expected-builds');
|
||||
|
||||
pasteText(JSON.stringify(importData));
|
||||
expect(modal.state.importValid).toBeTruthy();
|
||||
@@ -185,7 +184,7 @@ describe('Import Controller', function() {
|
||||
describe('Import E:D Shipyard Builds', function() {
|
||||
|
||||
it('imports a valid builds', function() {
|
||||
let imports = require('./fixtures/ed-shipyard-import-valid');
|
||||
const imports = require('./fixtures/ed-shipyard-import-valid');
|
||||
|
||||
for (let i = 0; i < imports.length; i++ ) {
|
||||
reset();
|
||||
@@ -203,7 +202,7 @@ describe('Import Controller', function() {
|
||||
});
|
||||
|
||||
it('catches invalid builds', function() {
|
||||
let imports = require('./fixtures/ed-shipyard-import-invalid');
|
||||
const imports = require('./fixtures/ed-shipyard-import-invalid');
|
||||
|
||||
for (let i = 0; i < imports.length; i++ ) {
|
||||
reset();
|
||||
@@ -212,7 +211,21 @@ describe('Import Controller', function() {
|
||||
expect(modal.state.errorMsg).toEqual(imports[i].errorMsg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Imports from a Comparison', function() {
|
||||
|
||||
it('imports a valid comparison', function() {
|
||||
const importBuilds = require('./fixtures/valid-backup').builds;
|
||||
Persist.deleteAll();
|
||||
render = TU.renderIntoDocument(<ContextProvider><ModalImport builds={importBuilds} /></ContextProvider>);
|
||||
modal = TU.findRenderedComponentWithType(render, ModalImport);
|
||||
|
||||
expect(modal.state.processed).toBe(true);
|
||||
expect(modal.state.errorMsg).toEqual(null);
|
||||
clickImport();
|
||||
expect(Persist.getBuilds()).toEqual(importBuilds);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
37
__tests__/test-persist.js
Normal file
37
__tests__/test-persist.js
Normal file
@@ -0,0 +1,37 @@
|
||||
jest.dontMock('../src/app/stores/Persist');
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import TU from 'react-testutils-additions';
|
||||
|
||||
xdescribe('Persist', function() {
|
||||
|
||||
const Persist = require('../src/app/stores/Persist').default;
|
||||
|
||||
describe('Builds', function() {
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('Comparisons', function() {
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('Settings', function() {
|
||||
|
||||
it("has defaults", function() {
|
||||
expect(false).toBeTruthy('Implement');
|
||||
});
|
||||
|
||||
it("loads from localStorage correctly", function() {
|
||||
expect(false).toBeTruthy('Implement');
|
||||
});
|
||||
|
||||
it("generates the backup", function() {
|
||||
expect(false).toBeTruthy('Implement');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,27 +1,20 @@
|
||||
import Ship from '../src/app/shipyard/Ship';
|
||||
import { Ships } from 'coriolis-data';
|
||||
import * as Serializer from '../src/app/shipyard/Serializer';
|
||||
import jsen from 'jsen';
|
||||
|
||||
describe("Serializer Service", function() {
|
||||
|
||||
describe("Serializer", function() {
|
||||
const anacondaTestExport = require.requireActual('./fixtures/anaconda-test-detailed-export-v3');
|
||||
const code = anacondaTestExport.references[0].code;
|
||||
const anaconda = Ships.anaconda;
|
||||
const validate = jsen(require('../src/schemas/ship-loadout/3'));
|
||||
|
||||
describe("To Detailed Build", function() {
|
||||
let testBuild = new Ship('anaconda', anaconda.properties, anaconda.slots).buildFrom(code);
|
||||
let exportData = Serializer.toDetailedBuild('Test', testBuild);
|
||||
|
||||
let testBuild, exportData;
|
||||
|
||||
beforeEach(function() {
|
||||
testBuild = new Ship('anaconda', anaconda.properties, anaconda.slots);
|
||||
testBuild.buildFrom(code);
|
||||
exportData = Serializer.toDetailedBuild('Test', testBuild);
|
||||
});
|
||||
|
||||
xit("conforms to the v2 ship-loadout schema", function() {
|
||||
// var validate = jsen(require('../schemas/ship-loadout/3'));
|
||||
// var valid = validate(exportData);
|
||||
expect(valid).toBeTruthy();
|
||||
it("conforms to the v3 ship-loadout schema", function() {
|
||||
expect(validate(exportData)).toBe(true);
|
||||
});
|
||||
|
||||
it("contains the correct components and stats", function() {
|
||||
@@ -33,6 +26,21 @@ describe("Serializer Service", function() {
|
||||
|
||||
});
|
||||
|
||||
describe("Export Detailed Builds", function() {
|
||||
const expectedExport = require('./fixtures/valid-detailed-export');
|
||||
const builds = require('./fixtures/expected-builds');
|
||||
const exportData = Serializer.toDetailedExport(builds);
|
||||
|
||||
it("conforms to the v3 ship-loadout schema", function() {
|
||||
expect(exportData instanceof Array).toBe(true);
|
||||
|
||||
for (let detailedBuild of exportData) {
|
||||
expect(validate(detailedBuild)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("From Detailed Build", function() {
|
||||
|
||||
it("builds the ship correctly", function() {
|
||||
@@ -51,4 +59,5 @@ describe("Serializer Service", function() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user