chai-increasing

増加/減少シーケンスに対する Chai マッチャー

chai プラグインで 増加/減少シーケンス に対するアサーションを作成しましょう

使用法

単調増加/減少

expect([1,2,2,3,3,4]).to.be.increasing;
expect([5,4,4,4,4,3]).to.be.decreasing;
expect([1,1,1,1,1,1]).to.be.increasing;
expect([1,1,1,1,1,1]).to.be.decreasing;

厳密増加/減少

expect([1,2,3,4,5]).to.be.strictly.increasing;
expect([1,2,3,3,4,5]).not.to.be.strictly.increasing;
expect([10,9,8,7,6]).to.be.strictly.increasing;
expect([10,9,8,7,7]).not.to.be.strictly.decreasing;

空の配列は 明らかに 増加/減少します。

expect([]).to.be.increasing;
expect([]).to.be.decreasing;
expect([]).to.be.strictly.increasing;
expect([]).to.be.strictly.decreasing;

追加機能

// supports Strings, Floats and Immutable.js Lists
expect(['Apple','Banana','Coconut']).to.be.strictly.increasing;
expect([1.15, 1.75, 3.28, 4.96]).to.be.strictly.increasing;
expect(Immutable.List.of([1,2,3,4])).to.be.strictly.increasing;

非減少/非増加別名

// "nondecreasing" and "nonincreasing" may be used instead 
// of "increasing" and "decreasing" for clarity; the behaviour is the same.
expect([1,1,1]).to.be.increasing;
expect([1,1,1]).to.be.nondecreasing;

インストール

npm install chai-increasing --save-dev
var chai = require('chai');
chai.use(require('chai-increasing'));

ライセンス

MIT ライセンス。
Copyright © 2016 James Lawson