mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Icons for years (#220)
This commit is contained in:
@@ -1366,11 +1366,25 @@ describe("server", () => {
|
||||
"..%2F..%2Ffoo",
|
||||
"%2Fetc%2Fpasswd",
|
||||
".%2Fbob.js",
|
||||
".",
|
||||
"..",
|
||||
"1",
|
||||
"%23%24",
|
||||
].forEach((type) => {
|
||||
describe(`trying to retrieve an icon with name ${type}`, () => {
|
||||
it(`should fail`, async () => {
|
||||
const response = await request(server()).get(
|
||||
`/icon/${type}/size/legacy`
|
||||
);
|
||||
|
||||
expect(response.status).toEqual(400);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("missing icons", () => {
|
||||
[
|
||||
"1",
|
||||
"notAValidIcon",
|
||||
"notAValidIcon:withSomeText"
|
||||
].forEach((type) => {
|
||||
describe(`trying to retrieve an icon with name ${type}`, () => {
|
||||
it(`should fail`, async () => {
|
||||
@@ -1398,6 +1412,20 @@ describe("server", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("invalid text", () => {
|
||||
["..", "foobar.123", "_dog_", "{ whoop }"].forEach((text) => {
|
||||
describe(`trying to retrieve an icon with text ${text}`, () => {
|
||||
it(`should fail`, async () => {
|
||||
const response = await request(server()).get(
|
||||
`/icon/yyyy:${text}/size/60`
|
||||
);
|
||||
|
||||
expect(response.status).toEqual(400);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("fetching", () => {
|
||||
[
|
||||
"artists",
|
||||
@@ -1527,6 +1555,41 @@ describe("server", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("specifing some text", () => {
|
||||
const text = "somethingWicked"
|
||||
|
||||
describe(`legacy icon`, () => {
|
||||
it("should return the png image", async () => {
|
||||
const response = await request(server()).get(
|
||||
`/icon/yyyy:${text}/size/legacy`
|
||||
);
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.header["content-type"]).toEqual("image/png");
|
||||
const image = await Image.load(response.body);
|
||||
expect(image.width).toEqual(80);
|
||||
expect(image.height).toEqual(80);
|
||||
});
|
||||
});
|
||||
|
||||
describe("svg icon", () => {
|
||||
it(`should return an svg image with the text replaced`, async () => {
|
||||
const response = await request(server()).get(
|
||||
`/icon/yyyy:${text}/size/60`
|
||||
);
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.header["content-type"]).toEqual(
|
||||
"image/svg+xml; charset=utf-8"
|
||||
);
|
||||
const svg = Buffer.from(response.body).toString();
|
||||
expect(svg).toContain(
|
||||
`>${text}</text>`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user