-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BaseService tests: Use Chai #1450
Conversation
Generated by 🚫 dangerJS |
@@ -1,6 +1,6 @@ | |||
'use strict'; | |||
|
|||
const assert = require('assert'); | |||
const { expect } = require('chai'); | |||
const sinon = require('sinon'); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding require('../lib/register-chai-plugins.spec');
here allows to run tests only from this file (using command line or IDE). Otherwise we will get Error: Invalid Chai property: calledOnce ...
services/base.spec.js
Outdated
assert(mockCamp.route.calledOnce); | ||
assert.equal(mockCamp.route.getCall(0).args[0].toString(), expectedRouteRegex); | ||
expect(mockCamp.route).to.have.been.calledOnce; | ||
expect(mockCamp.route.getCall(0).args[0].toString()).to.equal(expectedRouteRegex.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace it with
expect(mockCamp.route).to.have.been.calledWith(expectedRouteRegex);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it fails, because we need the .toString()
.
> /foo/ === /foo/
false
> /foo/ == /foo/
false
> /foo/.toString() === /foo/.toString()
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, no, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ Chai
It looks great! Thanks :-) |
Thanks for reading 😄 |
…1543 This merges the `node-8` branch. The heavy lift was by @Daniel15 with refactoring from me and a patch by @RedSparr0w. * New API for registering services (#963) * Disable Node 6 tests on node-8 branch (#1423) * BaseService: Factor out methods _regex and _namedParamsForMatch (#1425) - Adjust test grouping - Rename data -> queryParams, text -> message * BaseService tests: Use Chai (#1450) * BaseService: make serviceData and badgeData explicit and declarative (#1451) * fix isValidStyle test (#1544) * Run tests in Node 9, not Node 6 (#1543)
No description provided.