Skip to content
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

Merged
merged 4 commits into from
Jan 15, 2018
Merged

BaseService tests: Use Chai #1450

merged 4 commits into from
Jan 15, 2018

Conversation

paulmelnikow
Copy link
Member

No description provided.

@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth label Jan 15, 2018
@shields-ci
Copy link

shields-ci commented Jan 15, 2018

Messages
📖

✨ Thanks for your contribution to Shields, @paulmelnikow!

Generated by 🚫 dangerJS

@@ -1,6 +1,6 @@
'use strict';

const assert = require('assert');
const { expect } = require('chai');
const sinon = require('sinon');

Copy link
Member

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 ...

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());
Copy link
Member

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);

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ Chai

@platan
Copy link
Member

platan commented Jan 15, 2018

It looks great! Thanks :-)

@paulmelnikow paulmelnikow merged commit b6045b9 into badges:node-8 Jan 15, 2018
@paulmelnikow paulmelnikow deleted the base-chai branch January 15, 2018 19:42
@paulmelnikow
Copy link
Member Author

Thanks for reading 😄

paulmelnikow added a commit that referenced this pull request Mar 12, 2018
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants