|
| 1 | +/* |
| 2 | +Copyright 2022 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import { ImageSize, suggestedSize } from "../../../src/settings/enums/ImageSize"; |
| 18 | + |
| 19 | +describe("ImageSize", () => { |
| 20 | + describe("suggestedSize", () => { |
| 21 | + it("constrains width", () => { |
| 22 | + const size = suggestedSize(ImageSize.Normal, { w: 648, h: 162 }); |
| 23 | + expect(size).toStrictEqual({ w: 324, h: 81 }); |
| 24 | + }); |
| 25 | + it("constrains height", () => { |
| 26 | + const size = suggestedSize(ImageSize.Normal, { w: 162, h: 648 }); |
| 27 | + expect(size).toStrictEqual({ w: 81, h: 324 }); |
| 28 | + }); |
| 29 | + it("does not constrain width in large mode", () => { |
| 30 | + const size = suggestedSize(ImageSize.Large, { w: 2400, h: 1200 }); |
| 31 | + expect(size).toStrictEqual({ w: 1200, h: 600 }); |
| 32 | + }); |
| 33 | + it("returns max values if content size is not specified", () => { |
| 34 | + const size = suggestedSize(ImageSize.Normal, { w: null, h: null }); |
| 35 | + expect(size).toStrictEqual({ w: 324, h: 324 }); |
| 36 | + }); |
| 37 | + }); |
| 38 | +}); |
0 commit comments