blob: 2f175dd7e2cb9d9a5c1d373b303e55135c2e5b60 [file]
/*
******************************************************************************
* Copyright © 2018 PTA GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*
******************************************************************************
*/
import { BaseHttpService, HttpMethodEn } from './base-http.service';
import { TestBed, inject } from '@angular/core/testing';
import { MockBaseHttpService } from '../testing/mock-base-http.service';
import { SessionContext } from '../common/session-context';
import { DocumentService } from './document.service';
describe('Service: Document', () => {
let sessionContext: SessionContext;
let mockedBaseHttpService: MockBaseHttpService;
beforeEach(() => {
sessionContext = new SessionContext();
mockedBaseHttpService = new MockBaseHttpService();
TestBed.configureTestingModule({
providers: [
DocumentService,
{ provide: SessionContext, useValue: sessionContext },
{ provide: BaseHttpService, useValue: mockedBaseHttpService },
SessionContext
]
});
});
it('should call uploadGridMeasureAttachments', inject([DocumentService], (service: DocumentService) => {
expect(service).toBeTruthy();
service.uploadGridMeasureAttachments(this.gmId, this.document);
expect(mockedBaseHttpService.lastHttpCallInfo.method).toBe(HttpMethodEn.post);
expect(mockedBaseHttpService.lastHttpCallInfo.uriFragment).toContain('uploadGridMeasureAttachments');
}));
it('should call getGridMeasureAttachments', inject([DocumentService], (service: DocumentService) => {
expect(service).toBeTruthy();
service.getGridMeasureAttachments(this.gmId);
expect(mockedBaseHttpService.lastHttpCallInfo.method).toBe(HttpMethodEn.get);
expect(mockedBaseHttpService.lastHttpCallInfo.uriFragment).toContain('getGridMeasureAttachments');
}));
it('should call downloadGridMeasureAttachment', inject([DocumentService], (service: DocumentService) => {
expect(service).toBeTruthy();
service.downloadGridMeasureAttachment(this.docId);
expect(mockedBaseHttpService.lastHttpCallInfo.method).toBe(HttpMethodEn.get);
expect(mockedBaseHttpService.lastHttpCallInfo.uriFragment).toContain('downloadGridMeasureAttachment');
}));
it('should call  deleteGridMeasureAttachment', inject([DocumentService], (service: DocumentService) => {
expect(service).toBeTruthy();
service.deleteGridMeasureAttachment(this.docId);
expect(mockedBaseHttpService.lastHttpCallInfo.method).toBe(HttpMethodEn.delete);
expect(mockedBaseHttpService.lastHttpCallInfo.uriFragment).toContain('deleteGridMeasureAttachment');
}));
});