当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TestBed.resetTestEnvironment方法代码示例

本文整理汇总了TypeScript中@angular/core/testing.TestBed.resetTestEnvironment方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBed.resetTestEnvironment方法的具体用法?TypeScript TestBed.resetTestEnvironment怎么用?TypeScript TestBed.resetTestEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core/testing.TestBed的用法示例。


在下文中一共展示了TestBed.resetTestEnvironment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: platformBrowserDynamicTesting

const testModuleConfig = () => {
  TestBed.resetTestEnvironment();

  TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting())
    .configureTestingModule({
      imports: [
        RouterTestingModule,
        StoreModule.forFeature('i18n', reducers),
        EffectsModule.forFeature([LanguageEffects]),
        CoreModule.forRoot([
          {
            provide: ConfigLoader,
            useFactory: configFactory,
            deps: [
              PLATFORM_ID,
              HttpClient
            ]
          }
        ]),
        CoreTestingModule,
        NgrxTestingModule,
        AnalyticsModule,
        I18NTestingModule
      ],
      providers: [
        LanguageEffects
      ]
    });
};
开发者ID:John123Yu,项目名称:universal-1,代码行数:29,代码来源:language.effects.spec.ts

示例2: platformBrowserDynamicTesting

export function setup<T>(moduleType: Type<T>, options: { storedValue?: any } = {}) {
  TestBed.resetTestEnvironment();
  TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
  const bootstrap: BootstrapModuleFn<T> = () =>
    getTestBed().platform.bootstrapModule(moduleType);
  const storedValue = options.storedValue;
  const storageValue = options.storedValue ? JSON.stringify(storedValue) : '';
  sessionStorage.setItem(NGXS_HMR_SNAPSHOT_KEY, storageValue);
  MockState.clear();
  return { bootstrap };
}
开发者ID:LucasFrecia,项目名称:store,代码行数:11,代码来源:hmr-helpers.ts

示例3: platformBrowserDynamicTesting

const testModuleConfig = () => {
  TestBed.resetTestEnvironment();

  TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting())
    .configureTestingModule({
      imports: [
        CoreModule.forRoot([
          {
            provide: ConfigLoader,
            useFactory: configFactory,
            deps: [
              PLATFORM_ID,
              HttpClient
            ]
          }
        ]),
        CoreTestingModule
      ]
    });
};
开发者ID:John123Yu,项目名称:universal-1,代码行数:20,代码来源:language.reducer.spec.ts

示例4: afterAll

 afterAll(() => {
   TestBed.resetTestEnvironment();
 });
开发者ID:lukethompson,项目名称:aws-amplify,代码行数:3,代码来源:auth.state.spec.ts

示例5: resetTestEnvironmentWithSummaries

 function resetTestEnvironmentWithSummaries(summaries?: () => any[]) {
   const {platform, ngModule} = getTestBed();
   TestBed.resetTestEnvironment();
   TestBed.initTestEnvironment(ngModule, platform, summaries);
 }
开发者ID:thorn0,项目名称:angular,代码行数:5,代码来源:jit_summaries_integration_spec.ts

示例6: require

 * This software is released under MIT license.
 * The full license information can be found in LICENSE in the root directory of this project.
 */

import "core-js";
import "core-js/es7/reflect";
import "zone.js/dist/zone";
import "zone.js/dist/long-stack-trace-zone";
import "zone.js/dist/async-test";
import "zone.js/dist/fake-async-test";
import "zone.js/dist/sync-test";
import "zone.js/dist/proxy";
import "zone.js/dist/jasmine-patch";
import JasmineExpect from "jasmine-expect";

/* tslint:disable no-var-requires no-require-imports */
const browserTesting = require("@angular/platform-browser-dynamic/testing");
const coreTesting = require("@angular/core/testing");
// include every .spec.ts file inside src, except for those in ks-app folder
const context = (require as any).context("../src/", true, /^((?![\\/]ks-app[\\/]).)*\.spec\.ts$/);
/* tslint:enable no-var-requires no-require-imports*/

Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 2000;

coreTesting.TestBed.resetTestEnvironment();
coreTesting.TestBed.initTestEnvironment(browserTesting.BrowserDynamicTestingModule,
                                        browserTesting.platformBrowserDynamicTesting());

context.keys().forEach(context);
开发者ID:beqom,项目名称:clarity,代码行数:30,代码来源:tests.entry.ts

示例7: beforeAll

 beforeAll( () => {
     TestBed.resetTestEnvironment()
     TestBed.initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ) 
 })
开发者ID:pracxs,项目名称:angular-2-intro,代码行数:4,代码来源:person.service.get.spec.ts

示例8: platformBrowserDynamicTesting

