Execute option declarations in local packages
This commit is contained in:
1 parent
9b44d68440
commit
00f95fdd09
5 files changed
+97
-54
No files matched your search
@@ -392,6 +392,64 @@ fn project_preview_uses_the_engine_default() {
|
||||
assert!(svg.contains("TexrraSerif"), "{svg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_executes_local_package_options() {
|
||||
let server = TestServer::start("route-d-package-options");
|
||||
let style = "\\ProvidesPackage{mystyle}\n\\DeclareOption{shout}{\\newcommand{\\loudword}{QZ}}\n\\ProcessOptions\n\\newcommand{\\plainword}{JK}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=mystyle.sty",
|
||||
style.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let document = "\\documentclass{article}\n\\usepackage[shout]{mystyle}\n\\begin{document}\nBody \\loudword{} \\plainword.\n\\end{document}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
document.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let text = preview.text();
|
||||
for character in ["Q", "Z", "J", "K"] {
|
||||
assert!(
|
||||
text.contains(&format!(">{character}</text>")),
|
||||
"missing {character}: {text}"
|
||||
);
|
||||
}
|
||||
assert!(!text.contains("DeclareOption"), "{text}");
|
||||
|
||||
let plain = "\\documentclass{article}\n\\usepackage{mystyle}\n\\begin{document}\nBody \\plainword.\n\\end{document}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
plain.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let text = preview.text();
|
||||
assert!(
|
||||
text.contains(">J</text>") && text.contains(">K</text>"),
|
||||
"{text}"
|
||||
);
|
||||
assert!(!text.contains(">Q</text>"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_loads_local_base_classes() {
|
||||
let server = TestServer::start("route-d-base-class");
|
||||
|
||||
Reference in new issue
Block a user