test: add template tests
This commit is contained in:
parent
0e42f90549
commit
2b0ef07fee
|
|
@ -62,7 +62,12 @@ function removeTemplate(keyName: string | undefined): void {
|
|||
addon.data.template.data?.deleteKey(keyName);
|
||||
}
|
||||
|
||||
function importTemplateFromClipboard(text?: string) {
|
||||
function importTemplateFromClipboard(
|
||||
text?: string,
|
||||
options: {
|
||||
quiet?: boolean;
|
||||
} = {},
|
||||
) {
|
||||
if (!text) {
|
||||
text = Zotero.Utilities.Internal.getClipboard("text/plain") || "";
|
||||
}
|
||||
|
|
@ -83,7 +88,10 @@ function importTemplateFromClipboard(text?: string) {
|
|||
showHint("The copied template is invalid");
|
||||
return;
|
||||
}
|
||||
if (!window.confirm(`Import template "${template.name}"?`)) {
|
||||
if (
|
||||
!options.quiet &&
|
||||
!window.confirm(`Import template "${template.name}"?`)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setTemplate({ name: template.name, text: template.content });
|
||||
|
|
@ -91,4 +99,5 @@ function importTemplateFromClipboard(text?: string) {
|
|||
if (addon.data.template.editor.window) {
|
||||
addon.data.template.editor.window.refresh();
|
||||
}
|
||||
return template.name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { config } from "../../package.json";
|
||||
import { getAddon } from "../utils/global";
|
||||
|
||||
describe("Startup", function () {
|
||||
it("should have plugin instance defined", function () {
|
||||
assert.isNotEmpty(Zotero[config.addonRef]);
|
||||
assert.isNotEmpty(getAddon());
|
||||
});
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,8 @@
|
|||
import { config } from "../../package.json";
|
||||
|
||||
export { getAddon };
|
||||
|
||||
function getAddon(): import("../../src/addon").default {
|
||||
// @ts-ignore - plugin instance
|
||||
return Zotero[config.addonRef];
|
||||
}
|
||||
Loading…
Reference in New Issue