Move escapeWhitespace to diffs and add small test

This commit is contained in:
Sebastian Sdorra
2020-09-02 07:40:52 +02:00
parent 4f060e4b24
commit 95dde51bba
4 changed files with 25 additions and 13 deletions

View File

@@ -23,7 +23,7 @@
*/
import { File, FileChangeType, Hunk } from "./DiffTypes";
import { getPath, createHunkIdentifier, createHunkIdentifierFromContext } from "./diffs";
import { getPath, createHunkIdentifier, createHunkIdentifierFromContext, escapeWhitespace } from "./diffs";
describe("tests for diff util functions", () => {
const file = (type: FileChangeType, oldPath: string, newPath: string): File => {
@@ -88,4 +88,15 @@ describe("tests for diff util functions", () => {
expect(identifier).toBe("delete_/etc/passwd_@@ -1,42 +1,39 @@");
});
});
describe("escapeWhitespace tests", () => {
it("should escape whitespaces", () => {
const escaped = escapeWhitespace("spaceship hog");
expect(escaped).toBe("spaceship-hog");
});
it("should escape multiple whitespaces", () => {
const escaped = escapeWhitespace("spaceship heart of gold");
expect(escaped).toBe("spaceship-heart-of-gold");
});
});
});