叉子为 柴弦
- 作为无害环境管理发布
- 与柴五兼容
- 删除
chai.string.XXX,仅支持expect编号 :assert样式断言
柴弦
匹配 Chai 的字符串比较断言.
使用量
浏览器
<script src="chai.js"></script>
<script src="chai-string.js"></script>
服务器
import * as chai from 'chai'
import string from '@achingbrain/chai-string'
chai.use(require('chai-string'))
请求
- 启动/启动
- 结束与结束
- 等离子目录
- 相等的忽略空间
- 包含忽略空间
- 包含忽略库
- 单行
- 倒转
- 帕林德罗
- 条目
- 索引
所有断言都为BDD语法和TDD语法所定义,但有一些别名存在,使这些断言在两种风格中都显得很好.
var d1 = 'abcdef',
d2 = 'abc';
d1.should.startWith.d2
expect(d1).to.startsWith(d2)
assert.startsWith(d1, d2)
启动/启动
assert.startsWith('abcdef', 'abc');
expect('abcdef').to.startsWith('abc');
'abcdef'.should.startWith('abc');
结束与结束
assert.endsWith('abcdef', 'def');
expect('abcdef').to.endsWith('def');
'abcdef'.should.endWith('def');
等离子目录
assert.equalIgnoreCase('abcdef', 'AbCdEf');
expect('abcdef').to.equalIgnoreCase('AbCdEf');
相等的忽略空间
assert.equalIgnoreSpaces('abcdef', 'a\nb\tc\r d ef');
expect('abcdef').to.equalIgnoreSpaces('a\nb\tc\r d ef');
包含忽略空间
assert.containIgnoreSpaces('abcdefgh', 'a\nb\tc\r d ef');
expect('abcdefgh').to.containIgnoreSpaces('a\nb\tc\r d ef');
包含忽略库
assert.containIgnoreCase('abcdefgh', 'AbcDefGH');
expect('abcdefgh').to.containIgnoreCase('AbcDefGH');
'abcdef'.should.containIgnoreCase('cDe');
单行
assert.singleLine('abcdef');
expect('abcdef').to.be.singleLine();
倒转
assert.reverseOf('abcdef', 'fedcba');
expect('abcdef').to.be.reverseOf('fedcba');
帕林德罗
assert.palindrome('abccba');
expect('abccba').to.be.palindrome();
条目
assert.entriesCount('abcabd', 'ab', 2);
expect('abcabd').to.have.entriesCount('ab', 2);
索引
assert.indexOf('abcabd', 'ab', 0);
expect('abcabd').to.have.indexOf('ab', 0);
谢谢
谢谢 约会时间 模块,用于给我一个如何构建和测试 chai 插件的想法.
