-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathFormatTest.java
More file actions
34 lines (29 loc) · 1.29 KB
/
Copy pathFormatTest.java
File metadata and controls
34 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.tinify;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.equalTo;
public class FormatTest {
@Test
public void formatShouldExposeSupportedMediaTypes() {
assertThat(Format.WEBP, is(equalTo("image/webp")));
assertThat(Format.PNG, is(equalTo("image/png")));
assertThat(Format.JPEG, is(equalTo("image/jpeg")));
assertThat(Format.JPG, is(equalTo("image/jpg")));
assertThat(Format.AVIF, is(equalTo("image/avif")));
assertThat(Format.JXL, is(equalTo("image/jxl")));
assertThat(Format.ANY, is(equalTo("*/*")));
}
@Test
public void convertWithFormatShouldSerializeMediaType() {
Options options = new Options().with("convert", new Options().with("type", Format.JXL));
assertThat(options.toJson(), is(equalTo("{\"convert\":{\"type\":\"image/jxl\"}}")));
}
@Test
public void convertWithMultipleFormatsShouldSerializeMediaTypes() {
Options options = new Options().with("convert",
new Options().with("type", new String[]{Format.JXL, Format.WEBP}));
assertThat(options.toJson(),
is(equalTo("{\"convert\":{\"type\":[\"image/jxl\",\"image/webp\"]}}")));
}
}