簡體   English   中英

如何在 Jasmine 中對 httpParams 進行單元測試

[英]how to unit test httpParams in Jasmine

我是單元測試的新手。 我有一個 function 正在設置查詢參數:

setParams(scale): HttpParams {
    return this.params = new HttpParams()
        .set('scale', scale);
}

output 將權利傳遞給 http 獲取方法。 但我不知道如何測試上面的 function 是否真的給出了 http 參數。 誰能給我一些建議? 謝謝!

類似於以下內容:

it('should set params', () => {
  const params = service.setParams('hello'); // I assume this is in the service code
  expect(params.get('scale')).toBe('hello');
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM