chai-quantifiers

Array quantifier assertions for chai assertion library

MIT 23 个版本
安装
npm install chai-quantifiers
yarn add chai-quantifiers
pnpm add chai-quantifiers
bun add chai-quantifiers
README

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 2024-02-26
1.0.17 2022-07-04
1.0.16 2021-11-04
1.0.15 2021-08-30
1.0.13 2021-01-09
1.0.12 2021-01-09
1.0.11 2020-12-27
1.0.10 2020-09-12
1.0.9 2020-01-27
1.0.8 2020-01-24
1.0.7 2019-07-11
1.0.6 2019-05-01
1.0.5 2019-03-27
1.0.4 2018-08-18
1.0.3 2018-08-10
1.0.2 2018-06-08
1.0.1 2018-05-05
1.0.0-beta.2 2018-03-08
1.0.0-beta.1 2018-02-27
1.0.0-alpha.3 2018-02-22
1.0.0-alpha.2 2018-02-22
1.0.0-alpha.1 2018-02-22
1.0.0 2018-04-09