fix: do not load mocks in container.ts since they are not available in the built app
This commit is contained in:
parent
f17801cb4c
commit
0baba65686
|
@ -5,21 +5,11 @@ import { NhentaiApi } from '../modules/nhentai/nhentai-api';
|
||||||
import '../modules/nhentai/nhentai-ipc-controller';
|
import '../modules/nhentai/nhentai-ipc-controller';
|
||||||
import { Session } from '../modules/session/session';
|
import { Session } from '../modules/session/session';
|
||||||
import { Store } from '../modules/store/store';
|
import { Store } from '../modules/store/store';
|
||||||
import { StoreMock } from '../modules/store/store.mock';
|
|
||||||
import { WebCrawler } from '../modules/web-crawler/web-crawler';
|
import { WebCrawler } from '../modules/web-crawler/web-crawler';
|
||||||
|
|
||||||
export const container = new Container({ defaultScope: 'Singleton' });
|
export const container = new Container({ defaultScope: 'Singleton' });
|
||||||
|
|
||||||
container.bind(Symbol.for('store')).to(Store);
|
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);
|
container.bind(Symbol.for('web-crawler')).to(WebCrawler);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ import 'mocha';
|
||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
import { Response } from 'node-fetch';
|
import { Response } from 'node-fetch';
|
||||||
import sinon from 'sinon';
|
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';
|
import { IWebCrawler } from './i-web-crawler';
|
||||||
|
|
||||||
describe('Web Crawler', function () {
|
describe('Web Crawler', function () {
|
||||||
|
@ -15,7 +17,8 @@ describe('Web Crawler', function () {
|
||||||
before(() => {
|
before(() => {
|
||||||
rewiremock.enable();
|
rewiremock.enable();
|
||||||
|
|
||||||
mockStore();
|
container.unbind(Symbol.for('store'));
|
||||||
|
container.bind(Symbol.for('store')).to(StoreMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -30,7 +33,9 @@ describe('Web Crawler', function () {
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
rewiremock.disable();
|
rewiremock.disable();
|
||||||
mockStore(true);
|
|
||||||
|
container.unbind(Symbol.for('store'));
|
||||||
|
container.bind(Symbol.for('store')).to(Store);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fetches websites', async () => {
|
it('fetches websites', async () => {
|
||||||
|
|
Loading…
Reference in New Issue