本文整理汇总了TypeScript中@angular/core/testing.TestBedStatic类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestBedStatic类的具体用法?TypeScript TestBedStatic怎么用?TypeScript TestBedStatic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestBedStatic类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("when the root store is created", () => {
let injector: TestBedStatic
const initialState = {
isInitialised: true,
computed: () => 1 + 1,
}
const computedState = {
isInitialised: true,
computed: 2,
}
beforeEach(() => {
injector = createTestStoreForRoot(() => initialState)
})
it("should be created", () => {
const result = injector.get(Store)
expect(result).toBeInstanceOf(Store)
expect(result).toBeInstanceOf(Observable)
})
it("should initialise the state and calculate computed properties", () => {
const subject: Store<any> = injector.get(Store)
expect(subject.state).toEqual(computedState)
})
})
示例2: beforeEach
beforeEach(async(() => {
testbed = TestBed.configureTestingModule({
imports: [FormulaModule],
declarations: [FakeComponent, FakeInputComponent],
providers: [],
})
testbed.overrideModule(BrowserDynamicTestingModule, {
set: {
entryComponents: [FakeComponent, FakeInputComponent],
},
})
void testbed.compileComponents()
}))
示例3: it
it("should dispatch an action", async(() => {
const subject: Actions = injector.get(Actions)
const result = { type: "ACTION" }
subject.pipe(take(1)).subscribe(action => expect(action).toEqual(result))
store.dispatch(result)
}))