SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
it('should return base endpoint', () => {expect(service.getBaseEndpoint()).toEqual(baseEndpoint);});
getBaseEndpoint的實現(xiàn):
getBaseEndpoint(): string {if (!this.config?.backend?.occ) {return '';}return ((this.config.backend.occ.baseUrl || '') +this.config.backend.occ.prefix +this.activeBaseSite);}來自注入的OccConfig的backend.occ.baseUrl, prefix和Service本身的activeBaseSite字段。
service的activeBaseSite字段是一個getter:
private get activeBaseSite(): string {return (this._activeBaseSite ??getContextParameterDefault(this.config, BASE_SITE_CONTEXT_ID));}在單元測試mock數(shù)據(jù)里將這4個部分分別維護好即可。
總結
以上是生活随笔為你收集整理的SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 行为树
- 下一篇: SAP Spartacus OccEnd