test: improve test coverage (#6387)

* test: improve test coverage

* fix

* use posixPath
This commit is contained in:
Joshua Chen 2022-01-18 16:29:40 +08:00 committed by GitHub
parent a9810db1cc
commit 62223ee556
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 463 additions and 60 deletions

View file

@ -5,7 +5,24 @@
* LICENSE file in the root directory of this source tree.
*/
import {parseBlogFileName} from '../blogUtils';
import {truncate, parseBlogFileName} from '../blogUtils';
describe('truncate', () => {
test('truncates texts', () => {
expect(
truncate('aaa\n<!-- truncate -->\nbbb\nccc', /<!-- truncate -->/),
).toEqual('aaa\n');
expect(
truncate('\n<!-- truncate -->\nbbb\nccc', /<!-- truncate -->/),
).toEqual('\n');
});
test('leaves texts without markers', () => {
expect(truncate('aaa\nbbb\nccc', /<!-- truncate -->/)).toEqual(
'aaa\nbbb\nccc',
);
expect(truncate('', /<!-- truncate -->/)).toEqual('');
});
});
describe('parseBlogFileName', () => {
test('parse file', () => {