From fdcf6369f2e495e9adcab04d7000ce3d4c52ea26 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Wed, 8 Nov 2023 11:42:29 +0100 Subject: [PATCH] add test to check that user name is properly escaped --- test/spec/ui/account.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/spec/ui/account.js diff --git a/test/spec/ui/account.js b/test/spec/ui/account.js new file mode 100644 index 000000000..0f2f807d2 --- /dev/null +++ b/test/spec/ui/account.js @@ -0,0 +1,23 @@ +describe('iD.uiAccount', function () { + it('properly escapes user name', function() { + var selection = d3.select('body').append('div'); + var osmConnectionMock = { + authenticated: () => true, + userDetails: (callback) => { + callback(null, { + display_name: 'x
y' + }); + }, + userURL: () => '', + on: (handler, callback) => { + if (handler === 'change.account') { + onChangeAccountHandler = callback; + } + } + }; + var onChangeAccountHandler; + iD.uiAccount({ connection: () => osmConnectionMock })(selection); + onChangeAccountHandler.call(); + expect(selection.select('.userInfo span.label').text()).to.equal('x
y'); + }); +});