2
2
3
3
'use strict'
4
4
5
- const { Buffer } = require ( 'buffer' )
6
- const expect = require ( 'chai' ) . expect
5
+ const { expect } = require ( 'aegir/utils/chai' )
7
6
const multiaddr = require ( 'multiaddr' )
7
+ const uint8ArrayFromString = require ( 'uint8arrays/from-string' )
8
8
9
9
const mafmt = require ( './../src' )
10
10
@@ -182,7 +182,7 @@ describe('multiaddr validation', function () {
182
182
expect ( p . matches ( testcase ) , `assertMatches: ${ testcase } (string)` ) . to . be . eql ( true )
183
183
const ma = multiaddr ( testcase )
184
184
expect ( p . matches ( ma ) , `assertMatches: ${ testcase } (multiaddr object)` ) . to . be . eql ( true )
185
- expect ( p . matches ( ma . buffer ) , `assertMatches: ${ testcase } (multiaddr.buffer )` ) . to . be . eql ( true )
185
+ expect ( p . matches ( ma . bytes ) , `assertMatches: ${ testcase } (multiaddr.bytes )` ) . to . be . eql ( true )
186
186
} catch ( err ) {
187
187
err . stack = '[testcase=' + JSON . stringify ( testcase ) + ', shouldMatch=true] ' + err . stack
188
188
throw err
@@ -200,15 +200,15 @@ describe('multiaddr validation', function () {
200
200
let validMultiaddrObj
201
201
try {
202
202
// if testcase string happens to be a valid multiaddr,
203
- // we expect 'p' test to also return false for Multiaddr object and Buffer versions
203
+ // we expect 'p' test to also return false for Multiaddr object and Uint8Array versions
204
204
validMultiaddrObj = multiaddr ( testcase )
205
205
} catch ( e ) {
206
206
// Ignoring testcase as the string is not a multiaddr
207
- // (There is a separate 'Buffer is invalid' test later below)
207
+ // (There is a separate 'Uint8Array is invalid' test later below)
208
208
}
209
209
if ( validMultiaddrObj ) {
210
210
expect ( p . matches ( validMultiaddrObj ) , `assertMismatches: ${ testcase } (multiaddr object)` ) . to . be . eql ( false )
211
- expect ( p . matches ( validMultiaddrObj . buffer ) , `assertMismatches: ${ testcase } (multiaddr.buffer )` ) . to . be . eql ( false )
211
+ expect ( p . matches ( validMultiaddrObj . bytes ) , `assertMismatches: ${ testcase } (multiaddr.bytes )` ) . to . be . eql ( false )
212
212
}
213
213
} catch ( err ) {
214
214
err . stack = '[testcase=' + JSON . stringify ( testcase ) + ', shouldMatch=false] ' + err . stack
@@ -222,8 +222,8 @@ describe('multiaddr validation', function () {
222
222
expect ( mafmt . HTTP . matches ( '/http-google-com' ) ) . to . be . eql ( false )
223
223
} )
224
224
225
- it ( 'do not throw if multiaddr Buffer is invalid' , function ( ) {
226
- expect ( mafmt . HTTP . matches ( Buffer . from ( 'no spoon' ) ) ) . to . be . eql ( false )
225
+ it ( 'do not throw if multiaddr Uint8Array is invalid' , function ( ) {
226
+ expect ( mafmt . HTTP . matches ( uint8ArrayFromString ( 'no spoon' ) ) ) . to . be . eql ( false )
227
227
} )
228
228
229
229
it ( 'DNS validation' , function ( ) {
0 commit comments