本文整理汇总了TypeScript中angular2-testing-lite/core.async函数的典型用法代码示例。如果您正苦于以下问题:TypeScript async函数的具体用法?TypeScript async怎么用?TypeScript async使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了async函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("AboutComponent", () => {
beforeEachProviders(() => [
MockBackend,
BaseRequestOptions,
provide(Http, {
useFactory: (backend: MockBackend, options: BaseRequestOptions) => new Http(backend, options),
deps: [MockBackend, BaseRequestOptions]
})
]);
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
builder = tcb
.overrideTemplate(AboutComponent, require("./about.html"));
}));
it("can create", async(
inject([], () => {
builder.createAsync(AboutComponent);
}))
);
it("has expected view", async(
inject([], () => {
builder
.createAsync(AboutComponent)
.then(fixture => {
assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>About Component</h3>
<p>This is the about component!</p>`);
});
}))
);
});
示例2: describe
describe("HomeComponent", () => {
beforeEachProviders(() => [
]);
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
builder = tcb
.overrideTemplate(HomeComponent, require("./home.html"));
}));
it("can create", async(
inject([], () => {
builder.createAsync(HomeComponent);
}))
);
it("has expected view", async(
inject([], () => {
builder
.createAsync(HomeComponent)
.then(fixture => {
assert.equal(fixture.debugElement.nativeElement.innerHTML, `<h3>Home Component</h3>
<p>Welcome to Angular Seed</p>`);
});
}))
);
});
示例3: describe
describe("Test: app.spec.ts", () => {
it("can instantiate", async(() => {
let store = new Store(null);
assert(!!store);
}));
describe("---", () => {
it("instanceof Store", async(() => {
const sc = new StoreController(new Store(null));
const store = sc.getStoreSafely();
assert(store instanceof Store);
}));
it("store.key check", async(() => {
const sc = new StoreController([new Store(null), new Store('second')]);
const mainStore = sc.getStoreSafely();
const secondStore = sc.getStoreSafely('second');
assert(mainStore.key === '__main__');
assert(secondStore.key === 'second');
}));
it('should fail', async(() => {
assert('2' === '3');
}));
});
});
示例4: xdescribe
xdescribe('getWeatherForCity', () => {
beforeEach(inject([ MockBackend ], (backend: MockBackend) => {
backend.connections.subscribe((c: MockConnection) => {
c.mockRespond(new Response(
new ResponseOptions({ status : 200, body : { 'city' : 'Berlin' } })));
});
}));
it('should return the mock data',
async(inject([ OpenWeatherApi ], (service: OpenWeatherApi) => {
service.getWeatherForCity('Berlin').toPromise().then(
resp => { expect(resp).to.exist; });
})));
});
示例5: describe
describe('AppComponent', () => {
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
builder = tcb.overrideProviders(AppComponent, []);
}));
it("can create", async(() => {
builder.createAsync(AppComponent)
.then(fixture => {
assert(!!fixture);
});
}));
it("should has text: 'My First Angular 2 App'", async(() => {
builder.createAsync(AppComponent)
.then(fixture => {
let el = fixture.debugElement;
assert(el.query(By.css("h1")).nativeElement.innerHTML === "My First Angular 2 App");
});
}));
it("should has text: 'My Test'", async(() => {
builder.createAsync(AppComponent)
.then(fixture => {
let el = fixture.debugElement;
assert(el.query(By.css("p")).nativeElement.innerHTML === "My Test");
});
}));
it("should fail", async(() => {
let app = new AppComponent();
let num = app.getNumber();
assert(num === 101);
}));
});
示例6: describe
describe("AppRootComponent", () => {
beforeEachProviders(() => [
...ROUTER_FAKE_PROVIDERS
]);
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
builder = tcb
.overrideTemplate(AppRootComponent, require("./app-root.html"));
}));
it("can create", async(
inject([], () => {
builder.createAsync(AppRootComponent);
}))
);
});
示例7: describe
describe("RepoBrowserComponent", () => {
beforeEachProviders(() => [
...ROUTER_FAKE_PROVIDERS,
]);
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
builder = tcb
.overrideTemplate(RepoBrowserComponent, require("./repo-browser.html"))
.overrideProviders(RepoBrowserComponent, [
provide(GitHub, {useClass: MockGitHub})
]);
}));
it("can create", async(
() => {
builder.createAsync(RepoBrowserComponent);
})
);
});