Update chai-string definitions for 1.4.0 (#23118)

This commit is contained in:
Stephen Wilcox 2018-01-29 12:15:27 -08:00 committed by Sheetal Nandi
parent 37c1b1dfea
commit 48d55d55fa
2 changed files with 109 additions and 1 deletions

View File

@ -51,6 +51,90 @@ describe('chai-string', function() {
});
describe('#containIgnoreSpaces', function () {
it('should return true', function () {
var str1 = '1234abcdef56',
str2 = '1234a\nb\tc\r d ef56';
str1.should.containIgnoreSpaces(str2);
});
it('should return true (2)', function () {
var str1 = 'abcdef',
str2 = 'a\nb\tc\r d ef';
str1.should.containIgnoreSpaces(str2);
});
it('should return false', function () {
var str1 = 'abdef',
str2 = 'a\nb\tc\r d ef';
str1.should.not.containIgnoreSpaces(str2);
});
});
describe('#containIgnoreCase', function () {
it('should return true', function () {
var str1 = 'abcdef',
str2 = 'cDe';
str1.should.containIgnoreCase(str2);
});
it('should return true (2)', function () {
'abcdef'.should.containIgnoreCase('cDe');
});
it('should return true (3)', function () {
var str1 = 'abcdef',
str2 = 'AbCdeF';
str1.should.containIgnoreCase(str2);
});
it('should return false', function () {
var str1 = 'abcdef',
str2 = 'efg';
str1.should.not.containIgnoreCase(str2);
});
it('should return false (3)', function () {
var str1 = 'abcdef',
str2 = 'zabcd';
str1.should.not.containIgnoreCase(str2);
});
});
describe('#indexOf', function () {
it('should return true', function () {
var str = 'abcabd',
substr = 'ab',
index = 0;
str.indexOf(substr, index).should.be.true;
});
it('should return true (2)', function () {
var str = 'abcabd',
substr = 'ca',
index = 2;
str.indexOf(substr, index).should.be.true;
});
it('should return true (3)', function () {
var str = 'ababab',
substr = 'ba',
index = 1;
str.indexOf(substr, index).should.be.true;
});
it('should return false', function () {
var str = 'abcaab',
substr = 'da',
index = 1;
str.indexOf(substr, index).should.be.false;
});
});
describe('tdd alias', function() {
let str: string;
let str2: string;
@ -92,6 +176,14 @@ describe('chai-string', function() {
assert.notEqualIgnoreSpaces(str, str2 + 'g');
});
it('.containIgnoreSpaces', function () {
assert.containIgnoreSpaces(str, str2);
});
it('.notContainIgnoreSpaces', function () {
assert.notContainIgnoreSpaces(str, str2 + 'g');
});
it('.singleLine', function() {
assert.singleLine(str);
});
@ -125,5 +217,13 @@ describe('chai-string', function() {
assert.entriesCount('', 'ab', 0);
});
it('.indexOf', function () {
assert.indexOf('abcabd', 'ab', 0);
assert.indexOf('abcabd', 'ca', 2);
assert.indexOf('ababab', 'ba', 1);
assert.indexOf('ababab', 'ba', 1);
'ababab'.indexOf('ba', 1).should.be.true;
});
});
});

View File

@ -1,4 +1,4 @@
// Type definitions for chai-string 1.1.4
// Type definitions for chai-string 1.4.0
// Project: https://github.com/onechiporenko/chai-string
// Definitions by: Nick Malaguti <https://github.com/nmalaguti>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -14,10 +14,13 @@ declare global {
endWith(expected: string, message?: string): Assertion;
equalIgnoreCase(expected: string, message?: string): Assertion;
equalIgnoreSpaces(expected: string, message?: string): Assertion;
containIgnoreCase(expected: string, msg?: string): Assertion;
containIgnoreSpaces(expected: string, msg?: string): Assertion;
singleLine(message?: string): Assertion;
reverseOf(message?: string): Assertion;
palindrome(message?: string): Assertion;
entriesCount(substr: string, expected: number, message?: string): Assertion;
indexOf(str: string, substr: string, index: number, msg?: string): Assertion;
}
interface Assert {
@ -29,6 +32,10 @@ declare global {
notEqualIgnoreCase(val: string, exp: string, msg?: string): void;
equalIgnoreSpaces(val: string, exp: string, msg?: string): void;
notEqualIgnoreSpaces(val: string, exp: string, msg?: string): void;
containIgnoreCase(val: string, exp: string, msg?: string): void;
notContainIgnoreCase(val: string, exp: string, msg?: string): void;
containIgnoreSpaces(val: string, exp: string, msg?: string): void;
notContainIgnoreSpaces(val: string, exp: string, msg?: string): void;
singleLine(val: string, msg?: string): void;
notSingleLine(val: string, msg?: string): void;
reverseOf(val: string, exp: string, msg?: string): void;
@ -36,6 +43,7 @@ declare global {
palindrome(val: string, msg?: string): void;
notPalindrome(val: string, msg?: string): void;
entriesCount(str: string, substr: string, count: number, msg?: string): void;
indexOf(str: string, substr: string, index: number, msg?: string): void;
}
}
}