mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
test(frontend): cover MIME precedence in non-PDF type detection (#6438)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [x] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [x] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [x] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [x] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [x] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [x] I have run `task check` to verify linters, typechecks, and tests pass - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details.
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
isPdfFile,
|
||||
detectFileExtension,
|
||||
formatFileSize,
|
||||
detectNonPdfFileType,
|
||||
} from "@app/utils/fileUtils";
|
||||
|
||||
describe("fileUtils", () => {
|
||||
@@ -94,4 +95,18 @@ describe("fileUtils", () => {
|
||||
expect(formatFileSize(1024 * 1024 * 1024)).toBe("1 GB");
|
||||
});
|
||||
});
|
||||
|
||||
describe("detectNonPdfFileType", () => {
|
||||
it("should prioritize MIME type over extension when they conflict", () => {
|
||||
expect(
|
||||
detectNonPdfFileType({
|
||||
name: "financial-summary.pdf",
|
||||
type: "text/csv",
|
||||
}),
|
||||
).toBe("csv");
|
||||
expect(
|
||||
detectNonPdfFileType({ name: "diagram.png", type: "application/json" }),
|
||||
).toBe("json");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user