SAP Spartacus popover Component 的单元测试
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus popover Component 的单元测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我們在SAP Spartacus B2B Page 的 list和Card頁面,點擊(i) icon之后,會看到一個popover Component,可以通過下面的選擇器訪問:
cx-popover > .popover-body > p
可以通過如下的代碼訪問:
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屬性選擇器的用法:
button[ng-reflect-cx-popover]因為button按鈕渲染完畢后,具有屬性 ng-reflect-cx-popover
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的SAP Spartacus popover Component 的单元测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP Cloud for Custom
- 下一篇: (一)主动学习概念与技术