-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-file-manager): extract file extension from an optional key
- Loading branch information
Showing
5 changed files
with
81 additions
and
9 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,5 @@ | ||
const base = require("../../jest.config.base"); | ||
|
||
module.exports = { | ||
...base({ path: __dirname }) | ||
}; |
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,68 @@ | ||
import { FileKey } from "./FileKey"; | ||
|
||
describe("FileKey", () => { | ||
it("should generate a file key (extension is included in the name)", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image-14.jpg", | ||
type: "image/jpeg" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("image-14.jpg"); | ||
}); | ||
|
||
it("should generate a file key (extension derived from file type)", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image-14", | ||
type: "image/jpeg" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("image-14.jpeg"); | ||
}); | ||
|
||
it("should generate a file key containing id", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image-14.jpeg", | ||
type: "image/jpeg", | ||
id: "12345678" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("12345678/image-14.jpeg"); | ||
}); | ||
|
||
it("should generate a file key containing prefix", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image-14.jpeg", | ||
type: "image/jpeg", | ||
keyPrefix: "prefix" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("prefix/image-14.jpeg"); | ||
}); | ||
|
||
it("should generate a file key containing id and prefix", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image-14.jpeg", | ||
type: "image/jpeg", | ||
id: "12345678", | ||
keyPrefix: "prefix" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("prefix/12345678/image-14.jpeg"); | ||
}); | ||
|
||
it("should use the key defined in the input", () => { | ||
const fileKey = new FileKey({ | ||
size: 1071690, | ||
name: "image", | ||
type: "image/jpeg", | ||
key: "image-14.jpg" | ||
}); | ||
|
||
expect(fileKey.toString()).toEqual("image-14.jpg"); | ||
}); | ||
}); |
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