Commit 0828c5ee authored by Farid Neshat's avatar Farid Neshat

Initial Commit

parents
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
* text=auto
node_modules
coverage
language: node_js
node_js:
- 7
- 6
- 4
{
"generator-node": {
"promptValues": {
"authorName": "OlinData BV",
"authorEmail": "FaridN_SOAD@yahoo.com",
"authorUrl": "https://olindata.com/en"
}
}
}
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2017 OlinData BV (https://olindata.com/en)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# chai-wildcard [![NPM version][npm-image]][npm-url]
> A chai plugin that adds `.matchWildcard`
This is mainly a wrapper for [matcher module](https://github.com/sindresorhus/matcher).
## Installation
```sh
$ npm install --save-dev chai-wildcard
```
## Usage
```js
const chaiWildcard = require('chai-wildcard');
const chai = require("chai");
chai.use(chaiWildcard);
const { expect } = chai;
expect('some string').to.match.wildcard('some*')
.and.match('!something else');
```
## License
MIT © [OlinData BV](https://olindata.com/en)
[npm-image]: https://badge.fury.io/js/chai-wildcard.svg
[npm-url]: https://npmjs.org/package/chai-wildcard
const chaiWildcard = require('../index.js');
const chai = require('chai');
chai.use(chaiWildcard);
const {expect} = chai;
describe('chaiWildcard', () => {
it('to matchWildcard', () => {
expect('something').to.matchWildcard('some*');
});
it('to not matchWildcard', () => {
expect('something').to.not.matchWildcard('someS*');
});
it('on failure should have proper exp/act', () => {
try {
expect('something').to.not.matchWildcard('some*');
} catch (e) {
expect(e.actual).to.be.eql('something');
expect(e.expected).to.be.eql('some*');
}
});
});
'use strict';
const matcher = require('matcher');
module.exports = function (chai, utils) {
const { Assertion } = chai;
utils.addChainableMethod(Assertion.prototype, 'matchWildcard', function (str) {
var obj = utils.flag(this, 'object');
this.assert(matcher.isMatch(obj, str),
'expected #{this} to match wildcard #{exp}',
'expected #{this} not to match wildcard #{exp}',
str);
});
};
This diff is collapsed.
{
"name": "chai-wildcard",
"version": "0.1.0",
"description": "A chai plugin that adds .matchWildcard",
"homepage": "https://gitlab.olindata.com/olindata/chai-wildcard",
"author": {
"name": "Farid Nouri Neshat",
"email": "FaridN_SOAD@yahoo.com"
},
"files": [
"lib"
],
"main": "lib/index.js",
"keywords": [
"chai",
"wildcard",
"match",
"glob",
"pattern"
],
"devDependencies": {
"chai": "^4.1.2",
"eslint": "^4.1.0",
"eslint-config-xo-space": "^0.16.0",
"jest": "^21.0.0",
"jest-cli": "^21.0.0",
"nsp": "^2.6.3"
},
"scripts": {
"prepublish": "nsp check",
"pretest": "eslint . --fix",
"test": "jest"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"jest": true,
"node": true
}
},
"repository": {
"type": "git",
"url": "https://gitlab.olindata.com/olindata/chai-wildcard.git"
},
"bugs": {
"url": "https://gitlab.olindata.com/olindata/chai-wildcard/issues"
},
"jest": {
"testEnvironment": "node"
},
"license": "MIT",
"dependencies": {
"matcher": "^1.0.0"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment