@@ -2,7 +2,7 @@ const { readFileSync } = require("fs");
22
33const { run } = require ( "." ) ;
44
5- it ( "Smoke test" , ( ) => {
5+ it ( "smoke test" , ( ) => {
66 expect ( run ) . toBeDefined ( ) ;
77 expect ( typeof run ) . toBe ( "function" ) ;
88} ) ;
@@ -56,3 +56,53 @@ it("readme example", () => {
5656
5757 run ( env , eventPayload , fs , core ) ;
5858} ) ;
59+
60+ it ( "multiple paragraphs" , ( ) => {
61+ const expectedOutput = require ( "./fixtures/multiple-paragraphs/expected.json" ) ;
62+ const expectedOutputJson = JSON . stringify ( expectedOutput , null , 2 ) ;
63+
64+ // mock ENV
65+ const env = {
66+ HOME : "<home path>" ,
67+ } ;
68+
69+ // mock event payload
70+ const eventPayload = require ( "./fixtures/multiple-paragraphs/issue" ) ;
71+
72+ // mock fs
73+ const fs = {
74+ readFileSync ( path , encoding ) {
75+ expect ( path ) . toBe ( "<template-path>" ) ;
76+ expect ( encoding ) . toBe ( "utf8" ) ;
77+ return readFileSync ( "fixtures/multiple-paragraphs/form.yml" , "utf-8" ) ;
78+ } ,
79+ writeFileSync ( path , content ) {
80+ expect ( path ) . toBe ( "<home path>/issue-parser-result.json" ) ;
81+ expect ( content ) . toBe ( expectedOutputJson ) ;
82+ } ,
83+ } ;
84+
85+ // mock core
86+ const core = {
87+ getInput ( inputName ) {
88+ expect ( inputName ) . toBe ( "template-path" ) ;
89+ return "<template-path>" ;
90+ } ,
91+ setOutput ( outputName , outputValue ) {
92+ if ( outputName === "jsonString" ) {
93+ expect ( outputValue ) . toBe ( expectedOutputJson ) ;
94+ return ;
95+ }
96+
97+ if ( outputName . startsWith ( "issueparser_" ) ) {
98+ const key = outputName . substr ( "issueparser_" . length ) ;
99+ expect ( Object . keys ( expectedOutput ) ) . toContain ( key ) ;
100+
101+ expect ( outputValue ) . toBe ( expectedOutput [ key ] ) ;
102+ return ;
103+ }
104+ } ,
105+ } ;
106+
107+ run ( env , eventPayload , fs , core ) ;
108+ } ) ;
0 commit comments