How to use should.Assertion:
8 9 10 11 12 13 14 15 16 17
/** * Auxiliary constants. */ const Assertion = should.Assertion.prototype; const assertions = Object.keys(Assertion); const chains = Object.keys(Assertion).filter(key => typeof Assertion[key] !== 'function'); /**
How to use should.fail:
75 76 77 78 79 80 81 82 83 84
await cardAssets.clearFiles(); try { await fs.readFile(path.join(destDir, 'cards.min.css'), 'utf-8'); should.fail(cardAssets, 'CSS file should not exist'); } catch (error) { if (error instanceof should.AssertionError) { throw error; }
How to use should.notDeepEqual:
67 68 69 70 71 72 73 74 75 76
}; const results = await Promise.all([cached(), notCached()]); should.equal(configObject.result.key5,'newvalue'); should.notDeepEqual(results[0], configObject); should.deepEqual(results[1], configObject); }); it('should get error for not found url', function (done) {
How to use should.ok:
97 98 99 100 101 102 103 104 105 106
describe.skip('custom resource function: getBlob()', function () { it('should return a file content', function (done) { gitlab.repositorys.getBlob({ id: 55045, sha: 'master', filepath: 'README.md' }, function (err, blob) { should.not.exists(err); should.exists(blob); should.ok(Buffer.isBuffer(blob)); blob.should.be.instanceof(Buffer); blob.length.should.above(0); blob.toString().should.containEql('gitlab-client-unittest'); done();
How to use should.notEqual:
11 12 13 14 15 16 17 18 19 20
var options = { source: path.join(__dirname, '/openapi_files/openapi2.yaml'), destination: path.join(__dirname, '../../api_bundles') } generateApi.generateApi('petStore', options, function (err, reply) { should.notEqual(err, null) reply.error.should.eql('openapi parsing failed..') done() }) })
45
30
0
See more examples
How to use should.throws:
GitHub: acnesiac/superagent
111 112 113 114 115 116 117 118 119 120
done(); }); }); it('throw when empty', () => { should.throws(() => { request .post(`${base}/echo`) .field() }, /name/);
How to use should.strictEqual:
GitHub: agiladis/inastekdb
16 17 18 19 20 21 22 23 24 25
}); it('should return undefined', function() { const result = hljs.getLanguage('-impossible-'); should.strictEqual(result, undefined); }); it('should not break on undefined', function() { const result = hljs.getLanguage(undefined);
How to use should.exists:
16 17 18 19 20 21 22 23 24 25
describe('RESTfulClient', function () { describe('request()', function () { it('should return status 200 results', function (done) { gitlab.projects.list(function (err, result) { should.not.exists(err); should.exists(result); result.length.should.above(1); result[0].should.have.property('id'); lastId = result[result.length - 1].id; done();
How to use should.equal:
GitHub: qiniu/nodejs-sdk
22 23 24 25 26 27 28 29 30
describe('test prepareZone', function () { it('test prepareZone', function (done) { config.zone = qiniu.zone.Zone_z0; qiniu.util.prepareZone(bucketManager, bucketManager.mac.accessKey, bucket, function (err, ctx) { should.not.exist(err); should.equal(bucketManager, ctx); done(); }); });
189
577
38
See more examples
How to use should.deepEqual:
46 47 48 49 50 51 52 53 54 55
this.timeout(10000); let remoteConfig = new RemoteConfig(configUrl, configRefreshTime); let result = await remoteConfig.getConfigObject(context); should.deepEqual(result, configObject); configObject.result.key5 = 'newvalue'; let cached = () => { return remoteConfig.getConfigObject(context);
How to use should.exist:
GitHub: qiniu/nodejs-sdk
30 31 32 33 34 35 36 37 38
}); it('test prepareZone error', function (done) { config.zone = null; qiniu.util.prepareZone(bucketManager, 'no_ak', 'no_bucket', function (err, ctx) { should.exist(err); done(); }); });
189
577
38
See more examples
How to use should.not:
GitHub: qiniu/nodejs-sdk
21 22 23 24 25 26 27 28 29 30
describe('test prepareZone', function () { it('test prepareZone', function (done) { config.zone = qiniu.zone.Zone_z0; qiniu.util.prepareZone(bucketManager, bucketManager.mac.accessKey, bucket, function (err, ctx) { should.not.exist(err); should.equal(bucketManager, ctx); done(); }); });
189
577
38
See more examples