mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 20:43:08 +00:00
[DURACOM-240] add and fix tests
This commit is contained in:

committed by
Giuseppe Digilio

parent
e1ba78c443
commit
3e30f64e9c
@@ -1,16 +1,54 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
Observable,
|
||||
of,
|
||||
} from 'rxjs';
|
||||
|
||||
import { MathService } from './math.service';
|
||||
import {
|
||||
MathJaxConfig,
|
||||
MathService,
|
||||
} from './math.service';
|
||||
|
||||
export class MockMathService extends MathService {
|
||||
protected mathJaxOptions: any = {};
|
||||
protected mathJax: MathJaxConfig = { source: '', id: '' };
|
||||
protected mathJaxFallback: MathJaxConfig = { source: '', id: '' };
|
||||
|
||||
protected registerMathJaxAsync(config: MathJaxConfig): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
ready(): Observable<boolean> {
|
||||
return of(true);
|
||||
}
|
||||
|
||||
render(element: HTMLElement): void {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
describe('MathService', () => {
|
||||
let service: MathService;
|
||||
let service: MockMathService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(MathService);
|
||||
service = new MockMathService();
|
||||
spyOn(service, 'render');
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be ready', (done) => {
|
||||
service.ready().subscribe(isReady => {
|
||||
expect(isReady).toBe(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should render', () => {
|
||||
service.render(document.createElement('div'));
|
||||
expect(service.render).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user