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

feat(assertions): add 'still' language chain #1194

Merged
merged 2 commits into from Sep 20, 2018

Conversation

ScottRudiger
Copy link
Contributor

To increase readability it's sometimes desirable to have a still language chain. Take this simplified test for example:

it('should have a length property that does not decrease below zero with excessive popping', () => {
  const array = [1, 2];
  array.pop();
  expect(array).to.have.lengthOf(1);
  array.pop();
  expect(array).to.have.lengthOf(0);
  array.pop();
  expect(array).to.still.have.lengthOf(0);
  array.pop();
  array.pop();
  array.pop();
  expect(array).to.still.have.lengthOf(0);
});

For my use case, it was easy enough to add an in-file helper with the following:

chai.use(({Assertion}) => Assertion.addProperty('still'));

But I thought I'd throw in a quick PR in case the maintainers agree this fits with the scope of the project.

Let me know if you'd like me to bump the version for a minor release and I'll add it to the PR (I'm familiar w/ the contributing guidelines).

I'll happily submit a corresponding PR to update the docs if this PR is accepted.

@ScottRudiger ScottRudiger requested a review from a team as a code owner September 13, 2018 19:35
@meeber
Copy link
Contributor

meeber commented Sep 15, 2018

I'm okay with adding still as a language chain. I don't think there's anything else that would need to be changed in terms of docs. A couple of tests would need to be updated for expect and should interfaces.

@chaijs/chai: Any strong feelings one way or the other about this?

@ScottRudiger
Copy link
Contributor Author

A couple of tests would need to be updated for expect and should interfaces.

@meeber I incorporated still into the tests for language chains in test/expect.js and test/should.js. Please let me know if there's something else I missed.

@codecov
Copy link

codecov bot commented Sep 20, 2018

Codecov Report

Merging #1194 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1194   +/-   ##
=======================================
  Coverage   94.51%   94.51%           
=======================================
  Files          32       32           
  Lines        1676     1676           
  Branches      404      404           
=======================================
  Hits         1584     1584           
  Misses         92       92
Impacted Files Coverage Δ
lib/chai/core/assertions.js 99.39% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 058ddad...7e5f67c. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants