11import { describe , expect , it } from '@rstest/core' ;
2- import { GroovyScriptConvertorUtil } from "@/components/script/utils/convertor " ;
2+ import { GroovyScriptConvertorUtil } from "@/groovy " ;
33
44describe ( 'GroovyScriptUtil' , ( ) => {
55
@@ -54,7 +54,7 @@ def run(request){
5454 } ) ;
5555
5656
57- describe ( 'getScriptMeta ' , ( ) => {
57+ describe ( 'getScriptMeta1 ' , ( ) => {
5858 it ( 'get groovy script meta' , ( ) => {
5959 const script = `
6060// @SCRIPT_TITLE 这是一个实例的标题
@@ -67,8 +67,21 @@ def run(request){
6767 } ) ;
6868 } ) ;
6969
70+ describe ( 'getScriptMeta2' , ( ) => {
71+ it ( 'get groovy script meta' , ( ) => {
72+ const script = `
73+ // @CUSTOM_SCRIPT 自定义脚本,返回的数据为动作类型
74+ // @SCRIPT_META {"trigger":"PASS"}
75+ def run(request){
76+ return 'SAVE';
77+ }`
78+ const result = GroovyScriptConvertorUtil . getScriptMeta ( script )
79+ expect ( result ) . toEqual ( `{"trigger":"PASS"}` ) ;
80+ } ) ;
81+ } ) ;
7082
71- describe ( 'updateScriptMeta' , ( ) => {
83+
84+ describe ( 'updateScriptMeta1' , ( ) => {
7285 it ( 'update groovy script meta' , ( ) => {
7386 const script = `
7487// @SCRIPT_TITLE 这是一个实例的标题
@@ -82,4 +95,19 @@ def run(request){
8295 expect ( title ) . toEqual ( `{name:"test"}` ) ;
8396 } ) ;
8497 } ) ;
98+
99+ describe ( 'updateScriptMeta2' , ( ) => {
100+ it ( 'update groovy script meta' , ( ) => {
101+ const script = `
102+ // @CUSTOM_SCRIPT 自定义脚本,返回的数据为动作类型
103+ // @SCRIPT_META {"trigger":"PASS"}
104+ def run(request){
105+ return 'SAVE';
106+ }`
107+ const result = GroovyScriptConvertorUtil . updateScriptMeta ( script , '{trigger:"SAVE"}' ) ;
108+ console . log ( result ) ;
109+ const title = GroovyScriptConvertorUtil . getScriptMeta ( result )
110+ expect ( title ) . toEqual ( `{trigger:"SAVE"}` ) ;
111+ } ) ;
112+ } ) ;
85113} ) ;
0 commit comments