ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
34 lines (26 loc) • 1.21 kB
text/typescript
/* tslint:disable:no-any */
import { createNzRootInitializer, NzRootConfig } from './nz-root-config';
describe('NzRootConfig', () => {
let mockDocument: Document;
let mockConfig: NzRootConfig;
let mockElement: HTMLDivElement;
beforeEach(() => {
mockDocument = { head: { appendChild: () => null }, createElement: () => null } as any;
mockConfig = { extraFontName: '', extraFontUrl: '' } as any;
mockElement = {} as any;
spyOn(mockDocument, 'createElement').and.returnValue(mockElement);
spyOn(mockDocument.head, 'appendChild');
});
it('should apply extra font style when option provided', () => {
const iniliatizer = createNzRootInitializer(mockDocument, mockConfig);
iniliatizer();
expect(mockDocument.createElement).toHaveBeenCalledWith('style');
expect(mockDocument.head.appendChild).toHaveBeenCalledWith(mockElement);
});
it('should not apply extra font style when option not provided', () => {
const iniliatizer = createNzRootInitializer(mockDocument);
iniliatizer();
expect(mockDocument.createElement).not.toHaveBeenCalled();
expect(mockDocument.head.appendChild).not.toHaveBeenCalled();
});
});