migrating to typescript
This commit is contained in:
parent
1f81dda083
commit
8b199cf9c3
|
@ -18,49 +18,45 @@
|
|||
*
|
||||
* @author Anatoly Khaytovich <anatolyuss@gmail.com>
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const TestSchemaProcessor = require('./TestModules/TestSchemaProcessor');
|
||||
const testSchema = require('./TestModules/SchemaProcessorTest');
|
||||
const testDataContent = require('./TestModules/DataContentTest');
|
||||
const testColumnTypes = require('./TestModules/ColumnTypesTest');
|
||||
import * as test from 'tape';
|
||||
import { EventEmitter } from 'events';
|
||||
import Conversion from '../src/Conversion';
|
||||
import TestSchemaProcessor from './TestModules/TestSchemaProcessor';
|
||||
import testSchema from './TestModules/SchemaProcessorTest';
|
||||
import testDataContent from './TestModules/DataContentTest';
|
||||
import testColumnTypes from './TestModules/ColumnTypesTest';
|
||||
|
||||
/**
|
||||
* Runs test suites.
|
||||
*
|
||||
* @param {TestSchemaProcessor} testSchemaProcessor
|
||||
*
|
||||
* @returns {Function}
|
||||
*/
|
||||
const runTestSuites = testSchemaProcessor => {
|
||||
function runTestSuites(testSchemaProcessor: TestSchemaProcessor): () => void {
|
||||
return () => {
|
||||
test.onFinish(() => {
|
||||
testSchemaProcessor.removeTestResources()
|
||||
.then(() => process.exit());
|
||||
test.onFinish(async () => {
|
||||
await testSchemaProcessor.removeTestResources();
|
||||
process.exit();
|
||||
});
|
||||
|
||||
test('Test schema should be created', tapeTestSchema => {
|
||||
test('Test schema should be created', (tapeTestSchema: test.Test) => {
|
||||
testSchema(testSchemaProcessor, tapeTestSchema);
|
||||
});
|
||||
|
||||
test('Test the data content', tapeTestDataContent => {
|
||||
test('Test the data content', (tapeTestDataContent: test.Test) => {
|
||||
testDataContent(testSchemaProcessor, tapeTestDataContent);
|
||||
});
|
||||
|
||||
test('Test column types', tapeTestColumnTypes => {
|
||||
test('Test column types', (tapeTestColumnTypes: test.Test) => {
|
||||
testColumnTypes(testSchemaProcessor, tapeTestColumnTypes);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const testSchemaProcessor = new TestSchemaProcessor();
|
||||
const testSchemaProcessor: TestSchemaProcessor = new TestSchemaProcessor();
|
||||
|
||||
testSchemaProcessor
|
||||
.initializeConversion()
|
||||
.then(conversion => {
|
||||
.then((conversion: Conversion) => {
|
||||
// Registers callback, that will be invoked when the test database arrangement will be completed.
|
||||
conversion._eventEmitter.on(conversion._migrationCompletedEvent, runTestSuites(testSchemaProcessor));
|
||||
(<EventEmitter>conversion._eventEmitter).on(conversion._migrationCompletedEvent, runTestSuites(testSchemaProcessor));
|
||||
|
||||
// Continues the test database arrangement.
|
||||
return Promise.resolve(conversion);
|
|
@ -18,11 +18,12 @@
|
|||
*
|
||||
* @author Anatoly Khaytovich <anatolyuss@gmail.com>
|
||||
*/
|
||||
import { TestSchemaProcessor } from './TestSchemaProcessor';
|
||||
import TestSchemaProcessor from './TestSchemaProcessor';
|
||||
import Conversion from '../../src/Conversion';
|
||||
import DBAccess from '../../src/DBAccess';
|
||||
import DBVendors from '../../src/DBVendors';
|
||||
import DBAccessQueryResult from '../../src/DBAccessQueryResult';
|
||||
import { Test } from 'tape';
|
||||
|
||||
/**
|
||||
* Checks if the schema exists.
|
||||
|
@ -44,21 +45,14 @@ async function hasSchemaCreated(testSchemaProcessor: TestSchemaProcessor): Promi
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO: check @types/tape.
|
||||
* Schema creation testing.
|
||||
*
|
||||
* @param {TestSchemaProcessor} testSchemaProcessor
|
||||
* @param {Tape} tape
|
||||
*
|
||||
* @returns {undefined}
|
||||
* Tests schema creation.
|
||||
*/
|
||||
module.exports = (testSchemaProcessor, tape) => {
|
||||
hasSchemaCreated(testSchemaProcessor).then(schemaExists => {
|
||||
const numberOfPlannedAssertions = 1;
|
||||
const autoTimeoutMs = 3 * 1000; // 3 seconds.
|
||||
export default async function(testSchemaProcessor: TestSchemaProcessor, tape: Test): Promise<void> {
|
||||
const schemaExists: boolean = await hasSchemaCreated(testSchemaProcessor);
|
||||
const numberOfPlannedAssertions: number = 1;
|
||||
const autoTimeoutMs: number = 3 * 1000; // 3 seconds.
|
||||
|
||||
tape.plan(numberOfPlannedAssertions);
|
||||
tape.timeoutAfter(autoTimeoutMs);
|
||||
tape.equal(schemaExists, true);
|
||||
});
|
||||
tape.plan(numberOfPlannedAssertions);
|
||||
tape.timeoutAfter(autoTimeoutMs);
|
||||
tape.equal(schemaExists, true);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import { createStateLogsTable } from '../../src/MigrationStateManager';
|
|||
import { createDataPoolTable, readDataPool } from '../../src/DataPoolManager';
|
||||
import generateError from '../../src/ErrorGenerator';
|
||||
|
||||
export class TestSchemaProcessor {
|
||||
export default class TestSchemaProcessor {
|
||||
/**
|
||||
* Instance of class Main.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue