smartbrowser/test/test.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-09-11 08:18:45 +00:00
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
2016-09-19 18:00:19 +00:00
2022-03-24 13:57:16 +00:00
import * as smartbrowser from '../ts/index.js';
2019-06-03 15:16:47 +00:00
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();
2022-03-24 13:57:16 +00:00
return expect(testSmartBrowser).toBeInstanceOf(smartbrowser.SmartBrowser);
2019-06-03 15:17:20 +00:00
});
2017-04-09 10:35:53 +00:00
2019-06-03 15:16:47 +00:00
tap.test('should start the browser ', async () => {
2022-03-24 13:57:16 +00:00
await testSmartBrowser.start();
2019-06-03 15:16:47 +00:00
});
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');
2022-03-24 13:57:16 +00:00
expect(result.buffer).toBeInstanceOf(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');
2022-03-24 13:57:16 +00:00
expect(result.buffer).toBeInstanceOf(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 () => {
2022-03-24 13:57:16 +00:00
await testSmartBrowser.stop();
2019-06-03 15:16:47 +00:00
});
tap.start();