2016-10-20 5 views
0

FrisbyJS를 배우기 시작하고 몇 가지 단정을 만들려고합니다.Frisby에있는 객체의 배열 객체 Count

나는이

[ 
    { 
     "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" 
    } 
] 

처럼 보이는 JSON을 얻을 그리고 내가 원하는 : 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(); 

답변

1

포함시킬 수있는 응답을 분석하고 간단한 자바 스크립트 조건 문을 사용하여 주장 할 수있는 인자로 보내드립니다

.afterJSON(json){ //json.articles can be asserted here //some more assertion on the response }

, 루프 등