Create settings page and image cache #27
4 changed files with 25 additions and 4 deletions
|
@ -2,7 +2,7 @@ module.exports = {
|
||||||
moduleFileExtensions: ["js", "jsx", "json", "vue", "ts", "tsx"],
|
moduleFileExtensions: ["js", "jsx", "json", "vue", "ts", "tsx"],
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.vue$": "vue-jest",
|
"^.+\\.vue$": "vue-jest",
|
||||||
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
|
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2|webp)$":
|
||||||
"jest-transform-stub",
|
"jest-transform-stub",
|
||||||
"^.+\\.tsx?$": "ts-jest"
|
"^.+\\.tsx?$": "ts-jest"
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,3 +3,4 @@ export * from "./MockPeer";
|
||||||
export * from "./MockHelper";
|
export * from "./MockHelper";
|
||||||
export * from "./EventHook";
|
export * from "./EventHook";
|
||||||
export * from "./IDBShim";
|
export * from "./IDBShim";
|
||||||
|
export * from "./sync-utils";
|
||||||
|
|
5
src/testing/sync-utils.ts
Normal file
5
src/testing/sync-utils.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export function seconds(ms: number): Promise<void> {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(resolve, ms * 1000);
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
import CardPicker from "@/components/DeckBuilder/CardPicker.vue";
|
import CardPicker from "@/components/DeckBuilder/CardPicker.vue";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import CardImage from "@/components/Cards/CardImage.vue";
|
||||||
|
import { shallowMount, mount } from "@vue/test-utils";
|
||||||
|
import { seconds } from "@/testing";
|
||||||
|
|
||||||
// Generate 10 test cards
|
// Generate 10 test cards
|
||||||
const testCards = new Array(10)
|
const testCards = new Array(10)
|
||||||
|
@ -8,8 +10,8 @@ const testCards = new Array(10)
|
||||||
const testSlots = testCards.map(c => ({ data: c, limit: 3, howmany: 1 }));
|
const testSlots = testCards.map(c => ({ data: c, limit: 3, howmany: 1 }));
|
||||||
|
|
||||||
describe("components/DeckBuilder/CardPicker", () => {
|
describe("components/DeckBuilder/CardPicker", () => {
|
||||||
test("CardPicker correctly creates images for each card", () => {
|
test("CardPicker correctly instances images for each card", () => {
|
||||||
const wrapper = shallowMount(CardPicker, {
|
const wrapper = mount(CardPicker, {
|
||||||
propsData: {
|
propsData: {
|
||||||
rows: 2,
|
rows: 2,
|
||||||
columns: 5,
|
columns: 5,
|
||||||
|
@ -20,6 +22,19 @@ describe("components/DeckBuilder/CardPicker", () => {
|
||||||
expect(cards.contains("img")).toBe(true);
|
expect(cards.contains("img")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("CardImage correctly resolves to an URL after a while", async () => {
|
||||||
|
const wrapper = mount(CardImage, {
|
||||||
|
propsData: {
|
||||||
|
id: "sb1"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let src = wrapper.attributes("src");
|
||||||
|
expect(src).toBe(""); // Should be placeholder but it gets stubbed
|
||||||
|
await seconds(0.5);
|
||||||
|
src = wrapper.attributes("src");
|
||||||
|
expect(src).toMatch(/^https?:|^blob:/);
|
||||||
|
});
|
||||||
|
|
||||||
test("CardPicker correctly aligns items in a grid", () => {
|
test("CardPicker correctly aligns items in a grid", () => {
|
||||||
const wrapper = shallowMount(CardPicker, {
|
const wrapper = shallowMount(CardPicker, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
|
Loading…
Reference in a new issue