FrisbyJS の学習を開始し、いくつかのアサーションを作成しようとしています。
このようなjsonを取得します
[
{
"articles": [
{
"article": "123-123002",
"updated": "2016-10-20T14:57:25",
"sourced balance": [],
"balance": "50.00"
},
{
"article": "100-123001",
"updated": "2016-10-20T14:41:36",
"sourced balance": [],
"balance": "10.00"
}
],
"DistrictID": [],
"WarehouseID": "SebastiansWarehouse",
"SourceID": "1234",
"City": "Stockholm",
"WarehouseName": "Sebastians Warehouse",
"WarehouseType": "STORE"
}
]
1. 記事オブジェクトの数をカウントする 2. 記事配列の数値 X に値が「123-123002」の変数があることを確認する
Frisbyでこれを行うにはどうすればよいですか?
私のコードは現在:
var frisby = require('frisby');
frisby.create('Mekonomen RIF1')
.get('https://10.254.8.67:9443/INTERSHOP/rest/WFS/Mekonomen-MekB2BSE-Site/-/availability/sources/1234/warehouses/SebastiansWarehouse/products/',{ strictSSL: false})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSON('?',{
articles: [],
DistrictID: [],
WarehouseID: "SebastiansWarehouse",
SourceID: '1234',
City: "Stockholm",
WarehouseName: "Sebastians Warehouse",
WarehouseType: "STORE"
}
)
.expectJSON('?.articles',{
articles: [],
DistrictID: [],
WarehouseID: "SebastiansWarehouse",
SourceID: '1234',
City: "Stockholm",
WarehouseName: "Sebastians Warehouse",
WarehouseType: "STORE"
}
)
.expectMaxResponseTime(500)
.toss();