Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuele-cozzi committed Mar 8, 2023
1 parent 7b4959a commit da08b9b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
1 change: 1 addition & 0 deletions tests/__mocks__/obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
32 changes: 16 additions & 16 deletions tests/filePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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);
});

// });
});

0 comments on commit da08b9b

Please sign in to comment.