Skip to content

Commit 9457953

Browse files
authored
Build process - semantic-release npm publish (#24)
* docs(.github/): add comments on semantic-release to PR template .md * chore(build-steps): add semantic-release package and circle.yml configs for auto npm publish * test(coverage): add tests to increase coverage
1 parent 675d440 commit 9457953

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

mocha.start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ JSDataAdapterTests.init({
4141
})
4242

4343
require('./test/find.test')
44+
require('./test/update.test')
4445

4546
describe('exports', function () {
4647
it('should have exports', function () {

test/find.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,38 @@ describe('MongoDBAdapter#find', function () {
5858
assert.objectsEqual(user, { _id: id, bsonField: ObjectID.toString() })
5959
})
6060
})
61+
62+
it('should use orderBy array', function () {
63+
var id
64+
65+
return adapter.findAll(User, {
66+
name: 'John'
67+
}).then(function (users) {
68+
assert.equal(users.length, 0)
69+
return adapter.create(User, { _id: '1', name: 'John' })
70+
}).then(function (user) {
71+
id = user._id
72+
assert.equal(typeof id, 'string')
73+
return adapter.findAll(User, {where: {id: id}, orderBy: ['name', 'asc']})
74+
}).then(function (userList) {
75+
assert.objectsEqual(userList, [{ _id: id, name: 'John' }])
76+
})
77+
})
78+
79+
it('should use orderBy string', function () {
80+
var id
81+
82+
return adapter.findAll(User, {
83+
name: 'John'
84+
}).then(function (users) {
85+
assert.equal(users.length, 0)
86+
return adapter.create(User, { _id: '1', name: 'John' })
87+
}).then(function (user) {
88+
id = user._id
89+
assert.equal(typeof id, 'string')
90+
return adapter.findAll(User, {where: {id: id}, orderBy: 'name'})
91+
}).then(function (userList) {
92+
assert.objectsEqual(userList, [{ _id: id, name: 'John' }])
93+
})
94+
})
6195
})

test/update.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
describe('MongoDBAdapter#find', function () {
2+
var adapter
3+
4+
// create a record to test update against
5+
before(function () {
6+
var id
7+
8+
this.$$adapter.findAll(this.$$User, {
9+
name: 'John'
10+
}).then(function (users) {
11+
assert.equal(users.length, 0)
12+
return this.$$adapter.create(this.$$User, {name: 'John'})
13+
}).then(function (user) {
14+
id = user._id
15+
return this.$$adapter.find(this.$$User, id.toString())
16+
}).then(function (user) {
17+
assert.objectsEqual(user, {_id: id, name: 'John'})
18+
})
19+
})
20+
21+
beforeEach(function () {
22+
adapter = this.$$adapter
23+
})
24+
25+
it('should not support updateMany', function () {
26+
return assert.throws(adapter.updateMany)
27+
})
28+
})

0 commit comments

Comments
 (0)