I've an API response which is sorted via the field provided in the payload. The API response body has a lot of parameters out of which the field on which it is sorted is a date-time field. How can I assert that the response is sorted on that date-time field?
Sample payload : URI - https://api.baseurl.com/v1/querysomething.json Payload :
{
"order_by" : "created_at"
}
Sample response :
{
"pagination":{
page_no : 1,
total_records : 100,
page_size: 5,
page_count : 20
}
"items":[
{
"id" : 123
"attr1": "attrvalue"
"attr2::[
{},{},{}
],
.
.
.
.
.
.
"created_at": "2022-11-02T10:48:04.148Z"
},
{
"id" : 1234
"attr1": "attrvalue"
"attr2::[
{},{},{}
],
.
.
.
.
.
.
"created_at": "2022-11-01T11:45:04.148Z"
}
]
}
I've already gone through the solutions mentioned here and here and I don't think the solution applies here. Please correct me if I am wrong in understanding this.