Skip to content

Commit

Permalink
Update sitemaps & fix the url for some images (#228)
Browse files Browse the repository at this point in the history
* Add image to the ranking tiers

* Little tweaks
  • Loading branch information
petrvecera authored Jul 29, 2023
1 parent 31b5d25 commit 69fd685
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 329 deletions.
49 changes: 48 additions & 1 deletion __tests__/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,51 @@
import { calculatePageNumber, calculatePositionNumber, isBrowserEnv } from "../../src/utils";
import config from "../../config";
import {
calculatePageNumber,
calculatePositionNumber,
isBrowserEnv,
internalSlash,
getIconsPathOnCDN,
} from "../../src/utils";

describe("getIconsPathOnCDN", () => {
test("should return the correctly formed URL for the export folder", () => {
const result = getIconsPathOnCDN("/path/my_icon", "export");
expect(result).toBe(`${config.CDN_ASSETS_HOSTING}/export/path/my_icon.png`);
});

test("should return the correctly formed URL for the export folder", () => {
const result = getIconsPathOnCDN("my_icon", "export");
expect(result).toBe(`${config.CDN_ASSETS_HOSTING}/export/my_icon.png`);
});

test("should append .png if the filename does not end with .png in the export folder", () => {
const result = getIconsPathOnCDN("my_icon.png", "export");
expect(result).toBe(`${config.CDN_ASSETS_HOSTING}/export/my_icon.png`);
});

test("should return the correctly formed URL for the export_flatten folder", () => {
const result = getIconsPathOnCDN("/path/to/my_icon", "export_flatten");
expect(result).toBe(`${config.CDN_ASSETS_HOSTING}/export_flatten/my_icon.png`);
});

test("should remove the path and keep only the filename in the export_flatten folder", () => {
const result = getIconsPathOnCDN("/path/to/my_icon.png", "export_flatten");
expect(result).toBe(`${config.CDN_ASSETS_HOSTING}/export_flatten/my_icon.png`);
});
});

describe("internalSlash", () => {
test("convert backwards-slash paths to forward slash paths", () => {
expect(internalSlash("c:\\aaaa\\bbbb")).toEqual("c:/aaaa/bbbb");
expect(internalSlash("c:\\aaaa\\bbbb\\★")).toEqual("c:/aaaa/bbbb/★");
expect(internalSlash("c:\\aaaa\\bbbb")).toEqual("c:/aaaa/bbbb");
});

test("not convert extended-length paths", () => {
const path = "\\\\?\\c:\\aaaa\\bbbb";
expect(internalSlash(path)).toEqual(path);
});
});

describe("calculatePositionNumber", () => {
test("returns 0 for page 1", () => {
Expand Down
Loading

0 comments on commit 69fd685

Please sign in to comment.