Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["@babel/env", "@babel/preset-typescript"]
"presets": ["@babel/env", "@babel/preset-typescript"],
"ignore": ["**/*.spec.js", "**/*.spec.ts"]
}
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ end_of_line = lf
insert_final_newline = true
indent_style = tab

[*.yml]
indent_style = space
indent_size = 2

[package.json]
indent_style = space
indent_size = 2
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ jobs:

- run: npm install
- run: npm run lint
- run: npm run lint-demo
- run: npm run build
- run: npm run build-demo
- run: npm run build-types
- run: npm run test
- run: npx testpack-cli --keep={ts-jest,typescript} src/e2e.spec.ts

- name: Upload test coverage report to Codecov
uses: codecov/codecov-action@v1
Expand Down
2 changes: 1 addition & 1 deletion demo/src/demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { condense, condenseIgnoreCase } from '../../src/index';
import { condense, condenseIgnoreCase } from '../../src';
import { autoExpandTextarea } from './utils/auto-expand-field';
import { parseString, WhitespaceHandling } from './utils/wordList';

Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
"node": ">=10"
},
"scripts": {
"build": "npm run clean && babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' && npm run build-types",
"build-demo": "wp --config demo/webpack.config.js",
"build-types": "tsc -p ./tsconfig.types.json",
"build": "run-s clean build:*",
"build:src": "babel src -d lib --extensions '.js,.ts'",
"build:demo": "wp --config demo/webpack.config.js",
"build:types": "tsc -p ./tsconfig.types.json",
"clean": "rimraf lib/*",
"format": "prettier --write 'src/**'",
"lint": "tsc -p ./tsconfig.json && eslint ./src --report-unused-disable-directives --ext .js,.ts --parser-options=project:./tsconfig.json",
"lint-demo": "tsc -p ./demo/tsconfig.json && eslint ./demo --report-unused-disable-directives --ext .js,.ts --parser-options=project:./demo/tsconfig.json",
"lint": "run-s lint:*",
"lint:src": "tsc -p ./tsconfig.json && eslint ./src --report-unused-disable-directives --ext .js,.ts --parser-options=project:./tsconfig.json",
"lint:demo": "tsc -p ./demo/tsconfig.json && eslint ./demo --report-unused-disable-directives --ext .js,.ts --parser-options=project:./demo/tsconfig.json",
"precommit": "pretty-quick --staged",
"prepublish": "npx publish-please guard",
"publish-please": "npx publish-please",
"publish-please-prereqs": "npm run lint && npm run test && npm run build",
"publish-please-prereqs": "run-s lint test build",
"test": "jest --coverage"
},
"jest": {
Expand Down Expand Up @@ -60,6 +62,7 @@
"husky": "^0.14.3",
"jest": "^26.0.0",
"jest-when": "^2.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.13.7",
"pretty-quick": "^1.6.0",
"regenerator-runtime": "^0.13.3",
Expand Down
21 changes: 21 additions & 0 deletions src/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { condense, condenseIgnoreCase } from '.';

describe('condense end-to-end', () => {
it('builds a case-sensitive RegEx to match strings', () => {
const stringsToMatch = ['foo', 'foobar', 'Foo', 'fooBarBaz'];
const matcher = condense(stringsToMatch);

expect(matcher).toHaveProperty('flags', '');
expect(matcher).toHaveProperty('source', '(foo(|bar|BarBaz)|Foo)');
});
});

describe('condenseIgnoreCase end-to-end', () => {
it('builds a case-insensitive RegEx to match strings', () => {
const stringsToMatch = ['foo', 'foobar', 'Foo', 'fooBarBaz'];
const matcher = condenseIgnoreCase(stringsToMatch);

expect(matcher).toHaveProperty('flags', 'i');
expect(matcher).toHaveProperty('source', 'foo(|bar(|baz))');
});
});
2 changes: 1 addition & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { when } from 'jest-when';
import { CharTrie } from './types/charTrie';
import * as patternUtils from './utils/pattern';
import * as trieUtils from './utils/trie';
import { condense, condenseIgnoreCase } from './index';
import { condense, condenseIgnoreCase } from '.';

describe('condense', () => {
it('builds pattern from trie of words', () => {
Expand Down