Skip to content

Commit

Permalink
Merge pull request #287 from derbyjs/replace-expectjs-with-chai
Browse files Browse the repository at this point in the history
Remove expectjs and replace with chai
  • Loading branch information
pypmannetjies authored Jan 28, 2021
2 parents 5a45bbd + 1bcef0e commit 0690856
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"uuid": "^2.0.1"
},
"devDependencies": {
"chai": "^4.2.0",
"coveralls": "^3.0.5",
"eslint": "^5.16.0",
"eslint-config-google": "^0.13.0",
"expect.js": "^0.3.1",
"mocha": "^6.1.4",
"nyc": "^14.1.1"
},
Expand Down
16 changes: 8 additions & 8 deletions test/Model/CollectionCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('CollectionCounter', function() {
describe('increment', function() {
it('increments count for a document', function() {
var counter = new CollectionCounter();
expect(counter.get('colors', 'green')).to.be(0);
expect(counter.get('colors', 'green')).to.equal(0);
expect(counter.increment('colors', 'green')).to.equal(1);
expect(counter.increment('colors', 'green')).to.equal(2);
expect(counter.get('colors', 'green')).to.equal(2);
Expand All @@ -27,29 +27,29 @@ describe('CollectionCounter', function() {
expect(counter.increment('colors', 'green'));
expect(counter.decrement('colors', 'green')).to.equal(1);
expect(counter.decrement('colors', 'green')).to.equal(0);
expect(counter.get('colors', 'green')).to.be(0);
expect(counter.get('colors', 'green')).to.equal(0);
});
it('does not affect peer document', function() {
var counter = new CollectionCounter();
expect(counter.increment('colors', 'green'));
expect(counter.increment('colors', 'red'));
expect(counter.decrement('colors', 'green'));
expect(counter.get('colors', 'green')).to.be(0);
expect(counter.get('colors', 'red')).to.be(1);
expect(counter.get('colors', 'green')).to.equal(0);
expect(counter.get('colors', 'red')).to.equal(1);
});
it('does not affect peer collection', function() {
var counter = new CollectionCounter();
expect(counter.increment('colors', 'green'));
expect(counter.increment('textures', 'smooth'));
expect(counter.decrement('colors', 'green'));
expect(counter.get('colors', 'green')).to.be(0);
expect(counter.get('textures', 'smooth')).to.be(1);
expect(counter.get('colors', 'green')).to.equal(0);
expect(counter.get('textures', 'smooth')).to.equal(1);
});
});
describe('toJSON', function() {
it('returns undefined if there are no counts', function() {
var counter = new CollectionCounter();
expect(counter.toJSON()).to.be(undefined);
expect(counter.toJSON()).to.equal(undefined);
});
it('returns a nested map representing counts', function() {
var counter = new CollectionCounter();
Expand All @@ -71,7 +71,7 @@ describe('CollectionCounter', function() {
var counter = new CollectionCounter();
counter.increment('colors', 'green');
counter.decrement('colors', 'green');
expect(counter.toJSON()).to.be(undefined);
expect(counter.toJSON()).to.equal(undefined);
});
it('decrementing id from collection with other keys removes key', function() {
var counter = new CollectionCounter();
Expand Down
2 changes: 1 addition & 1 deletion test/Model/EventListenerTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('EventListenerTree', function() {
var tree = new EventListenerTree();
var listener = {};
var node = tree.addListener(['colors', 'green'], listener);
expect(node).a(EventListenerTree);
expect(node).instanceOf(EventListenerTree);
expect(node.parent.parent).equal(tree);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/Model/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('connection', function() {
var backend = racer.createBackend();
var model = backend.createModel();
var agent = model.getAgent();
expect(agent).ok();
expect(agent).to.be.ok;
});

it('returns null once the model is disconnected', function(done) {
Expand Down
2 changes: 1 addition & 1 deletion test/Model/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ module.exports = function(createDoc) {
var doc = createDoc();
doc.set(['friends'], {}, function() {});
doc.push(['friends'], ['x'], function(err) {
expect(err).a(TypeError);
expect(err).instanceOf(TypeError);
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/Model/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Model events without useEventObjects', function() {

model.at('a').on('change', function(value, prev) {
expect(value).to.equal(1);
expect(prev).to.be.empty;
expect(prev).not.to.exist;
done();
});
model.set('a', 1);
Expand Down
2 changes: 1 addition & 1 deletion test/Model/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('filter', function() {
});
expect(function() {
filter.get();
}).to.throwException();
}).to.throw(Error);
});
it('supports filter of object', function() {
var model = (new Model()).at('_page');
Expand Down
2 changes: 1 addition & 1 deletion test/Model/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('query', function() {
{id: 'a'}
], 3);
// 'a' is still present once in the results, should still be in the map.
expect(query.idMap).to.only.have.keys(['a', 'b', 'c']);
expect(query.idMap).to.have.all.keys(['a', 'b', 'c']);
});
});

Expand Down
16 changes: 1 addition & 15 deletions test/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var util = require('util');
var expect = require('expect.js');
var expect = require('chai').expect;

exports.expect = expect;

Expand All @@ -19,17 +19,3 @@ exports.inspect = function(value, depth, showHidden) {
if (showHidden == null) showHidden = true;
console.log(util.inspect(value, {depth: depth, showHidden: showHidden}));
};

expect.Assertion.prototype.NaN = function() {
this.assert(this.obj !== this.obj,
'expected ' + util.inspect(this.obj) + ' to be NaN',
'expected ' + util.inspect(this.obj) + ' to not be NaN'
);
};

expect.Assertion.prototype.null = function() {
this.assert(this.obj == null,
'expected ' + util.inspect(this.obj) + ' to be null or undefined',
'expected ' + util.inspect(this.obj) + ' to not be null or undefined'
);
};

0 comments on commit 0690856

Please sign in to comment.