Skip to content

Commit 0db8b34

Browse files
alireza-ahmadiAlireza Ahmadi
authored and
Alireza Ahmadi
committed
Improve tests for better code style consistency
- Change test descriptions to match the new style - Change error handling mechanism for better stack traces
1 parent 3856c0d commit 0db8b34

File tree

1 file changed

+45
-55
lines changed

1 file changed

+45
-55
lines changed

test/postgresql.test.js

Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -247,98 +247,88 @@ describe('postgresql connector', function() {
247247
Post.destroyAll(done);
248248
});
249249

250-
it('should support case sensitive queries using like',
251-
function(done) {
252-
Post.find({where: {content: {like: '%TestCase%'}}},
253-
function(err, posts) {
254-
should.not.exists(err);
255-
posts.length.should.equal(1);
256-
posts[0].content.should.equal('T1_TestCase');
257-
done();
258-
});
250+
it('supports case sensitive queries using like', function(done) {
251+
Post.find({where: {content: {like: '%TestCase%'}}}, function(err, posts) {
252+
if (err) return done(err);
253+
posts.length.should.equal(1);
254+
posts[0].content.should.equal('T1_TestCase');
255+
done();
259256
});
257+
});
260258

261-
it('should not support case insensitive queries using like',
262-
function(done) {
263-
Post.find({where: {content: {like: '%tesTcasE%'}}},
264-
function(err, posts) {
265-
should.not.exists(err);
266-
posts.length.should.equal(0);
267-
done();
268-
});
259+
it('rejects case insensitive queries using like', function(done) {
260+
Post.find({where: {content: {like: '%tesTcasE%'}}}, function(err, posts) {
261+
if (err) return done(err);
262+
posts.length.should.equal(0);
263+
done();
269264
});
265+
});
270266

271-
it('should support like for no match', function(done) {
272-
Post.find({where: {content: {like: '%TestXase%'}}},
273-
function(err, posts) {
274-
should.not.exists(err);
275-
posts.length.should.equal(0);
276-
done();
277-
});
267+
it('supports like for no match', function(done) {
268+
Post.find({where: {content: {like: '%TestXase%'}}}, function(err, posts) {
269+
if (err) return done(err);
270+
posts.length.should.equal(0);
271+
done();
272+
});
278273
});
279274

280-
it('should support negative case sensitive queries using nlike',
281-
function(done) {
282-
Post.find({where: {content: {nlike: '%Case%'}}},
283-
function(err, posts) {
284-
should.not.exists(err);
285-
posts.length.should.equal(0);
286-
done();
287-
});
275+
it('supports negative case sensitive queries using nlike', function(done) {
276+
Post.find({where: {content: {nlike: '%Case%'}}}, function(err, posts) {
277+
if (err) return done(err);
278+
posts.length.should.equal(0);
279+
done();
288280
});
281+
});
289282

290-
it('should not support negative case insensitive queries using nlike',
291-
function(done) {
292-
Post.find({where: {content: {nlike: '%casE%'}}},
293-
function(err, posts) {
294-
should.not.exists(err);
295-
posts.length.should.equal(2);
296-
done();
297-
});
283+
it('rejects negative case insensitive queries using nlike', function(done) {
284+
Post.find({where: {content: {nlike: '%casE%'}}}, function(err, posts) {
285+
if (err) return done(err);
286+
posts.length.should.equal(2);
287+
done();
298288
});
289+
});
299290

300-
it('should support nlike for no match', function(done) {
291+
it('supports nlike for no match', function(done) {
301292
Post.find({where: {content: {nlike: '%TestXase%'}}},
302293
function(err, posts) {
303-
should.not.exists(err);
294+
if (err) return done(err);
304295
posts.length.should.equal(2);
305296
done();
306297
});
307298
});
308299

309-
it('should support case insensitive queries using ilike', function(done) {
300+
it('supports case insensitive queries using ilike', function(done) {
310301
Post.find({where: {content: {ilike: '%tesTcasE%'}}},
311302
function(err, posts) {
312-
should.not.exist(err);
303+
if (err) return done(err);
313304
posts.length.should.equal(1);
314305
posts[0].content.should.equal('T1_TestCase');
315306
done();
316307
});
317308
});
318309

319-
it('should support ilike for no match', function(done) {
310+
it('supports ilike for no match', function(done) {
320311
Post.find({where: {content: {ilike: '%tesTxasE%'}}},
321312
function(err, posts) {
322-
should.not.exists(err);
313+
if (err) return done(err);
323314
posts.length.should.equal(0);
324315
done();
325316
});
326317
});
327318

328-
it('should support negative case insensitive queries using nilike',
319+
it('supports negative case insensitive queries using nilike',
329320
function(done) {
330-
Post.find({where: {content: {nilike: '%casE%'}}},
331-
function(err, posts) {
332-
should.not.exist(err);
333-
posts.length.should.equal(0);
334-
done();
335-
});
321+
Post.find({where: {content: {nilike: '%casE%'}}}, function(err, posts) {
322+
if (err) return done(err);
323+
posts.length.should.equal(0);
324+
done();
325+
});
336326
});
337327

338-
it('should support nilike for no match', function(done) {
328+
it('supports nilike for no match', function(done) {
339329
Post.find({where: {content: {nilike: '%tesTxasE%'}}},
340330
function(err, posts) {
341-
should.not.exists(err);
331+
if (err) return done(err);
342332
posts.length.should.equal(2);
343333
done();
344334
});

0 commit comments

Comments
 (0)