From 436b1fa39c58492d34bfb1ed668feb265a238fce Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Tue, 5 Mar 2024 18:17:43 +0100 Subject: [PATCH] test(secure_channel_store): add tests for matchit Closes https://github.com/adonisjs/transmit/issues/4 --- tests/secure_channel_store.spec.ts | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/secure_channel_store.spec.ts diff --git a/tests/secure_channel_store.spec.ts b/tests/secure_channel_store.spec.ts new file mode 100644 index 0000000..b56d054 --- /dev/null +++ b/tests/secure_channel_store.spec.ts @@ -0,0 +1,31 @@ +/* + * @adonisjs/transmit + * + * (c) AdonisJS + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import { test } from '@japa/runner' +import { SecureChannelStore } from '../src/secure_channel_store.js' + +test.group('SecureChannelStore', () => { + test('add channel to the store', async ({ assert }) => { + const store = new SecureChannelStore() + + try { + store.add('users/:id') + } catch (error) { + assert.isTrue(false) + } + }) + + test('match channel', async ({ assert }) => { + const store = new SecureChannelStore() + store.add('users/:id') + + const match = store.match('users/1') + assert.deepEqual(match, { params: { id: '1' }, url: 'users/:id' }) + }) +})