我正在编写一些代码来测试 Zapier 的 CLI 中的操作。我想在这里再添加一个条件,比如response.status == 200 or 201;
检查 API 响应代码是 200 还是 201。
我该怎么做?当我记录响应时,它会为我提供 API 返回的整个 JSON 对象。
describe("contact create", () => {
it("should create a contact", done => {
const bundle = {
inputData: {
firstName: "Test",
lastName: "Contact",
email: "Contact@test.com",
mobileNumber: "+12125551234",
type: "contact"
}
};
appTester(App.creates.contact.operation.perform, bundle)
.then(response => {
// Need one more condition whether response status is 200 or 201.
response.should.not.be.an.Array();
response.should.have.property('id');
done();
})
.catch(done);
});
});