mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-13 20:57:24 +01:00
fix(dataexport) - 12482 - Extract xml marshalling into library
- Add integration test on dataexport endpoint - Add library with unit test for xml marshalling
This commit is contained in:
44
test/api/unit/libs/xmlMarshaller.test.js
Normal file
44
test/api/unit/libs/xmlMarshaller.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as xmlMarshaller from '../../../../website/server/libs/xmlMarshaller';
|
||||
|
||||
describe('xml marshaller marshalls user data', () => {
|
||||
const minimumUser = {
|
||||
pinnedItems: [],
|
||||
unpinnedItems: [],
|
||||
inbox: {},
|
||||
};
|
||||
|
||||
function userDataWith (fields) {
|
||||
return { ...minimumUser, ...fields };
|
||||
}
|
||||
|
||||
it('maps the newMessages field to have id as a value in a list.', () => {
|
||||
const userData = userDataWith({
|
||||
newMessages: {
|
||||
'283171a5-422c-4991-bc78-95b1b5b51629': {
|
||||
name: 'The Language Hackers',
|
||||
value: true,
|
||||
},
|
||||
'283171a6-422c-4991-bc78-95b1b5b51629': {
|
||||
name: 'The Bug Hackers',
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const xml = xmlMarshaller.marshallUserData(userData);
|
||||
|
||||
expect(xml).to.equal(`<user>
|
||||
<inbox/>
|
||||
<newMessages>
|
||||
<id>283171a5-422c-4991-bc78-95b1b5b51629</id>
|
||||
<name>The Language Hackers</name>
|
||||
<value>true</value>
|
||||
</newMessages>
|
||||
<newMessages>
|
||||
<id>283171a6-422c-4991-bc78-95b1b5b51629</id>
|
||||
<name>The Bug Hackers</name>
|
||||
<value>false</value>
|
||||
</newMessages>
|
||||
</user>`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user