fix: unit tests

This commit is contained in:
samuele-cozzi 2023-03-08 14:51:43 +01:00
parent 7b4959adb5
commit da08b9b122
3 changed files with 18 additions and 17 deletions

View file

@ -6,7 +6,7 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/78932986b29ffe273e56/maintainability)](https://codeclimate.com/github/samuele-cozzi/obsidian-marp-slides/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/78932986b29ffe273e56/test_coverage)](https://codeclimate.com/github/samuele-cozzi/obsidian-marp-slides/test_coverage)
[![LICENSE](https://img.shields.io/github/license/samuele-cozzi/obsidian-marp-slides)](https://github.com/samuele-cozzi/obsidian-marp-slides/blob/main/LICENSE)
![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian&color=%23483699&label=downloads&query=%24%5B%22better-word-count%22%5D.downloads&url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json&style=for-the-badge)
<!-- ![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian&color=%23483699&label=downloads&query=%24%5B%22better-word-count%22%5D.downloads&url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json&style=for-the-badge) -->
Marp Slides is very simple & powerful slide deck extension for [Obsidian](href="https://obsidian.md") based on [Marp](https://marp.app/)

View file

@ -31,6 +31,7 @@ export const normalizePath = jest.fn().mockImplementation((str: string) => {
function normalize (path: string) {
if (typeof path !== 'string') {
console.log(path);
throw new TypeError('expected path to be a string');
}

View file

@ -13,8 +13,8 @@ test('file base path', () => {
const filePath = new FilePath(DEFAULT_SETTINGS);
const tests : pathsUtility[] = [
{ base: "aaa", relative: "bbb", expected: "aaa/bbb/"}//,
//{ base: "C:\\user\\foo\\vault", relative: "\\folder\\file", expected: "C:\\user\\foo\\vault\\folder\\file\\"},
{ base: "aaa", relative: "bbb", expected: "app://local/aaa/bbb/"},
{ base: "C:\\user\\foo\\vault", relative: "folder\\file", expected: "app://local/C:/user/foo/vault/folder/file/"},
];
tests.forEach(element => {
@ -30,23 +30,23 @@ test('file base path', () => {
});
// test('file path', () => {
test('file path', () => {
// const filePath = new FilePath(DEFAULT_SETTINGS);
// const tests : pathsUtility[] = [
// { base: "aaa", relative: "bbb.md", expected: "aaa/bbb.md"},
// { base: "C:\\user\\foo\\vault", relative: "\\folder\\file.md", expected: "C:\\user\\foo\\vault\\folder\\file.md"},
// ];
const filePath = new FilePath(DEFAULT_SETTINGS);
const tests : pathsUtility[] = [
{ base: "aaa", relative: "bbb.md", expected: "aaa/bbb.md"},
{ base: "C:\\user\\foo\\vault", relative: "folder\\file.md", expected: "C:/user/foo/vault/folder/file.md"},
];
// tests.forEach(element => {
// const file = new TFile;
tests.forEach(element => {
const file = new TFile;
// file.parent.path = element.relative;
// file.vault.adapter.write(element.base, '');
file.path = element.relative;
file.vault.adapter.write(element.base, '');
// const result = filePath.getCompleteFilePath(file);
const result = filePath.getCompleteFilePath(file);
// expect(result).toBe(element.expected);
// });
expect(result).toBe(element.expected);
});
// });
});