-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now automatically includes file with same name as folder when mdinclu…
…de'ing a directory
- Loading branch information
blitzher
committed
Apr 24, 2024
1 parent
ff6b4f1
commit 4f3b6fd
Showing
7 changed files
with
96 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
const util = require("./tester.test.js"); | ||
|
||
util.put( | ||
"module.exports = {main: (new_template, new_command) => {new_template('hi', 'hello'); new_command(/#test_cmd/, (t,p) => 'yeet', 0);}};", | ||
"extensions.js" | ||
); | ||
const putTemplate = () => { | ||
util.put( | ||
"module.exports = {main: (new_template, new_command) => {new_template('hi', 'hello'); new_command(/#test_cmd/, (t,p) => 'yeet', 0);}};", | ||
"extensions.js" | ||
); | ||
}; | ||
|
||
describe("Use of templates", () => { | ||
beforeEach(putTemplate); | ||
it("should import presentation template as expected", () => { | ||
putTemplate(); | ||
const output = new util.Parser("#mdtemplate<presentation>").get(); | ||
const template = `<style>html {width: 100vw;height: 100vh;}.slide {padding: 5%;border-radius: 25px;margin: 0;}div > .slide-num {position: absolute;top: 12.5%;right: 15%;/* font-size: 150%; */}body {margin: 5% 15%;}img {max-width: 100%;max-height: 40vh;}</style><script>document.addEventListener("DOMContentLoaded", () => {let current_slide = 0;const all_slides = document.querySelectorAll("div.slide");const num_slides = all_slides.length;all_slides.forEach((slide) => {const num_elem = document.createElement("p");num_elem.classList.add("slide-num");slide.appendChild(num_elem);});onkeydown = (ev) => {if (ev.key == "ArrowRight" && current_slide < all_slides.length - 1)update_slide(++current_slide);else if (ev.key == "ArrowLeft" && current_slide > 0)update_slide(--current_slide);};const update_slide = (index) => {all_slides.forEach((slide) => (slide.style.display = "none"));all_slides[current_slide].style.display = "block";all_slides[current_slide].lastChild.textContent = \`\${current_slide + 1} / \${num_slides}\`;};update_slide(current_slide);});</script>`; | ||
|
||
util.assert.strictEqual(output, template + "\n\n"); | ||
}); | ||
|
||
it("should use custom templates from project extensions.js file", () => { | ||
putTemplate(); | ||
util.put("#mdtemplate<hi>", "sample1.md"); | ||
|
||
util.assert.strictEqual( | ||
new util.Parser("test/test-files/sample1.md").get(), | ||
"hello\n\n" | ||
); | ||
|
||
/* make sure to remove after, to not mess with future tests */ | ||
}); | ||
|
||
it("should use custom commands from project extensions.js file", () => { | ||
putTemplate(); | ||
util.put("#test_cmd", "sample1.md"); | ||
|
||
const parser = new util.Parser("test/test-files/sample1.md"); | ||
util.assert.strictEqual(parser.get(), "yeet\n\n"); | ||
|
||
/* make sure to remove after, to not mess with future tests */ | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const fs = require("fs"); | ||
|
||
exports.mochaHooks = { | ||
beforeEach(done) { | ||
fs.rmdirSync("test/test-files", { recursive: true }); | ||
fs.mkdirSync("test/test-files"); | ||
done(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters