當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。