1.0.18 • Published 2 months ago

chai-quantifiers v1.0.18

Weekly downloads
1,332
License
MIT
Repository
github
Last release
2 months ago

chai-quantifiers

Array quantifier assertions for Chai assertion library.

main workflow Coverage Status Maintainability node code style Types License Status

Install

npm install --save-dev chai chai-quantifiers

Usage

There are three assertions available, applicable to arrays.

  • containAll -- Asserts that all array items are true in respect to a predicate.
  • containOne -- Asserts that at least one array item is true in respect to a predicate.
  • containExactlyOne -- Asserts that exactly one array item is true in respect to a predicate.

A quick example:

const chai = require('chai');
const chaiQuantifiers = require('chai-quantifiers');

chai.use(chaiQuantifiers);

const { expect } = chai;

describe('chai-quantifiers', () => {
  it('containAll should be true if all items are true', () => {
    expect([0, 1, 2, 3]).to.containAll(item => item < 4);
  });
  it('containOne should be true if at least one item is true', () => {
    expect([0, 1, 2, 3]).to.containOne(item => item >= 2);
  });
  it('containExactlyOne should be true if exactly one item is true', () => {
    expect([0, 1, 2, 3]).to.containExactlyOne(item => item === 2);
  });
});

This module also includes types for TypeScript.

1.0.18

2 months ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-alpha.3

6 years ago

1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago