global filter
This commit is contained in:
@@ -4,9 +4,14 @@ import {DocxService} from './docx.service';
|
||||
|
||||
describe('DocxService', () => {
|
||||
let service: DocxService;
|
||||
type DocxServiceInternals = DocxService & {
|
||||
prepareData: (showId: string) => Promise<unknown>;
|
||||
prepareNewDocument: (data: unknown, options?: unknown) => unknown;
|
||||
saveAs: (blob: Blob, name: string) => void;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
void TestBed.configureTestingModule({});
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(DocxService);
|
||||
});
|
||||
|
||||
@@ -15,8 +20,9 @@ describe('DocxService', () => {
|
||||
});
|
||||
|
||||
it('should not try to save a document when the required data cannot be prepared', async () => {
|
||||
const prepareDataSpy = spyOn<any>(service, 'prepareData').and.resolveTo(null);
|
||||
const saveAsSpy = spyOn<any>(service, 'saveAs');
|
||||
const serviceInternals = service as DocxServiceInternals;
|
||||
const prepareDataSpy = spyOn(serviceInternals, 'prepareData').and.resolveTo(null);
|
||||
const saveAsSpy = spyOn(serviceInternals, 'saveAs');
|
||||
|
||||
await service.create('show-1');
|
||||
|
||||
@@ -26,7 +32,8 @@ describe('DocxService', () => {
|
||||
|
||||
it('should build and save a docx file when all data is available', async () => {
|
||||
const blob = new Blob(['docx']);
|
||||
const prepareDataSpy = spyOn<any>(service, 'prepareData').and.resolveTo({
|
||||
const serviceInternals = service as DocxServiceInternals;
|
||||
const prepareDataSpy = spyOn(serviceInternals, 'prepareData').and.resolveTo({
|
||||
show: {
|
||||
showType: 'service-worship',
|
||||
date: {toDate: () => new Date('2026-03-10T00:00:00Z')},
|
||||
@@ -35,8 +42,8 @@ describe('DocxService', () => {
|
||||
user: {name: 'Benjamin'},
|
||||
config: {ccliLicenseId: '12345'},
|
||||
});
|
||||
const prepareNewDocumentSpy = spyOn<any>(service, 'prepareNewDocument').and.returnValue({doc: true});
|
||||
const saveAsSpy = spyOn<any>(service, 'saveAs');
|
||||
const prepareNewDocumentSpy = spyOn(serviceInternals, 'prepareNewDocument').and.returnValue({doc: true});
|
||||
const saveAsSpy = spyOn(serviceInternals, 'saveAs');
|
||||
spyOn(Packer, 'toBlob').and.resolveTo(blob);
|
||||
|
||||
await service.create('show-1', {copyright: true});
|
||||
|
||||
Reference in New Issue
Block a user