aps-data-api
Version:
package for data extraction from APS company for omnimetic project
26 lines (20 loc) • 774 B
text/typescript
import fs from 'fs';
import path from 'path';
import { BrowserInterface } from '../../../src/typings';
import { ClickOptions } from 'puppeteer';
export class MockElementHandle implements BrowserInterface.ElementHandle {
serviceAccountId: string;
constructor(serviceAccountId: string) {
this.serviceAccountId = serviceAccountId;
}
async click(options?: ClickOptions) {
const mockPath = path.resolve('test/mocks/fixtures', 'bill.pdf');
const tempPath = path.resolve(
`/tmp/downloads/service_acccounts/${this.serviceAccountId}/bills/Sep_2021`,
);
const mockFile = fs.readFileSync(mockPath);
fs.mkdirSync(tempPath, { recursive: true });
await fs.writeFileSync(`${tempPath}/bill.pdf`, mockFile);
return Promise.resolve();
}
}