smartbrowser/test/test.ts
2020-06-01 20:20:57 +00:00

37 lines
1.2 KiB
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 evalute something in the browser', async () => {
const result = await testSmartBrowser.evaluateOnPage('https://lossless.com', async () => {
return window.location.toString();
});
console.log(result);
});
tap.test('should stop the browser ', async () => {
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
});
tap.start();