@@ -4,57 +4,53 @@ import { TemplateKind } from 'myst-common';
44import MystTemplate , { downloadTemplate , resolveInputs , Session } from 'myst-templates' ;
55import { renderTemplate } from '../src' ;
66
7- describe (
8- 'Download Template' ,
9- ( ) => {
10- it ( 'Download default template' , async ( ) => {
11- const session = new Session ( ) ;
12- const inputs = resolveInputs ( session , { buildDir : '_build' , kind : TemplateKind . tex } ) ;
13- await downloadTemplate ( session , {
14- templatePath : inputs . templatePath ,
15- templateUrl : inputs . templateUrl as string ,
16- } ) ;
17- expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.zip' ) ) . toBe ( true ) ;
18- expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.yml' ) ) . toBe ( true ) ;
19- expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.tex' ) ) . toBe ( true ) ;
7+ describe ( 'Download Template' , { timeout : 15000 } , ( ) => {
8+ it ( 'Download default template' , async ( ) => {
9+ const session = new Session ( ) ;
10+ const inputs = resolveInputs ( session , { buildDir : '_build' , kind : TemplateKind . tex } ) ;
11+ await downloadTemplate ( session , {
12+ templatePath : inputs . templatePath ,
13+ templateUrl : inputs . templateUrl as string ,
2014 } ) ;
21- it ( 'Bad template paths to throw' , async ( ) => {
22- const jtex = new MystTemplate ( new Session ( ) , {
23- template : 'not-there' ,
24- kind : TemplateKind . tex ,
25- } ) ;
26- expect ( ( ) => jtex . prepare ( { } as any ) ) . toThrow ( / d o e s n o t e x i s t / ) ;
15+ expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.zip' ) ) . toBe ( true ) ;
16+ expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.yml' ) ) . toBe ( true ) ;
17+ expect ( fs . existsSync ( '_build/templates/tex/myst/plain_latex/template.tex' ) ) . toBe ( true ) ;
18+ } ) ;
19+ it ( 'Bad template paths to throw' , async ( ) => {
20+ const jtex = new MystTemplate ( new Session ( ) , {
21+ template : 'not-there' ,
22+ kind : TemplateKind . tex ,
2723 } ) ;
28- it ( 'Render out the template' , async ( ) => {
29- const jtex = new MystTemplate ( new Session ( ) , {
30- kind : TemplateKind . tex ,
31- template : `${ __dirname } /example` ,
32- } ) ;
33- renderTemplate ( jtex , {
34- contentOrPath : `${ __dirname } /test.tex` ,
35- outputPath : '_build/out/article.tex' ,
36- frontmatter : {
37- title : 'test' ,
38- description : 'test' ,
39- date : new Date ( 2022 , 6 , 22 ) . toISOString ( ) ,
40- authors : [
41- { name : 'Rowan Cockett' , affiliations : [ 'Curvenote' ] } ,
42- { name : 'Steve Purves' , affiliations : [ 'Curvenote' ] , orcid : '0000' } ,
43- ] ,
44- } ,
45- options : {
46- keywords : '' ,
47- } ,
48- parts : {
49- abstract : 'My abstract!' ,
50- } ,
51- } ) ;
52- expect ( fs . existsSync ( '_build/out/article.tex' ) ) . toBe ( true ) ;
53- const content = fs . readFileSync ( '_build/out/article.tex' ) . toString ( ) ;
54- expect ( content . includes ( 'Volcanic Archipelago' ) ) . toBe ( true ) ;
55- expect ( content . includes ( 'Rowan Cockett' ) ) . toBe ( true ) ;
56- expect ( content . includes ( 'My abstract!' ) ) . toBe ( true ) ;
24+ expect ( ( ) => jtex . prepare ( { } as any ) ) . toThrow ( / d o e s n o t e x i s t / ) ;
25+ } ) ;
26+ it ( 'Render out the template' , async ( ) => {
27+ const jtex = new MystTemplate ( new Session ( ) , {
28+ kind : TemplateKind . tex ,
29+ template : `${ __dirname } /example` ,
5730 } ) ;
58- } ,
59- { timeout : 15000 } ,
60- ) ;
31+ renderTemplate ( jtex , {
32+ contentOrPath : `${ __dirname } /test.tex` ,
33+ outputPath : '_build/out/article.tex' ,
34+ frontmatter : {
35+ title : 'test' ,
36+ description : 'test' ,
37+ date : new Date ( 2022 , 6 , 22 ) . toISOString ( ) ,
38+ authors : [
39+ { name : 'Rowan Cockett' , affiliations : [ 'Curvenote' ] } ,
40+ { name : 'Steve Purves' , affiliations : [ 'Curvenote' ] , orcid : '0000' } ,
41+ ] ,
42+ } ,
43+ options : {
44+ keywords : '' ,
45+ } ,
46+ parts : {
47+ abstract : 'My abstract!' ,
48+ } ,
49+ } ) ;
50+ expect ( fs . existsSync ( '_build/out/article.tex' ) ) . toBe ( true ) ;
51+ const content = fs . readFileSync ( '_build/out/article.tex' ) . toString ( ) ;
52+ expect ( content . includes ( 'Volcanic Archipelago' ) ) . toBe ( true ) ;
53+ expect ( content . includes ( 'Rowan Cockett' ) ) . toBe ( true ) ;
54+ expect ( content . includes ( 'My abstract!' ) ) . toBe ( true ) ;
55+ } ) ;
56+ } ) ;
0 commit comments