smartbrowser/test/test.ts
2019-06-03 17:17:20 +02:00

30 lines
1005 B
TypeScript

import { tap, expect } from '@pushrocks/tapbundle';
import * as smartbrowser from '../ts/index';
let testSmartBrowser: smartbrowser.SmartBrowser;
tap.test('should instanstiate a new browser ', async () => {
testSmartBrowser = new smartbrowser.SmartBrowser();
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
});
tap.test('should start the browser ', async () => {
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
});
tap.test('should create a PDF from a page', async tools => {
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
expect(result.buffer).to.be.instanceOf(Buffer);
});
tap.test('should produce a valid screenshot', async tools => {
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
expect(result.buffer).to.be.instanceOf(Buffer);
});
tap.test('should stop the browser ', async () => {
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
});
tap.start();