2023-09-11 10:18:45 +02:00
|
|
|
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
2016-09-19 20:00:19 +02:00
|
|
|
|
2022-03-24 14:57:16 +01:00
|
|
|
import * as smartbrowser from '../ts/index.js';
|
2019-06-03 17:16:47 +02:00
|
|
|
let testSmartBrowser: smartbrowser.SmartBrowser;
|
2016-09-19 20:00:19 +02:00
|
|
|
|
2019-06-03 17:17:20 +02:00
|
|
|
tap.test('should instanstiate a new browser ', async () => {
|
|
|
|
testSmartBrowser = new smartbrowser.SmartBrowser();
|
2022-03-24 14:57:16 +01:00
|
|
|
return expect(testSmartBrowser).toBeInstanceOf(smartbrowser.SmartBrowser);
|
2019-06-03 17:17:20 +02:00
|
|
|
});
|
2017-04-09 12:35:53 +02:00
|
|
|
|
2019-06-03 17:16:47 +02:00
|
|
|
tap.test('should start the browser ', async () => {
|
2022-03-24 14:57:16 +01:00
|
|
|
await testSmartBrowser.start();
|
2019-06-03 17:16:47 +02:00
|
|
|
});
|
2017-04-09 12:35:53 +02:00
|
|
|
|
2021-04-29 14:52:28 +00:00
|
|
|
tap.test('should create a PDF from a page', async (tools) => {
|
2019-06-03 17:16:47 +02:00
|
|
|
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
2022-03-24 14:57:16 +01:00
|
|
|
expect(result.buffer).toBeInstanceOf(Buffer);
|
2019-05-28 23:27:55 +02:00
|
|
|
});
|
2019-06-03 17:16:47 +02:00
|
|
|
|
2021-04-29 14:52:28 +00:00
|
|
|
tap.test('should produce a valid screenshot', async (tools) => {
|
2019-06-03 17:16:47 +02:00
|
|
|
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
2022-03-24 14:57:16 +01:00
|
|
|
expect(result.buffer).toBeInstanceOf(Buffer);
|
2019-05-28 23:27:55 +02:00
|
|
|
});
|
2019-06-03 17:16:47 +02: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 17:16:47 +02:00
|
|
|
tap.test('should stop the browser ', async () => {
|
2022-03-24 14:57:16 +01:00
|
|
|
await testSmartBrowser.stop();
|
2019-06-03 17:16:47 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.start();
|