smarturl/test/test.ts

26 lines
710 B
TypeScript
Raw Permalink Normal View History

2020-03-27 13:40:03 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2022-07-26 22:40:18 +00:00
import * as smarturl from '../ts/index.js';
2020-03-27 13:40:03 +00:00
2021-04-12 19:18:36 +00:00
let testSmarturl: smarturl.Smarturl;
2020-03-27 13:40:03 +00:00
tap.test('first test', async () => {
2021-04-12 19:18:36 +00:00
testSmarturl = new smarturl.Smarturl();
2022-07-26 22:40:18 +00:00
expect(testSmarturl).toBeInstanceOf(smarturl.Smarturl);
2020-03-27 13:40:03 +00:00
});
2021-04-12 20:09:19 +00:00
tap.test('should parse an URL', async () => {
2021-05-02 16:32:24 +00:00
const testUrl = 'https://lossless.com:3000/?some=cool&more=yes';
// const urlMod = await import('url');
// const altParsed = urlMod.parse(testUrl);
// console.log(altParsed);
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {
searchParams: {
2022-07-26 22:40:18 +00:00
more: 'overwritten',
},
2021-05-02 16:32:24 +00:00
});
2021-04-12 20:09:19 +00:00
console.log(parsedUrl);
2021-05-02 16:32:24 +00:00
console.log(parsedUrl.toString());
2021-04-12 20:09:19 +00:00
});
2020-03-27 13:40:03 +00:00
tap.start();