Skip to content

Commit

Permalink
fix(test): cover storage service
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Apr 3, 2020
1 parent 1bd0c8b commit d1b0947
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/storage/TestStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { NotFoundError } from '@apextoaster/js-utils';
import { expect } from 'chai';

import { EntityModule } from '../../src/module/EntityModule';
import { MigrationModule } from '../../src/module/MigrationModule';
import { Storage } from '../../src/storage';
import { createServiceContainer } from '../helpers/container';

const TEST_METADATA = {
kind: 'test-storage',
name: 'test-storage',
};

describe('storage service', async () => {
xit('should handle connection errors');

it('should close connections when stopped', async () => {
const { container } = await createServiceContainer(new EntityModule(), new MigrationModule());
const storage = await container.create(Storage, {
data: {
migrate: false,
orm: {
database: 'out/test.db',
type: 'sqlite',
},
},
metadata: TEST_METADATA,
});
await storage.start();
await storage.stop();
expect(storage.isConnected).to.equal(false);
});

it('should check connection status', async () => {
const { container } = await createServiceContainer(new EntityModule(), new MigrationModule());
const storage = await container.create(Storage, {
data: {
migrate: false,
orm: {
database: 'test.db',
type: 'sqlite',
},
},
metadata: TEST_METADATA,
});
await storage.start();
const connected = storage.isConnected;
await storage.stop();
expect(connected).to.equal(true);
});
});

0 comments on commit d1b0947

Please sign in to comment.