Skip to content

Commit 54e1f42

Browse files
committed
refactor: standardize code formatting and improve consistency
- Updated various configuration files to use single quotes for strings. - Removed unnecessary trailing commas and improved formatting in JavaScript files. - Enhanced consistency in import statements and object properties across the project. - Cleaned up CSS files for better readability and organization.
1 parent 59a91a5 commit 54e1f42

28 files changed

+677
-765
lines changed

postcss.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
plugins: {
33
tailwindcss: {},
4-
autoprefixer: {},
5-
},
4+
autoprefixer: {}
5+
}
66
};

src/App.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
</template>
3737

3838
<script setup>
39-
import Logo from "@/components/Logo.vue";
40-
import Description from "@/components/Description.vue";
41-
import Slogan from "@/components/Slogan.vue";
42-
import Faq from "@/components/Faq.vue";
43-
import Author from "@/components/Author.vue";
44-
import Ribbon from "@/components/Ribbon.vue";
45-
import Copyright from "@/components/Copyright.vue";
39+
import Logo from '@/components/Logo.vue';
40+
import Description from '@/components/Description.vue';
41+
import Slogan from '@/components/Slogan.vue';
42+
import Faq from '@/components/Faq.vue';
43+
import Author from '@/components/Author.vue';
44+
import Ribbon from '@/components/Ribbon.vue';
45+
import Copyright from '@/components/Copyright.vue';
4646
</script>

src/__tests__/AboutView.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { describe, it, expect } from "vitest";
2-
import { mount } from "@vue/test-utils";
3-
import AboutView from "@/views/AboutView.vue";
1+
import { describe, it, expect } from 'vitest';
2+
import { mount } from '@vue/test-utils';
3+
import AboutView from '@/views/AboutView.vue';
44

