我有一个带有函数 getSettingtHis
和 getLastIndex
的类,它们在辅助函数中使用,如何在单元测试中模拟这些值,以便我在 trackSetting
< 中测试逻辑/p>
export class SettingController {
#setting: [];
constructor() {
this.#setting = [];
this.#lastIndex = 0;
}
getSettingHis(): [] {
return this.#setting;
}
getLastIndex(): number {
return this.#lastIndex;
}
}
export function trackSetting(): boolean {
let hasSetting = false;
const lastIndex = settingController.getLastIndex();
const totalSettingHistory = [...settingController.getSettingHis()]
//** logic checking */
}