SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
it('should return base endpoint', () => {expect(service.getBaseEndpoint()).toEqual(baseEndpoint);});
getBaseEndpoint的實(shí)現(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字段是一個(gè)getter:
private get activeBaseSite(): string {return (this._activeBaseSite ??getContextParameterDefault(this.config, BASE_SITE_CONTEXT_ID));}在單元測試mock數(shù)據(jù)里將這4個(gè)部分分別維護(hù)好即可。
總結(jié)
以上是生活随笔為你收集整理的SAP Spartacus OccEndpointsService单元测试之getBaseEndpoint的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 行为树
- 下一篇: 分享一个好用的Python在线编辑器(人