From ba45b47240cf2110edc142c3a678d05443ce2686 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 21 Jan 2021 22:42:12 +0000 Subject: [PATCH] Oops, the tests won't work if we don't export the functions --- src/VoipUserMapper.ts | 6 ++++-- test/VoipUserMapper-test.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/VoipUserMapper.ts b/src/VoipUserMapper.ts index c5de686ab8..a4f5822065 100644 --- a/src/VoipUserMapper.ts +++ b/src/VoipUserMapper.ts @@ -26,13 +26,15 @@ export function voipUserMapperEnabled(): boolean { return SdkConfig.get()['voip_mxid_translate_pattern'] !== undefined; } -function userToVirtualUser(userId: string, templateString?: string): string { +// only exported for tests +export function userToVirtualUser(userId: string, templateString?: string): string { if (templateString === undefined) templateString = SdkConfig.get()['voip_mxid_translate_pattern']; if (!templateString) return null; return templateString.replace('${mxid}', encodeURIComponent(userId).replace(/%/g, '=').toLowerCase()); } -function virtualUserToUser(userId: string, templateString?: string): string { +// only exported for tests +export function virtualUserToUser(userId: string, templateString?: string): string { if (templateString === undefined) templateString = SdkConfig.get()['voip_mxid_translate_pattern']; if (!templateString) return null; diff --git a/test/VoipUserMapper-test.ts b/test/VoipUserMapper-test.ts index a736efd6be..ee45379e4c 100644 --- a/test/VoipUserMapper-test.ts +++ b/test/VoipUserMapper-test.ts @@ -18,7 +18,7 @@ import { userToVirtualUser, virtualUserToUser } from '../src/VoipUserMapper'; const templateString = '@_greatappservice_${mxid}:frooble.example'; const realUser = '@alice:boop.example'; -const virtualUser = "@_greatappservice_%40alice%3Aboop.example:frooble.example"; +const virtualUser = "@_greatappservice_=40alice=3aboop.example:frooble.example"; describe('VoipUserMapper', function() { it('translates users to virtual users', function() {