|
|
@@ -329,6 +329,40 @@ describe('home learning modules', () => {
|
|
|
expect(play).not.toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
+ it('pages through all words in a history record without requesting a course unit', async () => {
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const originalPost = api.post.bind(api);
|
|
|
+ const post = spyOn(api, 'post').and.callFake((action, params) => action === 'e_record_detail'
|
|
|
+ ? of({ retcode: 1, result: Array.from({ length: 31 }, (_, index) => ({
|
|
|
+ GeneralID: 700 + index,
|
|
|
+ Title: `history-${index + 1}`,
|
|
|
+ detail: [{ GeneralID: 700 + index, Title: `history-${index + 1}`, sy: `释义 ${index + 1}` }],
|
|
|
+ })), addon: [] } as ApiEnvelope<any>)
|
|
|
+ : originalPost(action, params));
|
|
|
+ const get = spyOn(api, 'get').and.callThrough();
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/his/his_words?id=201');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+
|
|
|
+ const list = () => harness.routeNativeElement?.querySelectorAll('.readonly-word-list article') ?? [];
|
|
|
+ expect(list().length).toBe(30);
|
|
|
+ expect(harness.routeNativeElement?.textContent).toContain('共 31 个单词');
|
|
|
+ (harness.routeNativeElement?.querySelector('.word-preview-pagination .page-direction:last-of-type') as HTMLButtonElement).click();
|
|
|
+ await harness.fixture.whenStable();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(list().length).toBe(1);
|
|
|
+ expect(list()[0].textContent).toContain('history-31');
|
|
|
+ expect(harness.routeNativeElement?.textContent).toContain('2 / 2 页');
|
|
|
+ expect(get.calls.allArgs().some(([action]) => action === 'e_ck_list')).toBeFalse();
|
|
|
+ expect(post.calls.allArgs().filter(([action]) => action === 'e_record_detail').length).toBe(1);
|
|
|
+
|
|
|
+ (harness.routeNativeElement?.querySelector('.word-preview-pagination .page-direction:first-child') as HTMLButtonElement).click();
|
|
|
+ await harness.fixture.whenStable();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(list().length).toBe(30);
|
|
|
+ expect(list()[0].textContent).toContain('history-1');
|
|
|
+ });
|
|
|
+
|
|
|
it('plays student history words on click without changing learning records or enabling unit preview audio', async () => {
|
|
|
const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
api.historyWordAudio = 'apple.mp3';
|