11'use strict'
22
33const { test } = require ( 'node:test' )
4- const assert = require ( 'node:assert' )
54const { fetch } = require ( '../..' )
65
76test ( 'fetching blob: uris' , async ( t ) => {
@@ -19,19 +18,19 @@ test('fetching blob: uris', async (t) => {
1918 await t . test ( 'a normal fetch request works' , async ( ) => {
2019 const res = await fetch ( objectURL )
2120
22- assert . strictEqual ( blobContents , await res . text ( ) )
23- assert . strictEqual ( blob . type , res . headers . get ( 'Content-Type' ) )
24- assert . strictEqual ( `${ blob . size } ` , res . headers . get ( 'Content-Length' ) )
21+ t . assert . strictEqual ( blobContents , await res . text ( ) )
22+ t . assert . strictEqual ( blob . type , res . headers . get ( 'Content-Type' ) )
23+ t . assert . strictEqual ( `${ blob . size } ` , res . headers . get ( 'Content-Length' ) )
2524 } )
2625
2726 await t . test ( 'non-GET method to blob: fails' , async ( ) => {
2827 try {
2928 await fetch ( objectURL , {
3029 method : 'POST'
3130 } )
32- assert . fail ( 'expected POST to blob: uri to fail' )
31+ t . assert . fail ( 'expected POST to blob: uri to fail' )
3332 } catch ( e ) {
34- assert . ok ( e , 'Got the expected error' )
33+ t . assert . ok ( e , 'Got the expected error' )
3534 }
3635 } )
3736
@@ -41,36 +40,36 @@ test('fetching blob: uris', async (t) => {
4140
4241 try {
4342 await fetch ( objectURL )
44- assert . fail ( 'expected revoked blob: url to fail' )
43+ t . assert . fail ( 'expected revoked blob: url to fail' )
4544 } catch ( e ) {
46- assert . ok ( e , 'Got the expected error' )
45+ t . assert . ok ( e , 'Got the expected error' )
4746 }
4847 } )
4948
5049 // https://github.com/web-platform-tests/wpt/blob/7b0ebaccc62b566a1965396e5be7bb2bc06f841f/FileAPI/url/resources/fetch-tests.js#L28-L34
5150 await t . test ( 'works with a fragment' , async ( ) => {
5251 const res = await fetch ( objectURL + '#fragment' )
5352
54- assert . strictEqual ( blobContents , await res . text ( ) )
53+ t . assert . strictEqual ( blobContents , await res . text ( ) )
5554 } )
5655
5756 // https://github.com/web-platform-tests/wpt/blob/7b0ebaccc62b566a1965396e5be7bb2bc06f841f/FileAPI/url/resources/fetch-tests.js#L52-L56
5857 await t . test ( 'Appending a query string to blob: url should cause fetch to fail' , async ( ) => {
5958 try {
6059 await fetch ( objectURL + '?querystring' )
61- assert . fail ( 'expected ?querystring blob: url to fail' )
60+ t . assert . fail ( 'expected ?querystring blob: url to fail' )
6261 } catch ( e ) {
63- assert . ok ( e , 'Got the expected error' )
62+ t . assert . ok ( e , 'Got the expected error' )
6463 }
6564 } )
6665
6766 // https://github.com/web-platform-tests/wpt/blob/7b0ebaccc62b566a1965396e5be7bb2bc06f841f/FileAPI/url/resources/fetch-tests.js#L58-L62
6867 await t . test ( 'Appending a path should cause fetch to fail' , async ( ) => {
6968 try {
7069 await fetch ( objectURL + '/path' )
71- assert . fail ( 'expected /path blob: url to fail' )
70+ t . assert . fail ( 'expected /path blob: url to fail' )
7271 } catch ( e ) {
73- assert . ok ( e , 'Got the expected error' )
72+ t . assert . ok ( e , 'Got the expected error' )
7473 }
7574 } )
7675
@@ -79,9 +78,9 @@ test('fetching blob: uris', async (t) => {
7978 for ( const method of [ 'HEAD' , 'POST' , 'DELETE' , 'OPTIONS' , 'PUT' , 'CUSTOM' ] ) {
8079 try {
8180 await fetch ( objectURL , { method } )
82- assert . fail ( `${ method } fetch should have failed` )
81+ t . assert . fail ( `${ method } fetch should have failed` )
8382 } catch ( e ) {
84- assert . ok ( e , `${ method } blob url - test succeeded` )
83+ t . assert . ok ( e , `${ method } blob url - test succeeded` )
8584 }
8685 }
8786 } )
0 commit comments