style: fix linting issues met Prettier
This commit is contained in:
parent
3a68fb3913
commit
5edf23c767
7 changed files with 35 additions and 24 deletions
|
@ -14,7 +14,5 @@
|
|||
* <img :src="convertBase64ToImageSrc(base64String)" alt="Learning Path Image" />
|
||||
*/
|
||||
export function convertBase64ToImageSrc(base64String: string): string {
|
||||
return base64String.startsWith("data:image")
|
||||
? base64String
|
||||
: `data:image/png;base64,${base64String}`;
|
||||
return base64String.startsWith("data:image") ? base64String : `data:image/png;base64,${base64String}`;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import { convertBase64ToImageSrc } from '../../src/utils/base64ToImage.js';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { describe, it, expect, beforeAll } from "vitest";
|
||||
import { convertBase64ToImageSrc } from "../../src/utils/base64ToImage.js";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
let sampleBase64: string;
|
||||
|
||||
beforeAll(() => {
|
||||
// Load base64 sample from text file
|
||||
const filePath = path.resolve(__dirname, 'base64Sample.txt');
|
||||
sampleBase64 = fs.readFileSync(filePath, 'utf8').trim();
|
||||
const filePath = path.resolve(__dirname, "base64Sample.txt");
|
||||
sampleBase64 = fs.readFileSync(filePath, "utf8").trim();
|
||||
});
|
||||
|
||||
describe('convertBase64ToImageSrc', () => {
|
||||
it('should return the same string if it is already a valid data URL', () => {
|
||||
describe("convertBase64ToImageSrc", () => {
|
||||
it("should return the same string if it is already a valid data URL", () => {
|
||||
const base64Image = `data:image/png;base64,${sampleBase64}`;
|
||||
expect(convertBase64ToImageSrc(base64Image)).toBe(base64Image);
|
||||
});
|
||||
|
||||
it('should correctly format a raw Base64 string as a PNG image URL', () => {
|
||||
it("should correctly format a raw Base64 string as a PNG image URL", () => {
|
||||
expect(convertBase64ToImageSrc(sampleBase64)).toBe(`data:image/png;base64,${sampleBase64}`);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue