fix: do not load mocks in container.ts since they are not available in the built app

This commit is contained in:
Xymorot 2020-07-25 22:28:55 +02:00
parent f17801cb4c
commit 0baba65686
2 changed files with 8 additions and 13 deletions

View File

@ -5,21 +5,11 @@ import { NhentaiApi } from '../modules/nhentai/nhentai-api';
import '../modules/nhentai/nhentai-ipc-controller';
import { Session } from '../modules/session/session';
import { Store } from '../modules/store/store';
import { StoreMock } from '../modules/store/store.mock';
import { WebCrawler } from '../modules/web-crawler/web-crawler';
export const container = new Container({ defaultScope: 'Singleton' });
container.bind(Symbol.for('store')).to(Store);
export function mockStore(unMock = false): void {
if (unMock) {
container.unbind(Symbol.for('store'));
container.bind(Symbol.for('store')).to(Store);
} else {
container.unbind(Symbol.for('store'));
container.bind(Symbol.for('store')).to(StoreMock);
}
}
container.bind(Symbol.for('web-crawler')).to(WebCrawler);

View File

@ -6,7 +6,9 @@ import 'mocha';
import nock from 'nock';
import { Response } from 'node-fetch';
import sinon from 'sinon';
import { container, mockStore } from '../../core/container';
import { container } from '../../core/container';
import { Store } from '../store/store';
import { StoreMock } from '../store/store.mock';
import { IWebCrawler } from './i-web-crawler';
describe('Web Crawler', function () {
@ -15,7 +17,8 @@ describe('Web Crawler', function () {
before(() => {
rewiremock.enable();
mockStore();
container.unbind(Symbol.for('store'));
container.bind(Symbol.for('store')).to(StoreMock);
});
beforeEach(() => {
@ -30,7 +33,9 @@ describe('Web Crawler', function () {
after(() => {
rewiremock.disable();
mockStore(true);
container.unbind(Symbol.for('store'));
container.bind(Symbol.for('store')).to(Store);
});
it('fetches websites', async () => {