Buckets:
| const { test } = require('node:test') | |
| const FindMyWay = require('..') | |
| test('If there are constraints param, router.off method support filter', t => { | |
| t.plan(12) | |
| const findMyWay = FindMyWay() | |
| findMyWay.on('GET', '/a', { constraints: { host: '1' } }, () => {}, { name: 1 }) | |
| findMyWay.on('GET', '/a', { constraints: { host: '2', version: '1.0.0' } }, () => {}, { name: 2 }) | |
| findMyWay.on('GET', '/a', { constraints: { host: '2', version: '2.0.0' } }, () => {}, { name: 3 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }).store, { name: 1 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }).store, { name: 2 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 }) | |
| findMyWay.off('GET', '/a', { host: '1' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }).store, { name: 2 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 }) | |
| findMyWay.off('GET', '/a', { host: '2', version: '1.0.0' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 }) | |
| findMyWay.off('GET', '/a', { host: '2', version: '2.0.0' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }), null) | |
| }) | |
| test('If there are no constraints param, router.off method remove all matched router', t => { | |
| t.plan(4) | |
| const findMyWay = FindMyWay() | |
| findMyWay.on('GET', '/a', { constraints: { host: '1' } }, () => {}, { name: 1 }) | |
| findMyWay.on('GET', '/a', { constraints: { host: '2' } }, () => {}, { name: 2 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }).store, { name: 1 }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2' }).store, { name: 2 }) | |
| findMyWay.off('GET', '/a') | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '1' }), null) | |
| t.assert.deepEqual(findMyWay.find('GET', '/a', { host: '2' }), null) | |
| }) | |
Xet Storage Details
- Size:
- 2.4 kB
- Xet hash:
- 42a4730dd48eaa92bf6fdec530f9fca70e4be7db6eb79546fbc6eea8bc12895b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.