smartbrowser/test/test.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-06-03 15:16:47 +00:00
import { tap, expect } from '@pushrocks/tapbundle';
2016-09-19 18:00:19 +00:00
2019-06-03 15:16:47 +00:00
import * as smartbrowser from '../ts/index';
let testSmartBrowser: smartbrowser.SmartBrowser;
2016-09-19 18:00:19 +00:00
2019-06-03 15:17:20 +00:00
tap.test('should instanstiate a new browser ', async () => {
testSmartBrowser = new smartbrowser.SmartBrowser();
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
});
2017-04-09 10:35:53 +00:00
2019-06-03 15:16:47 +00:00
tap.test('should start the browser ', async () => {
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
});
2017-04-09 10:35:53 +00:00
2021-04-29 14:52:28 +00:00
tap.test('should create a PDF from a page', async (tools) => {
2019-06-03 15:16:47 +00:00
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
expect(result.buffer).to.be.instanceOf(Buffer);
2019-05-28 21:27:55 +00:00
});
2019-06-03 15:16:47 +00:00
2021-04-29 14:52:28 +00:00
tap.test('should produce a valid screenshot', async (tools) => {
2019-06-03 15:16:47 +00:00
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
expect(result.buffer).to.be.instanceOf(Buffer);
2019-05-28 21:27:55 +00:00
});
2019-06-03 15:16:47 +00:00
2020-06-01 20:19:25 +00:00
tap.test('should evalute something in the browser', async () => {
const result = await testSmartBrowser.evaluateOnPage('https://lossless.com', async () => {
2020-06-01 20:20:57 +00:00
return window.location.toString();
2020-06-01 20:19:25 +00:00
});
console.log(result);
});
2019-06-03 15:16:47 +00:00
tap.test('should stop the browser ', async () => {
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
});
tap.start();