mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-04 23:19:45 +08:00
start unit testing setup (#872)
This commit is contained in:
parent
5f784c8ed6
commit
b4a79ebe6c
17
.github/workflows/unit.yml
vendored
Normal file
17
.github/workflows/unit.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: unit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- run: npm install
|
||||
- run: npm test
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
node_modules/
|
||||
package-lock.json
|
||||
output
|
||||
foo.zip
|
||||
foo.xlsx
|
||||
foo
|
60
abap_transpile.json
Normal file
60
abap_transpile.json
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"input_folder": "{src,test}",
|
||||
"input_filter": [
|
||||
"src/zcl_excel_a",
|
||||
"src/zcl_excel_c",
|
||||
"src/zcl_excel_d",
|
||||
"src/zcl_excel_fill_template",
|
||||
"src/zcl_excel_font TODO, missing TDFONTSIZE",
|
||||
"src/zcl_excel_g",
|
||||
"src/zcl_excel_h",
|
||||
"src/zcl_excel_l",
|
||||
"src/zcl_excel_o",
|
||||
"src/zcl_excel_r",
|
||||
"src/zcl_excel_s",
|
||||
"src/zcl_excel_t",
|
||||
"src/zcl_excel_w",
|
||||
"src/zcl_excel.clas",
|
||||
"src/zcx_",
|
||||
"src/zexcel_.*doma",
|
||||
"src/zexcel_.*dtel",
|
||||
"src/not_cloud/zexcel_.*dtel",
|
||||
"src/not_cloud/zexcel_.*doma",
|
||||
"src/zexcel_c",
|
||||
"src/zexcel_p",
|
||||
"src/zexcel_s",
|
||||
"src/zexcel_t",
|
||||
"src/zif_",
|
||||
"test/"
|
||||
],
|
||||
"output_folder": "output",
|
||||
"lib": "https://github.com/open-abap/open-abap",
|
||||
"write_unit_tests": true,
|
||||
"write_source_map": true,
|
||||
"options": {
|
||||
"ignoreSyntaxCheck": false,
|
||||
"addFilenames": true,
|
||||
"addCommonJS": true,
|
||||
"unknownTypes": "runtimeError",
|
||||
"skip": [
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_number", "note": "SXML in open-abap currently only handles json, todo"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_shared_string", "note": "SXML in open-abap currently only handles json, todo"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_shared_string_missing", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_inline_string", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_empty_cells", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_boolean", "note": "SXML in open-abap currently only handles json, todo"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_style", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_style_missing", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_formula", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_read_shared_strings", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_shared_string_some_empty", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_shared_string_multi_style", "note": "??"},
|
||||
{"object": "ZCL_EXCEL_READER_HUGE_FILE", "class": "lcl_test", "method": "test_skip_to_inexistent", "note": "??"},
|
||||
|
||||
{"object": "ZCL_EXCEL_WRITER_2007", "class": "ltc_column_formula", "method": "one_column_formula", "note": "?? CALL TRANSFORMATION xml_header = 'no'"},
|
||||
{"object": "ZCL_EXCEL_WRITER_2007", "class": "ltc_column_formula", "method": "two_column_formulas", "note": "??"},
|
||||
|
||||
{"object": "ZCL_EXCEL_COMMON", "class": "lcl_excel_common_test", "method": "convert_column2int_oob_empty", "note": "?? sy value defaults"}
|
||||
]
|
||||
}
|
||||
}
|
16
package.json
Normal file
16
package.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "rm -rf output && abap_transpile abap_transpile.json && echo RUNNING && node output/index.mjs"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/abap2xlsx/abap2xlsx.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@abaplint/cli": "^2.105.14",
|
||||
"@abaplint/transpiler-cli": "^2.7.153",
|
||||
"@abaplint/runtime": "^2.7.153"
|
||||
}
|
||||
}
|
37
test/cl_excel_test.clas.abap
Normal file
37
test/cl_excel_test.clas.abap
Normal file
|
@ -0,0 +1,37 @@
|
|||
CLASS cl_excel_test DEFINITION PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS run
|
||||
RETURNING VALUE(xdata) TYPE xstring
|
||||
RAISING cx_static_check.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS cl_excel_test IMPLEMENTATION.
|
||||
METHOD run.
|
||||
DATA lo_excel TYPE REF TO zcl_excel.
|
||||
DATA lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
DATA lo_hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
DATA lo_column TYPE REF TO zcl_excel_column.
|
||||
DATA lv_date TYPE d.
|
||||
DATA lv_time TYPE t.
|
||||
DATA li_writer TYPE REF TO zif_excel_writer.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lv_date = '20211231'.
|
||||
lv_time = '055817'.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = lv_date ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = lv_time ).
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'https://abap2xlsx.github.io/abap2xlsx' ).
|
||||
lo_worksheet->set_cell( ip_columnrow = 'B4' ip_value = 'Click here to visit abap2xlsx homepage' ip_hyperlink = lo_hyperlink ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = '你好,世界' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = '(Chinese)' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 7 ip_value = 'नमस्ते दुनिया' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 7 ip_value = '(Hindi)' ).
|
||||
lo_column = lo_worksheet->get_column( ip_column = 'B' ).
|
||||
lo_column->set_width( ip_width = 11 ).
|
||||
|
||||
CREATE OBJECT li_writer TYPE zcl_excel_writer_2007.
|
||||
xdata = li_writer->write_file( lo_excel ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
10
test/cl_excel_test.clas.testclasses.abap
Normal file
10
test/cl_excel_test.clas.testclasses.abap
Normal file
|
@ -0,0 +1,10 @@
|
|||
CLASS ltcl DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
|
||||
PUBLIC SECTION.
|
||||
METHODS test FOR TESTING RAISING cx_static_check.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltcl IMPLEMENTATION.
|
||||
METHOD test.
|
||||
cl_excel_test=>run( ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
34
test/mimetypes.tabl.xml
Normal file
34
test/mimetypes.tabl.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_TABL" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<DD02V>
|
||||
<TABNAME>MIMETYPES</TABNAME>
|
||||
<DDLANGUAGE>E</DDLANGUAGE>
|
||||
<TABCLASS>INTTAB</TABCLASS>
|
||||
<DDTEXT>MIMETYPES</DDTEXT>
|
||||
<EXCLASS>1</EXCLASS>
|
||||
</DD02V>
|
||||
<DD03P_TABLE>
|
||||
<DD03P>
|
||||
<FIELDNAME>TYPE</FIELDNAME>
|
||||
<ADMINFIELD>0</ADMINFIELD>
|
||||
<INTTYPE>C</INTTYPE>
|
||||
<INTLEN>000256</INTLEN>
|
||||
<DATATYPE>CHAR</DATATYPE>
|
||||
<LENG>000128</LENG>
|
||||
<MASK> CHAR</MASK>
|
||||
</DD03P>
|
||||
<DD03P>
|
||||
<FIELDNAME>EXTENSION</FIELDNAME>
|
||||
<ADMINFIELD>0</ADMINFIELD>
|
||||
<INTTYPE>C</INTTYPE>
|
||||
<INTLEN>000128</INTLEN>
|
||||
<DATATYPE>CHAR</DATATYPE>
|
||||
<LENG>000064</LENG>
|
||||
<MASK> CHAR</MASK>
|
||||
</DD03P>
|
||||
</DD03P_TABLE>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
9
test/run.mjs
Normal file
9
test/run.mjs
Normal file
|
@ -0,0 +1,9 @@
|
|||
import {initializeABAP} from "../output/init.mjs";
|
||||
import {cl_excel_test} from "../output/cl_excel_test.clas.mjs";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
await initializeABAP();
|
||||
|
||||
const test = new cl_excel_test();
|
||||
const buf = Buffer.from((await test.run()).get().toLowerCase(), "hex");
|
||||
fs.writeFileSync("foo.xlsx", buf);
|
Loading…
Reference in New Issue
Block a user