Skip to content

Commit 4e6fd72

Browse files
committed
Implement relationship metadata unit test
1 parent f931b75 commit 4e6fd72

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

test/normalize.spec.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('relationships', () => {
290290
}
291291
}
292292
}
293-
}
293+
};
294294

295295
const result = normalize(json);
296296

@@ -1201,3 +1201,59 @@ describe('lazy loading', () => {
12011201
expect(isEqual(result, output)).to.be.true;
12021202
});
12031203
});
1204+
1205+
describe('relationship meta', () => {
1206+
const json1 = {
1207+
"data": [{
1208+
"type": "post",
1209+
"relationships": {
1210+
"question": {
1211+
"data": {
1212+
"type": "question",
1213+
"id": "295"
1214+
},
1215+
"meta": {
1216+
"membership": {
1217+
"createdAt": "2017-11-22",
1218+
"updatedAt": "2017-11-26"
1219+
}
1220+
}
1221+
}
1222+
},
1223+
"id": 2620,
1224+
"attributes": {
1225+
"text": "hello",
1226+
}
1227+
}]
1228+
};
1229+
1230+
const output1 = {
1231+
post: {
1232+
"2620": {
1233+
id: 2620,
1234+
attributes: {
1235+
"text": "hello",
1236+
},
1237+
relationships: {
1238+
question: {
1239+
data: {
1240+
id: "295",
1241+
type: "question"
1242+
},
1243+
meta: {
1244+
membership: {
1245+
createdAt: "2017-11-22",
1246+
updatedAt: "2017-11-26"
1247+
}
1248+
}
1249+
}
1250+
}
1251+
}
1252+
}
1253+
};
1254+
1255+
it('meta in relationship', () => {
1256+
const result = normalize(json1);
1257+
expect(isEqual(result, output1)).to.be.true;
1258+
});
1259+
});

0 commit comments

Comments
 (0)