First commit

This commit is contained in:
2026-01-12 13:12:46 +01:00
parent b2d9501f6d
commit a1fbd8acf5
4413 changed files with 1245183 additions and 0 deletions

52
node_modules/find-my-way/test/issue-247.test.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
'use strict'
const t = require('tap')
const test = t.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.same(findMyWay.find('GET', '/a', { host: '1' }).store, { name: 1 })
t.same(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }).store, { name: 2 })
t.same(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 })
findMyWay.off('GET', '/a', { host: '1' })
t.same(findMyWay.find('GET', '/a', { host: '1' }), null)
t.same(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }).store, { name: 2 })
t.same(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 })
findMyWay.off('GET', '/a', { host: '2', version: '1.0.0' })
t.same(findMyWay.find('GET', '/a', { host: '1' }), null)
t.same(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }), null)
t.same(findMyWay.find('GET', '/a', { host: '2', version: '2.0.0' }).store, { name: 3 })
findMyWay.off('GET', '/a', { host: '2', version: '2.0.0' })
t.same(findMyWay.find('GET', '/a', { host: '1' }), null)
t.same(findMyWay.find('GET', '/a', { host: '2', version: '1.0.0' }), null)
t.same(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.same(findMyWay.find('GET', '/a', { host: '1' }).store, { name: 1 })
t.same(findMyWay.find('GET', '/a', { host: '2' }).store, { name: 2 })
findMyWay.off('GET', '/a')
t.same(findMyWay.find('GET', '/a', { host: '1' }), null)
t.same(findMyWay.find('GET', '/a', { host: '2' }), null)
})