All files / src/ui/lib zcl_abapgit_html_form.clas.testclasses.abap

100% Statements 71/71
100% Branches 5/5
100% Functions 5/5
100% Lines 71/71

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 721x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
CLASS ltcl_webgui_actions DEFINITION DEFERRED.
CLASS zcl_abapgit_html_form DEFINITION LOCAL FRIENDS ltcl_webgui_actions.
 
CLASS ltcl_webgui_actions DEFINITION FINAL FOR TESTING
  DURATION SHORT RISK LEVEL HARMLESS.
 
  PRIVATE SECTION.
    DATA mo_form TYPE REF TO zcl_abapgit_html_form.
    DATA mi_html TYPE REF TO zif_abapgit_html.
 
    METHODS setup.
    METHODS command_marker FOR TESTING.
    METHODS picker_marker FOR TESTING.
 
ENDCLASS.
 
CLASS ltcl_webgui_actions IMPLEMENTATION.
 
  METHOD setup.
    CREATE OBJECT mo_form.
    mo_form->mv_webgui = abap_true.
    mo_form->mv_form_id = 'test_form'.
    mi_html = zcl_abapgit_html=>create( ).
  ENDMETHOD.
 
  METHOD command_marker.
    DATA ls_command TYPE zif_abapgit_html_form=>ty_command.
    DATA lv_html TYPE string.
 
    ls_command-label = 'Save'.
    ls_command-action = 'save?key=1&name=example'.
    ls_command-cmd_type = zif_abapgit_html_form=>c_cmd_type-input_main.
    mo_form->render_command(
      ii_html = mi_html
      is_cmd  = ls_command ).
    lv_html = mi_html->render( ).
 
    cl_abap_unit_assert=>assert_char_cp(
      act = lv_html
      exp = '*data-sapevent="save?key=1&name=example"*' ).
    cl_abap_unit_assert=>assert_char_cp(
      act = lv_html
      exp = |*submitSapeventForm(\{ \}, this.getAttribute('data-sapevent'), 'post', *| ).
    cl_abap_unit_assert=>assert_char_cp(
      act = lv_html
      exp = '*class="dialog-commands main">Save</a>*' ).
  ENDMETHOD.
 
  METHOD picker_marker.
    DATA ls_field TYPE zif_abapgit_html_form=>ty_field.
    DATA ls_attr TYPE zcl_abapgit_html_form=>ty_attr.
    DATA lv_html TYPE string.
 
    ls_field-name = 'package'.
    ls_field-label = 'Package'.
    ls_field-side_action = 'choose_package'.
    mo_form->render_field_text(
      ii_html  = mi_html
      is_field = ls_field
      is_attr  = ls_attr ).
    lv_html = mi_html->render( ).
 
    cl_abap_unit_assert=>assert_char_cp(
      act = lv_html
      exp = '*type="button"*data-sapevent="choose_package"*' ).
    cl_abap_unit_assert=>assert_char_cp(
      act = lv_html
      exp = |*submitSapeventForm(\{ \}, this.getAttribute('data-sapevent'), 'post', *| ).
  ENDMETHOD.
 
ENDCLASS.