fix: #1738 save image dimensions to svg uploads
This commit is contained in:
15
test/uploads/image.svg
Normal file
15
test/uploads/image.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg width="260" height="260" viewBox="0 0 260 260" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
path {
|
||||
fill: #333333;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
path {
|
||||
fill: white;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<path d="M120.59 8.5824L231.788 75.6142V202.829L148.039 251.418V124.203L36.7866 57.2249L120.59 8.5824Z" />
|
||||
<path d="M112.123 244.353V145.073L28.2114 193.769L112.123 244.353Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 437 B |
@@ -26,7 +26,7 @@ describe('Collections - Uploads', () => {
|
||||
|
||||
describe('REST', () => {
|
||||
describe('create', () => {
|
||||
it('creates from form data', async () => {
|
||||
it('creates from form data given a png', async () => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', fs.createReadStream(path.join(__dirname, './image.png')));
|
||||
|
||||
@@ -56,6 +56,29 @@ describe('Collections - Uploads', () => {
|
||||
expect(doc.sizes).toHaveProperty('mobile');
|
||||
expect(doc.sizes).toHaveProperty('icon');
|
||||
});
|
||||
|
||||
it('creates from form data given an svg', async () => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', fs.createReadStream(path.join(__dirname, './image.svg')));
|
||||
|
||||
const { status, doc } = await client.create({
|
||||
file: true,
|
||||
data: formData,
|
||||
auth: true,
|
||||
headers: {},
|
||||
});
|
||||
|
||||
expect(status).toBe(201);
|
||||
|
||||
// Check for files
|
||||
expect(await fileExists(path.join(__dirname, './media', doc.filename))).toBe(true);
|
||||
|
||||
// Check api response
|
||||
expect(doc.mimeType).toEqual('image/svg+xml');
|
||||
expect(doc.sizes.maintainedAspectRatio.url).toBeUndefined();
|
||||
expect(doc.width).toBeDefined();
|
||||
expect(doc.height).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
it('creates images that do not require all sizes', async () => {
|
||||
|
||||
Reference in New Issue
Block a user