-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from yesmeck/automatic-tokenization
Automatic tokenization
- Loading branch information
Showing
6 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import expect from 'expect.js'; | ||
import { includesSeparators, splitBySeparators } from '../src/util'; | ||
|
||
describe('includesSeparators', () => { | ||
const separators = [' ', ',']; | ||
it('return true when given includes separators', () => { | ||
expect(includesSeparators(',foo,bar', separators)).to.be(true); | ||
}); | ||
|
||
it('return false when given do not include separators', () => { | ||
expect(includesSeparators('foobar', separators)).to.be(false); | ||
}); | ||
|
||
it('return false when string only has a leading separator', () => { | ||
expect(includesSeparators(',foobar', separators)).to.be(false); | ||
}); | ||
}); | ||
|
||
describe('splitBySeparators', () => { | ||
const separators = [' ', ',']; | ||
it('split given string by separators', () => { | ||
const string = 'foo bar,baz'; | ||
expect(splitBySeparators(string, separators)).to.eql(['foo', 'bar', 'baz']); | ||
}); | ||
|
||
it('split string with leading separator ', () => { | ||
const string = ',foo'; | ||
expect(splitBySeparators(string, separators)).to.eql(['foo']); | ||
}); | ||
|
||
it('split string with trailling separator', () => { | ||
const string = 'foo,'; | ||
expect(splitBySeparators(string, separators)).to.eql(['foo']); | ||
}); | ||
|
||
it('split a separator', () => { | ||
const string = ','; | ||
expect(splitBySeparators(string, separators)).to.eql([]); | ||
}); | ||
}); |