-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: strip hash marks from file names (#20)
- Loading branch information
1 parent
c17c2f2
commit 051b843
Showing
4 changed files
with
59 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { cleanTag, cleanTitle, updateStringCase } from "../src/lib/util"; | ||
|
||
describe('cleanTag', () => { | ||
it('should replace invalid characters', () => { | ||
const strCase = "iKebab-case"; | ||
expect(cleanTag("Cheese&Bacon", strCase)).toEqual("Cheese-and-Bacon"); | ||
expect(cleanTag("C++", strCase)).toEqual("C"); | ||
expect(cleanTag("Categories:Other", strCase)).toEqual("Categories/Other"); | ||
expect(cleanTag("#hashtag", strCase)).toEqual("hashtag"); | ||
expect(cleanTag("Why++would++you++write++it++like++this?", strCase)).toEqual("Why-would-you-write-it-like-this"); | ||
}); | ||
}); | ||
|
||
describe('cleanTitle', () => { | ||
it('should replace pipes and colons with hyphens', () => { | ||
expect(cleanTitle("OpenNeRF: Open Set 3D Neural Scene Segmentation")) | ||
.toEqual("OpenNeRF - Open Set 3D Neural Scene Segmentation"); | ||
|
||
expect(cleanTitle("Local News | Botched home sale costs man his real estate license")) | ||
.toEqual("Local News - Botched home sale costs man his real estate license"); | ||
|
||
expect(cleanTitle("Blog|Some Title")).toEqual("Blog - Some Title"); | ||
|
||
expect(cleanTitle("Some Podcast #323")).toEqual("Some Podcast 323"); | ||
}) | ||
}); | ||
|
||
describe('updateStringCase', () => { | ||
it('should update string case', () => { | ||
const str = "Cheese and Bacon"; | ||
expect(updateStringCase(str, "iKebab-case")).toEqual("Cheese-and-Bacon"); | ||
expect(updateStringCase(str, "PascalCase")).toEqual("CheeseAndBacon"); | ||
expect(updateStringCase(str, "camelCase")).toEqual("cheeseAndBacon"); | ||
expect(updateStringCase(str, "kebab-case")).toEqual("cheese-and-bacon"); | ||
expect(updateStringCase(str, "snake_case")).toEqual("cheese_and_bacon"); | ||
}); | ||
}); | ||
|