Skip to content

Commit 85323a4

Browse files
authored
Merge pull request #262 from digitalsadhu/update_mocha_and_fix_tests
chore(package): update mocha to latest
2 parents db0501a + d96eea0 commit 85323a4

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"istanbul": "^0.4.5",
5353
"loopback": "^3.16.2",
5454
"loopback-datasource-juggler": "^3.13.0",
55-
"mocha": "^3.0.1",
55+
"mocha": "^4.0.1",
5656
"rsvp": "4.7.0",
5757
"semantic-release": "^8.2.0",
5858
"standard": "^10.0.3",

test/create.test.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var request = require('supertest')
44
var loopback = require('loopback')
55
var expect = require('chai').expect
6-
var query = require('./util/query')
76
var JSONAPIComponent = require('../')
87
var app
98
var Post
@@ -54,7 +53,7 @@ describe('loopback json api component create method', function () {
5453
)
5554
it(
5655
'POST /models should have the JSON API Content-Type header set on response',
57-
function (done) {
56+
function () {
5857
var data = {
5958
data: {
6059
type: 'posts',
@@ -65,32 +64,24 @@ describe('loopback json api component create method', function () {
6564
}
6665
}
6766

68-
var options = {
69-
headers: {
70-
Accept: 'application/vnd.api+json',
71-
'Content-Type': 'application/vnd.api+json'
72-
}
73-
}
74-
75-
// use http module via util to make this post to check headers are working since
76-
// superagent/supertest breaks when trying to use JSON API Content-Type header
77-
// waiting on a fix
78-
// see https://github.com/visionmedia/superagent/issues/753
79-
query(app).post('/posts', data, options, function (err, res) {
80-
expect(err).to.equal(null)
81-
expect(res.headers['content-type']).to.match(
82-
/application\/vnd\.api\+json/
83-
)
84-
expect(res.statusCode).to.equal(201)
85-
expect(res.body).to.have.all.keys('data')
86-
expect(res.body.data).to.have.all.keys(
87-
'type',
88-
'id',
89-
'links',
90-
'attributes'
91-
)
92-
done()
93-
})
67+
return request(app)
68+
.post('/posts')
69+
.send(data)
70+
.set('accept', 'application/vnd.api+json')
71+
.set('content-type', 'application/vnd.api+json')
72+
.then(res => {
73+
expect(res.headers['content-type']).to.match(
74+
/application\/vnd\.api\+json/
75+
)
76+
expect(res.statusCode).to.equal(201)
77+
expect(res.body).to.have.all.keys('data')
78+
expect(res.body.data).to.have.all.keys(
79+
'type',
80+
'id',
81+
'links',
82+
'attributes'
83+
)
84+
})
9485
}
9586
)
9687

0 commit comments

Comments
 (0)