Skip to content

Instantly share code, notes, and snippets.

View topnotch48's full-sized avatar

n.yakovenko topnotch48

  • behind your back
View GitHub Profile
@topnotch48
topnotch48 / Repository.cs
Created December 21, 2017 10:44
General Repo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using AutoMapper;
using CardDisputes.Db.Olap.Contracts;
using CardDisputes.Db.Olap.DAL.DataMapping;
using CardDisputes.Db.Olap.DAL.DataMapping.Predicates;
describe('BannerComponent', () => {
let component: BannerComponent;
let fixture: ComponentFixture<BannerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ BannerComponent ]
})
.compileComponents();
}));
import {resetFakeAsyncZone} from './fake_async';
import {TestBed} from './test_bed';
declare var global: any;
const _global = <any>(typeof window === 'undefined' ? global : window);
// Reset the test providers and the fake async zone before each test.
if (_global.beforeEach) {
_global.beforeEach(() => {
TestBed.resetTestingModule();
resetFakeAsyncZone();
});
resetTestingModule() {
clearOverrides();
this._aotSummaries = [];
this._templateOverrides = [];
this._compiler = null !;
this._moduleOverrides = [];
this._componentOverrides = [];
this._directiveOverrides = [];
this._pipeOverrides = [];
get(token: any, notFoundValue: any = Injector.THROW_IF_NOT_FOUND) {
this._initIfNeeded();
if (token === TestBed) {
return this;
}
const result = this._moduleRef.injector.get(token, UNDEFINED);
return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue) : result;
}
private _initIfNeeded() {
if (this._instantiated) {
return;
}
if (!this._moduleFactory) {
try {
const moduleType = this._createCompilerAndModule();
this._moduleFactory =
this._compiler.compileModuleAndAllComponentsSync(moduleType).ngModuleFactory;
} catch (e) {
/**
* Reconfigures current test suit to prevent angular components compilation after every test run.
* Forces angular test bed to re-create zone and all injectable services by directly
* changing _instantiated to false after every test run.
* Cleanups all the changes and reverts test bed configuration after suite is finished.
*/
export const configureTestSuite = () => {
const testBedApi: any = getTestBed();
const originReset = TestBed.resetTestingModule;
describe('#productions Production wizard bates settings', () => {
beforeEach(done => (async () => {
TestBed.configureTestingModule({
imports: modules,
providers: [defaultGlobalProvidersForTests]
});
TestBed.overrideModule(ProductionsModule, overrides);
describe('#productions Production wizard bates settings', () => {
configureTestSuite();
beforeAll(done => (async () => {
TestBed.configureTestingModule({
imports: modules,
providers: [defaultGlobalProvidersForTests]
});
...
frameworks: [
'parallel',
'jasmine'
],
plugins: [
"karma-jasmine",
"karma-chrome-launcher",
"karma-junit-reporter",
"karma-spec-reporter",