Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul development and test dependencies. #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ jobs:

- name: Install dependencies
run: |
npm install -g grunt
npm install

- name: Tests
- name: Run tests
shell: bash
run: |
grunt
npm test

test-python:
runs-on: ${{ matrix.os }}
Expand Down
58 changes: 0 additions & 58 deletions Gruntfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Words are case insensitive.
Also note that due to the complexities of the English language, I am considering anything containing the substring of a bad word to be blacklisted. For example, even though "homogenous" is not a bad word, it contains the substring "homo" and it gets filtered. The reason for this is that new slang pops up all the time using compound words and I can't possibly keep up with it. I'm willing to lose a few words like "homogenous" and "Pakistan" in order to avoid false negatives.

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using the included testing libraries (e.g., run `npm test` to test the JavaScript library).

## License
Copyright (c) 2013 Darius Kazemi
Expand Down
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt nodeunit"
"watch": "concurrently \"npm:watch:*\"",
"watch:json": "onchange 'lib/badwords.json' -- npm run jsonlint",
"watch:js": "onchange 'lib/**/*.js' 'test/**/*.js' -- concurrently \"npm:test:js\" \"npm:jshint\"",
"test": "npm run test:js",
"test:js": "npx jest test/wordfilter.test.js",
"jshint": "npx jshint lib/ test/",
"jsonlint": "npx jsonlint lib/badwords.json"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.4.0",
"grunt-jsonlint": "^1.0.4",
"grunt": "~0.4.1"
"@prantlf/jsonlint": "^14.0.3",
"concurrently": "^8.2.0",
"jest": "^29.5.0",
"jshint": "^2.13.6",
"onchange": "^7.1.0"
},
"keywords": []
}
37 changes: 37 additions & 0 deletions test/wordfilter.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// See https://jshint.com/docs/ for test documentation.

// Inline configuration for jshint to ignore the undefined Jest functions:
/* globals test, expect */

var wordfilter = require('../lib/wordfilter.js');

test('detects bad words in a string', function() {
expect(typeof(wordfilter)).toEqual('object');
expect(wordfilter.blacklisted('this string contains the word skank')).toBeTruthy();
expect(wordfilter.blacklisted('this string contains the word SkAnK')).toBeTruthy();
expect(wordfilter.blacklisted('this string contains the wordskank')).toBeTruthy();
expect(wordfilter.blacklisted('this string contains the skankword')).toBeTruthy();
expect(wordfilter.blacklisted('this string is clean!')).toBeFalsy();
});

test('add a word to blacklist', function() {
wordfilter.addWords(['clean']);

expect(wordfilter.blacklisted('this string was clean!')).toBeTruthy();
});

test('remove a single word from blacklist', function() {
wordfilter.removeWord('crip');

expect(wordfilter.blacklisted('I have a prescription.')).toBeFalsy();
});

test('clear blacklist', function() {
wordfilter.clearList();

expect(wordfilter.blacklisted('this string contains the word skank')).toBeFalsy();

wordfilter.addWords(['skank']);

expect(wordfilter.blacklisted('this string contains the word skank')).toBeTruthy();
});
66 changes: 0 additions & 66 deletions test/wordfilter_test.js

This file was deleted.