/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
     

import { AppComponent } from '../App/app.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
 
          
// The following initializes the test environment for Angular 2. This call is required for Angular 2 dependency injection.
// That's new in Angular 2 RC5
TestBed.resetTestEnvironment();
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

describe("AppComponent -> ", () => {
        
    let de: DebugElement; 
    let comp: AppComponent; 
    let fixture: ComponentFixture<AppComponent>;
       
    beforeEach(async(() => {
        TestBed.configureTestingModule({
            declarations: [AppComponent]
        })
            .compileComponents();
    }));      

    beforeEach(() => {  
        fixture = TestBed.createComponent(AppComponent);
        comp = fixture.componentInstance;
开发者ID:Pablissimo,项目名称:chutzpah,代码行数:31,代码来源:app.component.spec.ts

示例9: MockStore

scenarios.forEach((scenario) => {
	TestBed.resetTestEnvironment();
	describe(scenario.name, () => {
		// create a new backing store for each call. Otherwise all tests will share the same backing.
		const createBacking = () => {
			return new MockStore({
				baseKey1: '"value1"',
				baseKey2: '"value2"',
				'prefix-Key1': '"value3"',
				'prefix-Key2': '"value4"'
			});
		};

		TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
		beforeEach(() => {
			TestBed.configureTestingModule({
				providers: [
					MockStorage,
					{ provide: MockStore, useValue: createBacking() },
					{ provide: MockOptions, useValue: scenario.options },
					MockSerdes
				]
			});
			mockStorage = TestBed.get(MockStorage);
			mockStore = TestBed.get(MockStore);
		});

		it('should load all keys from storage', () => {
			expect(mockStorage.length).toBe(scenario.totalKeys);
		});

		it('can delete a key with delete keyword', () => {
			delete mockStorage[scenario.keyName];
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + scenario.keyName]).not.toBeDefined();
		});

		it('can delete a key with removeItem', () => {
			mockStorage.removeItem(scenario.keyName);
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + scenario.keyName]).not.toBeDefined();
		});

		it('can clear all keys', () => {
			const totalStored = mockStore.length;
			expect(mockStorage.length).toBe(scenario.totalKeys);
			mockStorage.clear();
			mockStorage.detectChanges();
			const found = Object.keys(mockStore).some((key) => key.startsWith(scenario.options.prefix));
			expect(found).toBe(false);
			expect(mockStore.length).toBe(totalStored - scenario.totalKeys);
		});

		it('can create a key', () => {
			expect(mockStore[scenario.options.prefix + 'brandNewKey']).not.toBeDefined();
			mockStorage['brandNewKey'] = { valueType: 'complex' };
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + 'brandNewKey']).toBeDefined();
		});

		it('can create a key with setItem', () => {
			expect(mockStore[scenario.options.prefix + 'brandNewKey']).not.toBeDefined();
			mockStorage.setItem('brandNewKey', 'simple');
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + 'brandNewKey']).toBeDefined();
		});

		it('will pass-thru pre-stringified objects', () => {
			const value = JSON.stringify({ valueType: 'complex' });
			mockStorage.setItem('brandNewKey', value);
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + 'brandNewKey']).toBe(value);
		});

		it('can retieve a value', () => {
			const expected = JSON.parse(mockStore[scenario.options.prefix + scenario.keyName]);
			expect(mockStorage[scenario.keyName]).toBe(expected);
		});

		it('can retireve a key with getItem', () => {
			const expected = JSON.parse(mockStore[scenario.options.prefix + scenario.keyName]);
			expect(mockStorage.getItem(scenario.keyName)).toBe(expected);
		});

		it('can retireve a key', () => {
			expect(mockStorage.key(scenario.keyIndex)).toBe(scenario.keyName);
		});

		it('can update a value', () => {
			mockStorage[scenario.keyName] = { valueType: 'complex' };
			mockStorage.detectChanges();
			expect(mockStore[scenario.options.prefix + scenario.keyName]).toBe(JSON.stringify({ valueType: 'complex' }));
		});

		it('will sync on storage event', () => {
			expect(mockStorage['otherKey']).not.toBeDefined();
			mockStore[scenario.options.prefix + 'otherKey'] = '"newValue"';
			mockStorage
				.createStorageEvent()
				.detectChanges();
//.........这里部分代码省略.........
开发者ID:SirDarquan,项目名称:h5webstorage,代码行数:101,代码来源:basestorage.spec.ts

示例10: afterEach

 afterEach(() => { TestBed.resetTestEnvironment(); });
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:1,代码来源:jit_summaries_spec.ts


注:本文中的@angular/core/testing.TestBed.resetTestEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。