5-
describe("AboutView", () => {
6-
it("links to the GitHub repository", () => {
5+
describe('AboutView', () => {
6+
it('links to the GitHub repository', () => {
77
const wrapper = mount(AboutView);
8-
expect(wrapper.text()).toContain("Logoly.pro");
9-
const link = wrapper.get("a");
10-
expect(link.attributes("href")).toBe("https://github.com/bestony/logoly");
11-
expect(link.attributes("target")).toBe("_blank");
8+
expect(wrapper.text()).toContain('Logoly.pro');
9+
const link = wrapper.get('a');
10+
expect(link.attributes('href')).toBe('https://github.com/bestony/logoly');
11+
expect(link.attributes('target')).toBe('_blank');
1212
});
1313
});

src/__tests__/ExportBtn.test.js

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
1-
import {
2-
describe,
3-
it,
4-
expect,
5-
beforeAll,
6-
afterAll,
7-
beforeEach,
8-
vi,
9-
} from "vitest";
10-
import { mount } from "@vue/test-utils";
11-
import { createPinia, setActivePinia } from "pinia";
12-
import ExportBtn from "@/components/ExportBtn.vue";
13-
import { useStore } from "@/stores/store";
1+
import { describe, it, expect, beforeAll, afterAll, beforeEach, vi } from 'vitest';
2+
import { mount } from '@vue/test-utils';
3+
import { createPinia, setActivePinia } from 'pinia';
4+
import ExportBtn from '@/components/ExportBtn.vue';
5+
import { useStore } from '@/stores/store';
146

157
const domToImageMock = vi.hoisted(() => ({
16-
toPng: vi.fn(() => Promise.resolve("data:image/png;base64,mock")),
17-
toSvg: vi.fn(() => Promise.resolve("data:image/svg+xml,mock")),
8+
toPng: vi.fn(() => Promise.resolve('data:image/png;base64,mock')),
9+
toSvg: vi.fn(() => Promise.resolve('data:image/svg+xml,mock'))
1810
}));
1911

2012
const onClickOutsideMock = vi.hoisted(() => vi.fn((_, handler) => handler()));
2113

22-
vi.mock("dom-to-image", () => ({
14+
vi.mock('dom-to-image', () => ({
2315
__esModule: true,
24-
default: domToImageMock,
16+
default: domToImageMock
2517
}));
2618

27-
vi.mock("@vueuse/core", () => ({
28-
onClickOutside: onClickOutsideMock,
19+
vi.mock('@vueuse/core', () => ({
20+
onClickOutside: onClickOutsideMock
2921
}));
30-
describe("ExportBtn", () => {
22+
describe('ExportBtn', () => {
3123
let OriginalImage;
3224
let clickSpy;
3325

@@ -50,9 +42,7 @@ describe("ExportBtn", () => {
5042
this._onload?.();
5143
}
5244
};
53-
clickSpy = vi
54-
.spyOn(window.HTMLAnchorElement.prototype, "click")
55-
.mockImplementation(() => {});
45+
clickSpy = vi.spyOn(window.HTMLAnchorElement.prototype, 'click').mockImplementation(() => {});
5646
});
5747

5848
afterAll(() => {
@@ -71,60 +61,53 @@ describe("ExportBtn", () => {
7161
const mountButton = () => mount(ExportBtn);
7262
const flush = () => new Promise((resolve) => setTimeout(resolve));
7363

74-
it("exports the editable area as PNG", async () => {
64+
it('exports the editable area as PNG', async () => {
7565
const store = useStore();
76-
store.prefix = "Porn";
77-
store.suffix = "hub";
66+
store.prefix = 'Porn';
67+
store.suffix = 'hub';
7868
const wrapper = mountButton();
7969

80-
await wrapper.find('[value="png"]').trigger("click");
81-
expect(domToImageMock.toPng).toHaveBeenCalledWith(
82-
document.getElementById("logo"),
83-
);
70+
await wrapper.find('[value="png"]').trigger('click');
71+
expect(domToImageMock.toPng).toHaveBeenCalledWith(document.getElementById('logo'));
8472

8573
await flush();
8674

8775
expect(store.editable).toBe(true);
8876
expect(onClickOutsideMock).toHaveBeenCalled();
8977
});
9078

91-
it("exports the editable area as SVG", async () => {
79+
it('exports the editable area as SVG', async () => {
9280
const store = useStore();
93-
store.prefix = "Only";
94-
store.suffix = "Fans";
81+
store.prefix = 'Only';
82+
store.suffix = 'Fans';
9583
const wrapper = mountButton();
9684

97-
await wrapper.find('[value="svg"]').trigger("click");
98-
expect(domToImageMock.toSvg).toHaveBeenCalledWith(
99-
document.getElementById("logo"),
100-
);
85+
await wrapper.find('[value="svg"]').trigger('click');
86+
expect(domToImageMock.toSvg).toHaveBeenCalledWith(document.getElementById('logo'));
10187

10288
await flush();
10389

10490
expect(clickSpy).toHaveBeenCalled();
10591
expect(store.editable).toBe(true);
10692
});
10793

108-
it("skips exporting when the logo node is missing", async () => {
109-
document.body.innerHTML = "";
94+
it('skips exporting when the logo node is missing', async () => {
95+
document.body.innerHTML = '';
11096
setActivePinia(createPinia());
11197
const wrapper = mountButton();
11298

113-
await wrapper.find('[value="png"]').trigger("click");
99+
await wrapper.find('[value="png"]').trigger('click');
114100

115101
expect(domToImageMock.toPng).not.toHaveBeenCalled();
116102
});
117103

118-
it("falls back to the default filename when none is provided", () => {
119-
const dispatchSpy = vi.spyOn(
120-
window.HTMLAnchorElement.prototype,
121-
"dispatchEvent",
122-
);
104+
it('falls back to the default filename when none is provided', () => {
105+
const dispatchSpy = vi.spyOn(window.HTMLAnchorElement.prototype, 'dispatchEvent');
123106
const wrapper = mountButton();
124107
const { downloadImage } = wrapper.vm.$.setupState;
125108

126-
expect(typeof downloadImage).toBe("function");
127-
downloadImage("data:image/png;base64,stub");
109+
expect(typeof downloadImage).toBe('function');
110+
downloadImage('data:image/png;base64,stub');
128111

129112
expect(dispatchSpy).toHaveBeenCalled();
130113
dispatchSpy.mockRestore();
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
import { describe, it, expect, beforeEach, vi } from "vitest";
2-
import { mount } from "@vue/test-utils";
3-
import { defineComponent } from "vue";
4-
import { createPinia, setActivePinia } from "pinia";
5-
import FontSelector from "@/components/FontSelector.vue";
6-
import { useStore } from "@/stores/store";
7-
import { loadGoogleFont } from "@/utils/fontLoader";
1+
import { describe, it, expect, beforeEach, vi } from 'vitest';
2+
import { mount } from '@vue/test-utils';
3+
import { defineComponent } from 'vue';
4+
import { createPinia, setActivePinia } from 'pinia';
5+
import FontSelector from '@/components/FontSelector.vue';
6+
import { useStore } from '@/stores/store';
7+
import { loadGoogleFont } from '@/utils/fontLoader';
88

9-
vi.mock("@/utils/fontLoader", () => ({
10-
loadGoogleFont: vi.fn(),
9+
vi.mock('@/utils/fontLoader', () => ({
10+
loadGoogleFont: vi.fn()
1111
}));
1212

1313
const VSelectStub = defineComponent({
14-
name: "VSelectStub",
14+
name: 'VSelectStub',
1515
props: {
1616
modelValue: {
1717
type: String,
18-
default: "",
18+
default: ''
1919
},
2020
items: {
2121
type: Array,
22-
default: () => [],
23-
},
22+
default: () => []
23+
}
2424
},
25-
emits: ["update:modelValue"],
25+
emits: ['update:modelValue'],
2626
template: `<select class="v-select-stub" :value="modelValue" @change="$emit('update:modelValue', $event.target.value)">
2727
<option v-for="option in items" :key="option" :value="option">{{ option }}</option>
28-
</select>`,
28+
</select>`
2929
});
3030

31-
describe("FontSelector component", () => {
31+
describe('FontSelector component', () => {
3232
beforeEach(() => {
3333
setActivePinia(createPinia());
3434
vi.clearAllMocks();
3535
});
3636

37-
it("loads the current font immediately and on selection changes", async () => {
37+
it('loads the current font immediately and on selection changes', async () => {
3838
const wrapper = mount(FontSelector, {
3939
global: {
4040
stubs: {
41-
"v-select": VSelectStub,
42-
},
43-
},
41+
'v-select': VSelectStub
42+
}
43+
}
4444
});
4545
const store = useStore();
4646

4747
expect(loadGoogleFont).toHaveBeenCalledTimes(1);
4848
expect(loadGoogleFont).toHaveBeenCalledWith(store.font);
4949

5050
loadGoogleFont.mockClear();
51-
const select = wrapper.get("select");
52-
await select.setValue("Lora");
51+
const select = wrapper.get('select');
52+
await select.setValue('Lora');
5353

5454
expect(loadGoogleFont).toHaveBeenCalledTimes(1);
55-
expect(loadGoogleFont).toHaveBeenCalledWith("Lora");
56-
expect(wrapper.html()).toContain("Font");
55+
expect(loadGoogleFont).toHaveBeenCalledWith('Lora');
56+
expect(wrapper.html()).toContain('Font');
5757
});
5858
});

src/__tests__/fontLoader.test.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
import { describe, it, expect, beforeEach, vi } from "vitest";
1+
import { describe, it, expect, beforeEach, vi } from 'vitest';
22

33
const loadModule = async () => {
44
vi.resetModules();
5-
const module = await import("@/utils/fontLoader.js");
5+
const module = await import('@/utils/fontLoader.js');
66
return module;
77
};
88

9-
describe("loadGoogleFont", () => {
9+
describe('loadGoogleFont', () => {
1010
beforeEach(() => {
11-
document.head.innerHTML = "";
11+
document.head.innerHTML = '';
1212
});
1313

14-
it("creates a preload link and converts it to stylesheet on load", async () => {
14+
it('creates a preload link and converts it to stylesheet on load', async () => {
1515
const { loadGoogleFont } = await loadModule();
16-
loadGoogleFont(" Roboto ");
17-
const link = document.head.querySelector("link");
16+
loadGoogleFont(' Roboto ');
17+
const link = document.head.querySelector('link');
1818
expect(link).toBeTruthy();
19-
expect(link.rel).toBe("preload");
20-
expect(link.href).toContain("Roboto");
19+
expect(link.rel).toBe('preload');
20+
expect(link.href).toContain('Roboto');
2121

2222
link.onload();
23-
expect(link.rel).toBe("stylesheet");
23+
expect(link.rel).toBe('stylesheet');
2424
});
2525

26-
it("avoids duplicate requests while a font is pending or already loaded", async () => {
26+
it('avoids duplicate requests while a font is pending or already loaded', async () => {
2727
const { loadGoogleFont } = await loadModule();
28-
loadGoogleFont("Lora");
29-
loadGoogleFont("Lora");
30-
expect(document.head.querySelectorAll("link").length).toBe(1);
28+
loadGoogleFont('Lora');
29+
loadGoogleFont('Lora');
30+
expect(document.head.querySelectorAll('link').length).toBe(1);
3131

32-
const [first] = document.head.querySelectorAll("link");
32+
const [first] = document.head.querySelectorAll('link');
3333
first.onload();
34-
loadGoogleFont("Lora");
35-
expect(document.head.querySelectorAll("link").length).toBe(1);
34+
loadGoogleFont('Lora');
35+
expect(document.head.querySelectorAll('link').length).toBe(1);
3636
});
3737

38-
it("retries after an error by cleaning the pending state", async () => {
38+
it('retries after an error by cleaning the pending state', async () => {
3939
const { loadGoogleFont } = await loadModule();
40-
loadGoogleFont("Inter");
41-
let link = document.head.querySelector("link");
40+
loadGoogleFont('Inter');
41+
let link = document.head.querySelector('link');
4242
expect(link).toBeTruthy();
4343
link.onerror();
44-
expect(document.head.querySelector("link")).toBeNull();
44+
expect(document.head.querySelector('link')).toBeNull();
4545

46-
loadGoogleFont("Inter");
47-
link = document.head.querySelector("link");
46+
loadGoogleFont('Inter');
47+
link = document.head.querySelector('link');
4848
expect(link).toBeTruthy();
4949
});
5050

51-
it("no-ops when the DOM is unavailable", async () => {
51+
it('no-ops when the DOM is unavailable', async () => {
5252
const originalWindow = globalThis.window;
5353
const originalDocument = globalThis.document;
5454
vi.resetModules();
@@ -57,8 +57,8 @@ describe("loadGoogleFont", () => {
5757
globalThis.window = undefined;
5858
// @ts-expect-error override for test
5959
globalThis.document = undefined;
60-
const { loadGoogleFont } = await import("@/utils/fontLoader.js");
61-
expect(() => loadGoogleFont("Roboto")).not.toThrow();
60+
const { loadGoogleFont } = await import('@/utils/fontLoader.js');
61+
expect(() => loadGoogleFont('Roboto')).not.toThrow();
6262
} finally {
6363
globalThis.window = originalWindow;
6464
globalThis.document = originalDocument;

src/__tests__/fontsConfig.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { describe, it, expect } from "vitest";
2-
import { fonts } from "@/config/fonts";
1+
import { describe, it, expect } from 'vitest';
2+
import { fonts } from '@/config/fonts';
33

4-
describe("fonts config", () => {
5-
it("exports a de-duplicated, trimmed list", () => {
4+
describe('fonts config', () => {
5+
it('exports a de-duplicated, trimmed list', () => {
66
expect(fonts.length).toBe(new Set(fonts).size);
77
expect(fonts.every((font) => font === font.trim())).toBe(true);
8-
expect(fonts).toContain("Roboto");
9-
expect(fonts).not.toContain("Roboto ");
8+
expect(fonts).toContain('Roboto');
9+
expect(fonts).not.toContain('Roboto ');
1010
});
1111
});

0 commit comments

Comments
 (0)