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
|
|
|
|
2019-06-03 15:17:20 +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
|
|
|
|
2019-06-03 15:17:20 +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
|
|
|
|
|
|
|
tap.test('should stop the browser ', async () => {
|
|
|
|
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.start();
|