前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SAP Spartacus popover Component 的单元测试

SAP Spartacus popover Component 的单元测试

作者头像
Jerry Wang
发布2021-04-07 16:09:51
3080
发布2021-04-07 16:09:51
举报

我们在SAP Spartacus B2B Page 的 list和Card页面,点击(i) icon之后,会看到一个popover Component,可以通过下面的选择器访问:

cx-popover > .popover-body > p

可以通过如下的代码访问:

代码语言:javascript
复制
describe('hint', () => {
    beforeEach(() => {
      fixture.detectChanges();
    });
    it('should not show hint by default', () => {
      const el = fixture.debugElement.query(
        By.css('cx-popover > .popover-body > p')
      );
      expect(el).toBeFalsy();
    });

    it('should display hint after click info button', () => {
      const infoButton = fixture.debugElement.query(
        By.css('button[ng-reflect-cx-popover]')
      ).nativeElement;
      infoButton.click();
      const el = fixture.debugElement.query(
        By.css('cx-popover > .popover-body > p')
      );
      expect(el).toBeTruthy();
      expect(el.nativeElement.innerText).toBe('organization.budget.hint');
    });
  });

其中下面这行代码是css属性选择器的用法:

代码语言:javascript
复制
button[ng-reflect-cx-popover]

因为button按钮渲染完毕后,具有属性 ng-reflect-cx-popover

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-03-29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • cx-popover > .popover-body > p
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档