1- // main
2- /* eslint-env jest */
1+ // main.test
2+
3+ import { describe , it } from 'node:test'
4+ import assert from 'node:assert'
35
46import { HttpsProxyAgent } from 'https-proxy-agent'
57
@@ -93,11 +95,11 @@ describe('test extract(bad url)', () => {
9395 ]
9496
9597 badSamples . forEach ( ( url ) => {
96- test ( `testing extract bad url "${ url } "` , async ( ) => {
98+ it ( `testing extract bad url "${ url } "` , async ( ) => {
9799 try {
98100 await extract ( url )
99101 } catch ( err ) {
100- expect ( err ) . toBeTruthy ( )
102+ assert . ok ( err )
101103 }
102104 } )
103105 } )
@@ -168,7 +170,7 @@ describe('test if extract() with some popular providers', () => {
168170
169171 cases . forEach ( ( { input, expected, checkFn } ) => {
170172 const { url, file, params = { } } = input
171- test ( `check fetchEmbed("${ url } ")` , async ( ) => {
173+ it ( `check fetchEmbed("${ url } ")` , async ( ) => {
172174 const provider = findProvider ( url )
173175 const { baseUrl, path } = parseUrl ( provider . endpoint )
174176
@@ -190,15 +192,15 @@ describe('test if extract() with some popular providers', () => {
190192 } = params
191193
192194 const result = await extract ( url , { maxwidth, maxheight } )
193- expect ( result ) . toBeTruthy ( )
194- expect ( checkFn ( result ) ) . toBe ( true )
195- expect ( result . provider_name ) . toEqual ( expected . provider_name )
196- expect ( result . type ) . toEqual ( expected . type )
195+ assert . ok ( result )
196+ assert . ok ( checkFn ( result ) )
197+ assert . ok ( result . provider_name === expected . provider_name )
198+ assert . ok ( result . type === expected . type )
197199 if ( maxwidth > 0 ) {
198- expect ( result . width ) . toBeLessThanOrEqual ( expected . maxwidth )
200+ assert . ok ( result . width <= expected . maxwidth )
199201 }
200202 if ( maxheight > 0 ) {
201- expect ( result . height ) . toBeLessThanOrEqual ( expected . maxheight )
203+ assert . ok ( result . height <= expected . maxheight )
202204 }
203205 nock . cleanAll ( )
204206 } )
@@ -207,23 +209,23 @@ describe('test if extract() with some popular providers', () => {
207209
208210if ( PROXY_SERVER !== '' ) {
209211 describe ( 'test extract live oembed API via proxy server' , ( ) => {
210- test ( 'check if extract method works with proxy server' , async ( ) => {
212+ it ( 'check if extract method works with proxy server' , async ( ) => {
211213 const url = 'https://codepen.io/ndaidong/pen/LYmLKBw'
212214 const result = await extract ( url , { } , {
213215 agent : new HttpsProxyAgent ( PROXY_SERVER ) ,
214216 } )
215217 console . log ( result )
216- expect ( result . success ) . toBeTruthy ( )
218+ assert . ok ( result . success )
217219 } , 10000 )
218220 } )
219221}
220222
221- test ( 'test .hasProvider() method' , ( ) => {
222- expect ( hasProvider ( 'https://www.youtube.com/watch?v=ciS8aCrX-9s' ) ) . toBe ( true )
223- expect ( hasProvider ( 'https://trello.com/b/BO3bg7yn/notes' ) ) . toBe ( false )
223+ it ( 'test .hasProvider() method' , ( ) => {
224+ assert . ok ( hasProvider ( 'https://www.youtube.com/watch?v=ciS8aCrX-9s' ) )
225+ assert . ok ( ! hasProvider ( 'https://trello.com/b/BO3bg7yn/notes' ) )
224226} )
225227
226- test ( 'test .setProviderList() method' , ( ) => {
228+ it ( 'test .setProviderList() method' , ( ) => {
227229 const customProviderOnly = [
228230 {
229231 provider_name : 'Example' ,
@@ -239,6 +241,6 @@ test('test .setProviderList() method', () => {
239241 } ,
240242 ]
241243 setProviderList ( customProviderOnly )
242- expect ( hasProvider ( 'http://www.example.org/media/abcdef' ) ) . toBe ( true )
243- expect ( hasProvider ( 'https://www.youtube.com/watch?v=ciS8aCrX-9s' ) ) . toBe ( false )
244+ assert . ok ( hasProvider ( 'http://www.example.org/media/abcdef' ) )
245+ assert . ok ( ! hasProvider ( 'https://www.youtube.com/watch?v=ciS8aCrX-9s' ) )
244246} )
0 commit comments