mirror of
https://github.com/decaf-dev/obsidian-vault-explorer.git
synced 2026-07-22 10:10:31 +00:00
110 lines
2.3 KiB
TypeScript
110 lines
2.3 KiB
TypeScript
import {
|
|
isExternalEmbed,
|
|
isInternalEmbed,
|
|
isWikiLink
|
|
} from "src/svelte/app/services/link-utils/link-validators";
|
|
|
|
describe("isWikiLink", () => {
|
|
it("should return false for content without a wiki link", () => {
|
|
//Arrange
|
|
const content = "This is some text";
|
|
|
|
//Act
|
|
const result = isWikiLink(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(false);
|
|
});
|
|
|
|
it("should return true for content with a wiki link", () => {
|
|
//Arrange
|
|
const content = "[[file.jpg]]";
|
|
|
|
//Act
|
|
const result = isWikiLink(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
|
|
it("should return true for content with a wiki link with a paremeter", () => {
|
|
//Arrange
|
|
const content = "[[file.jpg|200]]";
|
|
|
|
//Act
|
|
const result = isWikiLink(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
});
|
|
|
|
describe("isInternalEmbed", () => {
|
|
it("should return false for content without an internal embed", () => {
|
|
//Arrange
|
|
const content = "This is some text";
|
|
|
|
//Act
|
|
const result = isInternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(false);
|
|
});
|
|
|
|
it("should return true for content with an internal embed", () => {
|
|
//Arrange
|
|
const content = "![[file.jpg]]";
|
|
|
|
//Act
|
|
const result = isInternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
|
|
it("should return true for content with an internal embed with a parameter", () => {
|
|
//Arrange
|
|
const content = "![[file.jpg|200]]";
|
|
|
|
//Act
|
|
const result = isInternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
});
|
|
|
|
describe("isExternalEmbed", () => {
|
|
it("should return false for content without an external image embed", () => {
|
|
//Arrange
|
|
const content = "This is some text";
|
|
|
|
//Act
|
|
const result = isExternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(false);
|
|
});
|
|
|
|
it("should return true for content with an external image embed", () => {
|
|
//Arrange
|
|
const content = "";
|
|
|
|
//Act
|
|
const result = isExternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
|
|
it("should return true for content with an external image embed with no alt text", () => {
|
|
//Arrange
|
|
const content = "";
|
|
|
|
//Act
|
|
const result = isExternalEmbed(content);
|
|
|
|
//Assert
|
|
expect(result).toEqual(true);
|
|
});
|
|
});
|