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(`
283171a5-422c-4991-bc78-95b1b5b51629
The Language Hackers
true
283171a6-422c-4991-bc78-95b1b5b51629
The Bug Hackers
false
`);
});
});
describe('xml marshaller marshalls user data (with purchases)', () => {
const minimumUser = {
pinnedItems: [],
unpinnedItems: [],
inbox: {},
};
function userDataWith (fields) {
return { ...minimumUser, ...fields };
}
it('maps the purchases field with data that begins with a number', () => {
const userData = userDataWith({
purchased: {
ads: false,
txnCount: 0,
skin: {
eb052b: true,
'0ff591': true,
'2b43f6': true,
d7a9f7: true,
'800ed0': true,
rainbow: true,
},
},
});
const xml = xmlMarshaller.marshallUserData(userData);
expect(xml).to.equal(`
false
0
eb052b
0ff591
2b43f6
d7a9f7
800ed0
rainbow
`);
});
});
describe('xml marshaller marshalls user data (with purchases nested)', () => {
const minimumUser = {
pinnedItems: [],
unpinnedItems: [],
inbox: {},
};
function userDataWith (fields) {
return { ...minimumUser, ...fields };
}
it('maps the purchases field with data that begins with a number and nested objects', () => {
const userData = userDataWith({
purchased: {
ads: false,
txnCount: 0,
skin: {
eb052b: true,
'0ff591': true,
'2b43f6': true,
d7a9f7: true,
'800ed0': true,
rainbow: true,
},
plan: {
consecutive: {
count: 0,
offset: 0,
gemCapExtra: 0,
trinkets: 0,
},
},
},
});
const xml = xmlMarshaller.marshallUserData(userData);
expect(xml).to.equal(`
false
0
eb052b
0ff591
2b43f6
d7a9f7
800ed0
rainbow
-
0
0
0
0
`);
});
});