Skip to content

Commit

Permalink
Misunderstood how 'should' works
Browse files Browse the repository at this point in the history
  • Loading branch information
zevisert committed Jan 12, 2019
1 parent 7ed6b36 commit eb3788a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/index.js
Expand Up @@ -167,7 +167,7 @@ describe('koa-body', () => {
res.body.user.names.should.be.an.Array().and.have.lengthOf(2);
res.body.user.names[0].should.equal('John');
res.body.user.names[1].should.equal('Paul');
res.body._files.firstField.should.be.an.Object;
res.body._files.firstField.should.be.an.Object();
res.body._files.firstField.name.should.equal('package.json');
should(fs.statSync(res.body._files.firstField.path)).be.ok;
fs.unlinkSync(res.body._files.firstField.path);
Expand Down Expand Up @@ -230,9 +230,9 @@ describe('koa-body', () => {
.end( (err, res) => {
if (err) return done(err);

res.body._files.firstField.should.be.an.Object;
res.body._files.firstField.should.be.an.Object();
res.body._files.firstField.name.should.equal('backage.json');
should(fs.statSync(res.body._files.firstField.path)).be.ok;
should(fs.statSync(res.body._files.firstField.path)).be.ok();
fs.unlinkSync(res.body._files.firstField.path);

done();
Expand Down Expand Up @@ -299,11 +299,11 @@ describe('koa-body', () => {
assert(requestSpy.calledOnce, 'Spy for /echo_body not called');
const req = requestSpy.firstCall.args[0].request;

req.body.should.be.null;
req.body.should.not.be.Undefined();
res.body.should.have.properties({});

req.body[unparsed].should.not.be.undefined;
req.body[unparsed].should.be.a.String;
req.body[unparsed].should.not.be.Undefined();
req.body[unparsed].should.be.a.String();
req.body[unparsed].should.have.length(0);

done();
Expand All @@ -330,8 +330,8 @@ describe('koa-body', () => {

assert(requestSpy.calledOnce, 'Spy for /users not called');
const req = requestSpy.firstCall.args[0].request;
req.body[unparsed].should.not.be.undefined;
req.body[unparsed].should.be.a.String;
req.body[unparsed].should.not.be.Undefined();
req.body[unparsed].should.be.a.String();
req.body[unparsed].should.equal('name=Test&followers=97');

res.body.user.should.have.properties({ name: 'Test', followers: '97' });
Expand All @@ -358,8 +358,8 @@ describe('koa-body', () => {

assert(requestSpy.calledOnce, 'Spy for /echo_body not called');
const req = requestSpy.firstCall.args[0].request;
req.body[unparsed].should.not.be.undefined;
req.body[unparsed].should.be.a.String;
req.body[unparsed].should.not.be.Undefined();
req.body[unparsed].should.be.a.String();
req.body[unparsed].should.equal(JSON.stringify({
hello: 'world',
number: 42
Expand All @@ -386,14 +386,14 @@ describe('koa-body', () => {

assert(requestSpy.calledOnce, 'Spy for /echo_body not called');
const req = requestSpy.firstCall.args[0].request;
req.body.should.equal('plain text content');
should(req.body).equal('plain text content');

// Raw text requests are still just text
assert.equal(req.body[unparsed], undefined);

// Text response is just text
res.body.should.have.properties({});
res.text.should.equal('plain text content');
should(res.body).have.properties({});
should(res.text).equal('plain text content');

done();
});
Expand Down

0 comments on commit eb3788a

Please sign in to comment.