Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-string

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-string - npm Package Compare versions

Comparing version 1.1.4 to 1.1.6

LICENSE

18

chai-string.js

@@ -73,2 +73,6 @@ (function (plugin) {

chai.string.indexOf = function(str, substr, index) {
return str.indexOf(substr) === index;
};
var startsWithMethodWrapper = function (expected) {

@@ -160,2 +164,12 @@ var actual = this._obj;

chai.Assertion.addChainableMethod('indexOf', function(substr, index) {
var actual = this._obj;
return this.assert(
chai.string.indexOf(actual, substr, index),
'expected ' + this._obj + ' to have ' + substr + ' on index ' + index,
'expected ' + this._obj + ' to not have ' + substr + ' on index ' + index
);
});
// Asserts

@@ -224,2 +238,6 @@ var assert = chai.assert;

assert.indexOf = function(str, substr, index, msg) {
new chai.Assertion(str, msg).to.have.indexOf(substr, index);
}
}));

12

package.json
{
"name": "chai-string",
"version": "1.1.4",
"version": "1.1.6",
"keywords": ["chai", "testing", "string", "chai-plugin", "browser"],

@@ -20,9 +20,9 @@ "description": "strings comparison matchers for chai",

"devDependencies": {
"chai": "^1.9.1",
"mocha": "~1.6.0",
"nodemon": "~0.6.23"
"chai": ">=1.9.1",
"mocha": ">=1.6.0",
"nodemon": ">=0.6.23"
},
"dependencies": {
"chai": "^1.9.1"
"peerDependencies": {
"chai": ">=1.9.1"
}
}

@@ -34,2 +34,3 @@ # chai-string

* entriesCount
* indexOf

@@ -97,4 +98,10 @@ All assertions are defined for both the BDD and TDD syntax but some aliases exist to make the assertions look good with both styles.

### indexOf
```javascript
assert.indexOf('abcabd', 'ab', 0);
expect('abcabd').to.have.indexOf('ab', 0);
```
## Thanks
Thanks to the [chai-datetime](https://github.com/gaslight/chai-datetime) module for giving me an idea for how to structure and test a chai plugin.

@@ -235,2 +235,35 @@ (function (test) {

describe('#indexOf', function() {
it('should return true', function() {
var str = 'abcabd',
substr = 'ab',
index = 0;
chai.string.indexOf(str, substr, index).should.be.true;
});
it('should return true (2)', function() {
var str = 'abcabd',
substr = 'ca',
index = 2;
chai.string.indexOf(str, substr, index).should.be.true;
});
it('should return true (3)', function() {
var str = 'ababab',
substr = 'ba',
index = 1;
chai.string.indexOf(str, substr, index).should.be.true;
});
it('should return false', function() {
var str = 'abcaab',
substr = 'da',
index = 1;
chai.string.indexOf(str, substr, index).should.be.false;
});
});
describe('tdd alias', function () {

@@ -308,4 +341,11 @@

it('.indexOf', function() {
assert.indexOf('abcabd', 'ab', 0);
assert.indexOf('abcabd', 'ca', 2);
assert.indexOf('ababab', 'ba', 1);
expect('ababab').to.have.indexOf('ba', 1);
});
});
});
}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc