-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
16 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function replaceNewlineWithBr(str) { | ||
return str.replace(/\r?\n/g, '<br>') | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import sum from './sum' | ||
import {replaceNewlineWithBr} from '../src/utils' | ||
|
||
test('main', () => { | ||
expect(sum(1, 2)).toBe(3) | ||
test('replaceNewlineWithBr', () => { | ||
const strInWindows = '1.登录平台,选择需求池tab\r\n2.需求列表有需求' | ||
const strInUnix = '1.登录平台,选择需求池tab\n2.需求列表有需求' | ||
const normalStr = `1.登录平台,选择需求池tab<br>2.需求列表有需求` | ||
expect(replaceNewlineWithBr(strInWindows)).toBe(normalStr) | ||
expect(replaceNewlineWithBr(strInUnix)).toBe(normalStr) | ||
}) |