本文整理汇总了TypeScript中src/app/test/dotcms-events-service.mock.DotcmsEventsServiceMock类的典型用法代码示例。如果您正苦于以下问题:TypeScript mock.DotcmsEventsServiceMock类的具体用法?TypeScript mock.DotcmsEventsServiceMock怎么用?TypeScript mock.DotcmsEventsServiceMock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mock.DotcmsEventsServiceMock类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fakeAsync
fakeAsync(() => {
const events: string[] = [
'SAVE_SITE',
'PUBLISH_SITE',
'UPDATE_SITE_PERMISSIONS',
'UN_ARCHIVE_SITE',
'UPDATE_SITE',
'ARCHIVE_SITE'
];
const dotcmsEventsService: DotcmsEventsServiceMock = this.injector.get(
DotcmsEventsService
);
const siteService = this.injector.get(SiteService);
const data = {
data: {
data: {
identifier: '5'
}
},
eventType: 'ARCHIVE_SITE'
};
this.siteService.switchSite(currentSite);
respondSwitchSiteRequest.bind(this)();
spyOn(siteService, 'siteEventsHandler');
dotcmsEventsService.triggerSubscribeToEvents(events, data);
tick();
expect(siteService.siteEventsHandler).toHaveBeenCalledWith(data);
})
示例2: describe
describe('DotMessageDisplayService', () => {
const mockRouter = {
routerState: {
snapshot: {
url: '/content-types-angular'
}
}
};
const mockDotcmsEventsService: DotcmsEventsServiceMock = new DotcmsEventsServiceMock();
let dotMessageDisplayService;
const messageExpected: any = {
life: 3000,
message: 'Hello World',
portletIdList: [],
severity: 'ERROR',
type: 'SIMPLE_MESSAGE'
};
beforeEach(() => {
const injector = DOTTestBed.resolveAndCreate([
{ provide: DotcmsEventsService, useValue: mockDotcmsEventsService },
{ provide: Router, useValue: mockRouter },
DotMessageDisplayService
]);
dotMessageDisplayService = injector.get(DotMessageDisplayService);
});
it('should emit a message', (done) => {
dotMessageDisplayService.messages().subscribe((message: DotMessage) => {
expect(message).toEqual({
...messageExpected,
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});
done();
});
mockDotcmsEventsService.triggerSubscribeTo('MESSAGE', {
data: messageExpected,
type: 'SIMPLE_MESSAGE'
});
});
it('should unsubscribe', () => {
let wasCalled = false;
dotMessageDisplayService.messages().subscribe(() => {
wasCalled = true;
});
dotMessageDisplayService.unsubscribe();
mockDotcmsEventsService.triggerSubscribeTo('MESSAGE', {
data: messageExpected,
type: 'SIMPLE_MESSAGE'
});
expect(wasCalled).toBe(false);
});
describe('with portletIdList', () => {
it('should show message when currentPortlet is in portletIdList ', (done) => {
messageExpected.portletIdList = ['content-types-angular'];
dotMessageDisplayService.messages().subscribe((message: DotMessage) => {
expect(message).toEqual({
...messageExpected,
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});
done();
});
mockDotcmsEventsService.triggerSubscribeTo('MESSAGE', {
data: messageExpected,
type: 'SIMPLE_MESSAGE'
});
});
it('should not show message when currentPortlet is not in portletIdList ', () => {
messageExpected.portletIdList = ['not-content-types-angular'];
let wasCalled = false;
dotMessageDisplayService.messages().subscribe(() => {
wasCalled = true;
});
mockDotcmsEventsService.triggerSubscribeTo('MESSAGE', {
data: messageExpected,
type: 'SIMPLE_MESSAGE'
});
expect(wasCalled).toBe(false);
});
//.........这里部分代码省略.........
示例3: it
it('should emit a message', (done) => {
dotMessageDisplayService.messages().subscribe((message: DotMessage) => {
expect(message).toEqual({
...messageExpected,
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});
done();
});
mockDotcmsEventsService.triggerSubscribeTo('MESSAGE', {
data: messageExpected,
type: 'SIMPLE_MESSAGE'
});
});