| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { ComponentFixture, TestBed } from '@angular/core/testing';
- import { OperationsService } from '../operations.service';
- import { OperationsVocabularyComponent } from './operations-vocabulary.component';
- describe('OperationsVocabularyComponent', () => {
- let fixture: ComponentFixture<OperationsVocabularyComponent>;
- let component: OperationsVocabularyComponent;
- let operations: jasmine.SpyObj<OperationsService>;
- beforeEach(async () => {
- operations = jasmine.createSpyObj<OperationsService>('OperationsService', ['vocabularyTree', 'vocabulary']);
- operations.vocabularyTree.and.resolveTo({ items: [], total: 0, totalWords: 89620, refreshedAt: '2026-08-22T12:00:00.000Z' });
- operations.vocabulary.and.resolveTo({ page: 1, pageSize: 30, total: 89620, items: [], refreshedAt: '2026-08-22T12:00:00.000Z' });
- await TestBed.configureTestingModule({
- imports: [OperationsVocabularyComponent],
- providers: [
- { provide: OperationsService, useValue: operations },
- ],
- }).compileComponents();
- fixture = TestBed.createComponent(OperationsVocabularyComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- await fixture.whenStable();
- });
- it('loads the complete vocabulary by default instead of one arbitrary unit', () => {
- expect(component.totalWords()).toBe(89620);
- expect(component.selectedNodeId()).toBe(0);
- expect(operations.vocabulary).toHaveBeenCalledWith(1, 30, '', { nodeId: 0, status: '', missingAudio: false });
- });
- it('normalizes old audio filenames and UploadFiles paths through the legacy asset host', () => {
- expect(component.audioSource('apple.mp3')).toBe('/backend/UploadFiles/apple.mp3');
- expect(component.audioSource('UploadFiles/unit/apple.mp3')).toBe('/backend/UploadFiles/unit/apple.mp3');
- expect(component.audioSource('/UploadFiles/unit/apple.mp3')).toBe('/backend/UploadFiles/unit/apple.mp3');
- expect(component.audioSource('https://cdn.example/apple.mp3')).toBe('https://cdn.example/apple.mp3');
- });
- it('keeps the normalized old-site audio URL unchanged', () => {
- const url = 'https://a018.2018.z01.com/UploadFiles/audio/c/cherish.mp3';
- expect(component.audioSource(url)).toBe(url);
- });
- });
|