Hi guys,
Could you please help me to validate that the endDate of promotions is not expired on the nested array.
This is a response where I need to check the endDate endPoint
{
"data": {
"findManyCommunities": {
"totalCount": 3,
"edges": [
{
"node": {
"name": "Atria West 86",
"promotions": [
{
"startDate": "2022-09-01T19:00:00.000Z",
"endDate": "2023-01-06T20:00:00.000Z"
}
]
}
},
{
"node": {
"name": "The Arbors at Hauppauge",
"promotions": [
{
"startDate": "2022-09-01T19:00:00.000Z",
"endDate": "2022-10-01T19:00:00.000Z"
},
{
"startDate": "2022-09-01T19:00:00.000Z",
"endDate": "2023-01-14T20:00:00.000Z"
}
]
}
},
{
"node": {
"name": "Atria Forest Hills",
"promotions": [
{
"startDate": "2022-09-02T19:00:00.000Z",
"endDate": "2022-12-09T20:00:00.000Z"
},
{
"startDate": "2022-09-01T19:00:00.000Z",
"endDate": "2022-12-01T20:00:00.000Z"
},
{
"startDate": "2022-09-02T19:00:00.000Z",
"endDate": "2023-01-07T20:00:00.000Z"
}
]
}
}
]
}
}
}
I attached a console log screenshot and this is my test that is not working…
const response=pm.response.json();
let moment = require ('moment');
console.log(response);
pm.test("Check that endDate is not expired", function () {
pm.expect(moment(response.data.findManyCommunities.edges[0].node.promotions[0].endDate, 'DD-MM-YYYY hh:mm:ss', true).isValid()).is.true;
});
Could you please help