Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisSigrist committed Oct 17, 2023
1 parent 51586da commit 039f183
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/core/codegen/dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function generateDTS(Catalogue) {
*/
const localeDictionaries = new Map();

for (const [locale, domain, dict] of Catalogue.getDictionaries()) {
const dictionaries = Catalogue.getDictionaries();
for (const [locale, domain, dict] of dictionaries.entries()) {
localeDictionaries.set(locale, dict);
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/utils/DoubleKeyedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export class DoubleKeyedMap {
return keys;
}

[Symbol.iterator]() {
/** @type {[string, string, T][]} */
const entries = [];
entries() {
/** @type {Set<[string, string, T]>} */
const entries = new Set();
for (const [key1, inner] of this.#map) {
for (const [key2, value] of inner.entries()) {
entries.push([key1, key2, value]);
entries.add([key1, key2, value]);
}
}
return entries[Symbol.iterator]();
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/DoubleKeyedMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("DoubleKeyedMap", () => {
map.set("foo2", "bar", "baz3");
map.set("foo2", "bar2", "baz4");

const triplets = new Set(map);
const triplets = new Set(map.entries());
expect (triplets.size).toBe(4);
})
});
16 changes: 16 additions & 0 deletions src/core/utils/id.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, it, expect } from "vitest";
import { cleanUrl } from "./id";

describe("cleanUrl", () => {
it("removes query parameters", () => {
expect(cleanUrl("http://example.com/?foo=bar")).toBe("http://example.com/");
});

it("removes hash values", () => {
expect(cleanUrl("http://example.com/#foo")).toBe("http://example.com/");
});

it("removes both query parameters and hash values", () => {
expect(cleanUrl("http://example.com/?foo=bar#baz")).toBe("http://example.com/");
});
});

0 comments on commit 039f183

Please sign in to comment.