1'use strict' 2const test = require('tap').test 3const validateCIDRList = require('../../lib/token.js')._validateCIDRList 4 5test('validateCIDRList', (t) => { 6 t.plan(10) 7 const single = ['127.0.0.0/24'] 8 const double = ['127.0.0.0/24', '192.168.0.0/16'] 9 const ipv6 = '2620:0:2d0:200::7/32' 10 const ipv6Mixed = ['127.0.0/24', '2620:0:2d0:200::7/32', '192.168.0.0/16'] 11 t.doesNotThrow(() => t.isDeeply(validateCIDRList(single.join(',')), single), 'single string ipv4') 12 t.doesNotThrow(() => t.isDeeply(validateCIDRList(single), single), 'single array ipv4') 13 t.doesNotThrow(() => t.isDeeply(validateCIDRList(double.join(',')), double), 'double string ipv4') 14 t.doesNotThrow(() => t.isDeeply(validateCIDRList(double), double), 'double array ipv4') 15 t.throws(() => validateCIDRList(ipv6)) 16 t.throws(() => validateCIDRList(ipv6Mixed)) 17 t.done() 18}) 19