Last active
March 7, 2017 23:06
-
-
Save mogocat/e15a19cb857217a6f7d3ef19caa13bc0 to your computer and use it in GitHub Desktop.
[API测试脚本] #tags: should, supertest, restapi, mocha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require("../app") | |
var supertest = require("supertest") | |
var should = require('should') | |
var request = supertest(app) | |
// 定义路由 | |
describe('测试配件模块', function(){ | |
it('/accessory/table 返回配件信息数组', function(done){ | |
request.get('/accessory/table') | |
.query({cate: 1}) | |
.end(function(err, res){ | |
should.not.exist(err) | |
let body = res.body | |
body.should.be.instanceof(Array) | |
if(body.length > 0){ | |
body[0].should.have.keys('id', 'name', 'cate', 'code', 'note', 'serial') | |
} | |
done() | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment