Skip to content

Commit

Permalink
fix: remove dead code
Browse files Browse the repository at this point in the history
Signed-off-by: hxtree <[email protected]>
  • Loading branch information
hxtree committed Oct 23, 2023
1 parent 5f1e212 commit 588d4ce
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions services/html-to-pdf/src/module/pdf/pdf.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import supertest from 'supertest';
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication, Injectable } from '@nestjs/common';
import { FakerFactory } from '@cats-cradle/faker-factory';
import { OperationInput, OperationOutput } from './operation.dto';
import { PdfService } from './pdf.service';
import { PdfController } from './pdf.controller';
Expand Down Expand Up @@ -30,10 +29,13 @@ describe('/pdf', () => {

describe('GET /pdf', () => {
it('should render url page to pdf', async () => {
jest.spyOn(pdfService, 'urlToPdf').mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));
jest
.spyOn(pdfService, 'urlToPdf')
.mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));

const response = await supertest(app.getHttpServer()).get('/pdf');
// .expect(200);
const response = await supertest(app.getHttpServer())
.get('/pdf')
.expect(200);

expect(response.header['content-type']).toEqual('application/pdf');
expect(response.body).toEqual(Buffer.from('Test', 'utf-8'));
Expand All @@ -42,7 +44,9 @@ describe('/pdf', () => {

describe('POST /pdf', () => {
it('should render url page to pdf', async () => {
jest.spyOn(pdfService, 'urlToPdf').mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));
jest
.spyOn(pdfService, 'urlToPdf')
.mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));

const response = await supertest(app.getHttpServer())
.post('/pdf')
Expand All @@ -58,7 +62,9 @@ describe('/pdf', () => {
});

it('should render url page to json', async () => {
jest.spyOn(pdfService, 'urlToPdf').mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));
jest
.spyOn(pdfService, 'urlToPdf')
.mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));

const response = await supertest(app.getHttpServer())
.post('/pdf')
Expand Down Expand Up @@ -106,7 +112,9 @@ describe('/pdf', () => {
});

it('should render url page to pdf', async () => {
jest.spyOn(pdfService, 'htmlToPdf').mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));
jest
.spyOn(pdfService, 'htmlToPdf')
.mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));

const response = await supertest(app.getHttpServer())
.post('/pdf')
Expand All @@ -123,7 +131,9 @@ describe('/pdf', () => {
});

it('should render url page to json', async () => {
jest.spyOn(pdfService, 'htmlToPdf').mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));
jest
.spyOn(pdfService, 'htmlToPdf')
.mockImplementation((url: string) => Promise.resolve(Buffer.from('Test', 'utf-8')));

const response = await supertest(app.getHttpServer())
.post('/pdf')
Expand All @@ -148,11 +158,9 @@ describe('/pdf', () => {
});

it('should render html page to data', async () => {
jest
.spyOn(pdfService, 'htmlToData')
.mockImplementation((html: string) => Promise.resolve({
title: 'Example Page',
}));
jest.spyOn(pdfService, 'htmlToData').mockImplementation((html: string) => Promise.resolve({
title: 'Example Page',
}));

const response = await supertest(app.getHttpServer())
.post('/pdf')
Expand Down

0 comments on commit 588d4ce

Please sign in to comment.