Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #152 from hcodes/string_tests
Browse files Browse the repository at this point in the history
Add tests for string helpers
  • Loading branch information
hcodes authored Apr 4, 2020
2 parents 6a14736 + 2218171 commit 95cea29
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ reports.onStart();
async.series(
isStdin ?
tasks.forStdin(program.stdinFilename, mergedOptions) :
tasks.forResources(program.args, mergedOptions),
() => {
reports.onComplete(mergedOptions.configRelativePath);
process.exit();
}
);
tasks.forResources(program.args, mergedOptions)
).then(() => {
reports.onComplete(mergedOptions.configRelativePath);
process.exit();
});
35 changes: 34 additions & 1 deletion test/helpers.string.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const assert = require('chai').assert;
const {
kebabCase,
isHTML,
isMarkdown,
jsonStringify,
replaceEngLettersWithAsterisk,
replaceRusLettersWithAsterisk,
hasEngRusLetters,
splitTrim,
splitByCommas,
stripTags,
} = require('../lib/helpers/string');
} = require('../lib/helpers/string');

describe('String', () => {
it('kebabCase', () => {
Expand All @@ -32,4 +37,32 @@ describe('String', () => {
it('stripTags', () => {
assert.ok(stripTags('<p>Hello</p>', 'Hello'));
});

it('isHTML', () => {
assert.ok(isHTML('<p>Hello</p>'));
assert.notOk(isHTML('Hello world'));
});

it('isMarkdown', () => {
assert.ok(isMarkdown('```code```'));
assert.notOk(isMarkdown('Hello world'));
});

it('jsonStringify', () => {
assert.equal(jsonStringify({ a: 1, b: 2 }), '{\n "a": 1,\n "b": 2\n}');
});

it('isMarkdown', () => {
assert.ok(isMarkdown('```code```'));
assert.notOk(isMarkdown('Hello world'));
});

it('splitTrim', () => {
assert.deepEqual(splitTrim(' 1:2 ', ':'), ['1', '2']);
});

it('splitByComma', () => {
assert.deepEqual(splitByCommas('console , html '), ['console', 'html']);
});

});

0 comments on commit 95cea29

Please sign in to comment.