add test to check that user name is properly escaped

This commit is contained in:
Martin Raifer
2023-11-08 11:42:29 +01:00
parent 0ab2eb901b
commit fdcf6369f2

23
test/spec/ui/account.js Normal file
View File

@@ -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<br>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<br>y');
});
});