All files / output zcl_abapgit_gui_css_processor.clas.testclasses.mjs

94.08% Statements 191/203
78.57% Branches 22/28
83.33% Functions 20/24
94.08% Lines 191/203

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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 2031x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 9x 9x 9x 1x 9x 9x 9x 1x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 7x 7x 7x 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 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
const {zcl_abapgit_gui_css_processor} = await import("./zcl_abapgit_gui_css_processor.clas.mjs");
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_gui_css_processor.clas.testclasses.abap
class ltcl_test_base {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_TEST_BASE';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MI_ASSET_MANAGER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_ASSET_MANAGER", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_ASSET_MANAGER"});}, "visibility": "O", "is_constant": " ", "is_class": " "},
  "MO_CUT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_GUI_CSS_PROCESSOR", RTTIName: "\\CLASS=ZCL_ABAPGIT_GUI_CSS_PROCESSOR"});}, "visibility": "O", "is_constant": " ", "is_class": " "}};
  static METHODS = {"SETUP": {"visibility": "I", "parameters": {}},
  "ADD_FILE": {"visibility": "O", "parameters": {"IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_CONTENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "setup": this.#setup.bind(this),
      "add_file": this.add_file.bind(this),
    };
    this.mi_asset_manager = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_ASSET_MANAGER", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_ASSET_MANAGER"});
    this.mo_cut = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_GUI_CSS_PROCESSOR", RTTIName: "\\CLASS=ZCL_ABAPGIT_GUI_CSS_PROCESSOR"});
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async #setup() {
    this.mi_asset_manager.set((await abap.Classes['ZCL_ABAPGIT_GUI_ASSET_MANAGER'].create()));
    this.mo_cut.set(await (new abap.Classes['ZCL_ABAPGIT_GUI_CSS_PROCESSOR']()).constructor_({ii_asset_manager: this.mi_asset_manager}));
  }
  async add_file(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let iv_content = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.iv_content) {iv_content.set(INPUT.iv_content);}
    await this.mi_asset_manager.get().zif_abapgit_gui_asset_manager$register_asset({iv_url: iv_url, iv_type: abap.CharacterFactory.get(8, 'text/css'), iv_inline: iv_content});
  }
}
abap.Classes['CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_TEST_BASE'] = ltcl_test_base;
class ltcl_single_file extends ltcl_test_base {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_SINGLE_FILE';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"TEST_FILE_EXISTS": {"visibility": "U", "parameters": {}},
  "TEST_FILE_DOES_NOT_EXIST": {"visibility": "U", "parameters": {}},
  "TEST_EMPTY_FILE": {"visibility": "U", "parameters": {}},
  "TEST_NO_VARIABLES": {"visibility": "U", "parameters": {}},
  "TEST_SIMPLE_VARIABLES": {"visibility": "U", "parameters": {}},
  "TEST_COMPLEX_VARIABLES": {"visibility": "U", "parameters": {}},
  "TEST_OVERWRITE": {"visibility": "U", "parameters": {}}};
  constructor() {
    const sup = super();
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "SUPER": sup.FRIENDS_ACCESS_INSTANCE,
      "test_file_exists": this.test_file_exists.bind(this),
      "test_file_does_not_exist": this.test_file_does_not_exist.bind(this),
      "test_empty_file": this.test_empty_file.bind(this),
      "test_no_variables": this.test_no_variables.bind(this),
      "test_simple_variables": this.test_simple_variables.bind(this),
      "test_complex_variables": this.test_complex_variables.bind(this),
      "test_overwrite": this.test_overwrite.bind(this),
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async test_file_exists() {
    await this.add_file({iv_url: abap.CharacterFactory.get(14, 'does/exist.css'), iv_content: new abap.types.String().set(`body \{\}\n`)});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(14, 'does/exist.css')});
    try {
      await this.mo_cut.get().process();
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
        await abap.Classes['CL_ABAP_UNIT_ASSERT'].fail();
      } else {
        throw e;
      }
    }
  }
  async test_file_does_not_exist() {
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(16, 'not/existing.css')});
    try {
      await this.mo_cut.get().process();
      await abap.Classes['CL_ABAP_UNIT_ASSERT'].fail();
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
      } else {
        throw e;
      }
    }
  }
  async test_empty_file() {
    await this.add_file({iv_url: abap.CharacterFactory.get(14, 'does/exist.css')});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(14, 'does/exist.css')});
    try {
      await this.mo_cut.get().process();
      await abap.Classes['CL_ABAP_UNIT_ASSERT'].fail();
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
      } else {
        throw e;
      }
    }
  }
  async test_no_variables() {
    let lv_content = new abap.types.String({qualifiedName: "STRING"});
    lv_content.set(abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  font-family: 'Arial', serif;\\n`),abap.operators.concat(new abap.types.String().set(`  background: #000000;\\n`),abap.operators.concat(new abap.types.String().set(`  color: #ffffff;\\n`),new abap.types.String().set(`}\\n`))))));
    await this.add_file({iv_url: abap.CharacterFactory.get(10, 'novars.css'), iv_content: lv_content});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(10, 'novars.css')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_content});
  }
  async test_simple_variables() {
    let lv_content = new abap.types.String({qualifiedName: "STRING"});
    let lv_expected = new abap.types.String({qualifiedName: "STRING"});
    lv_content.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --my-bg-color: #123456;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  font-family: 'Arial', serif;\\n`),abap.operators.concat(new abap.types.String().set(`  background: var(--my-bg-color);\\n`),abap.operators.concat(new abap.types.String().set(`  color: #ffffff;\\n`),new abap.types.String().set(`}\\n`)))))))));
    await this.add_file({iv_url: abap.CharacterFactory.get(10, 'simple.css'), iv_content: lv_content});
    lv_expected.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --my-bg-color: #123456;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  font-family: 'Arial', serif;\\n`),abap.operators.concat(new abap.types.String().set(`  background: #123456;\\n`),abap.operators.concat(new abap.types.String().set(`  color: #ffffff;\\n`),new abap.types.String().set(`}\\n`)))))))));
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(10, 'simple.css')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_expected});
  }
  async test_complex_variables() {
    let lv_content = new abap.types.String({qualifiedName: "STRING"});
    let lv_expected = new abap.types.String({qualifiedName: "STRING"});
    lv_content.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --primary-color: #0099FF;\\n`),abap.operators.concat(new abap.types.String().set(`  --dark-percentage: 15%;\\n`),abap.operators.concat(new abap.types.String().set(`  --primary-color-dark: calc(var(--primary-color) + var(--dark-percentage));\\n`),abap.operators.concat(new abap.types.String().set(`  --my-bg-color: var(--primary-color-dark);\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  font-family: 'Arial', serif;\\n`),abap.operators.concat(new abap.types.String().set(`  background: var(--my-bg-color);\\n`),abap.operators.concat(new abap.types.String().set(`  color: #ffffff;\\n`),new abap.types.String().set(`}\\n`))))))))))));
    await this.add_file({iv_url: abap.CharacterFactory.get(11, 'complex.css'), iv_content: lv_content});
    lv_expected.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --primary-color: #0099FF;\\n`),abap.operators.concat(new abap.types.String().set(`  --dark-percentage: 15%;\\n`),abap.operators.concat(new abap.types.String().set(`  --primary-color-dark: calc(#0099FF + 15%);\\n`),abap.operators.concat(new abap.types.String().set(`  --my-bg-color: calc(#0099FF + 15%);\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  font-family: 'Arial', serif;\\n`),abap.operators.concat(new abap.types.String().set(`  background: calc(#0099FF + 15%);\\n`),abap.operators.concat(new abap.types.String().set(`  color: #ffffff;\\n`),new abap.types.String().set(`}\\n`))))))))))));
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(11, 'complex.css')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_expected});
  }
  async test_overwrite() {
    let lv_content = new abap.types.String({qualifiedName: "STRING"});
    let lv_expected = new abap.types.String({qualifiedName: "STRING"});
    lv_content.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 5;\\n`),abap.operators.concat(new abap.types.String().set(`  --var1: var(--var2);\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: var(--var3);\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 1;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  width: var(--var1);\\n`),new abap.types.String().set(`}\\n`))))))))));
    await this.add_file({iv_url: abap.CharacterFactory.get(13, 'overwrite.css'), iv_content: lv_content});
    lv_expected.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 5;\\n`),abap.operators.concat(new abap.types.String().set(`  --var1: 1;\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: 1;\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 1;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  width: 1;\\n`),new abap.types.String().set(`}\\n`))))))))));
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(13, 'overwrite.css')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_expected});
  }
}
abap.Classes['CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_SINGLE_FILE'] = ltcl_single_file;
class ltcl_multiple_files extends ltcl_test_base {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_MULTIPLE_FILES';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"TEST_SIMPLE": {"visibility": "U", "parameters": {}},
  "TEST_OVERWRITE": {"visibility": "U", "parameters": {}}};
  constructor() {
    const sup = super();
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "SUPER": sup.FRIENDS_ACCESS_INSTANCE,
      "test_simple": this.test_simple.bind(this),
      "test_overwrite": this.test_overwrite.bind(this),
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async test_simple() {
    let lv_file1 = new abap.types.String({qualifiedName: "STRING"});
    let lv_file2 = new abap.types.String({qualifiedName: "STRING"});
    let lv_expected = new abap.types.String({qualifiedName: "STRING"});
    lv_file1.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: var(--var3);\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 6;\\n`),new abap.types.String().set(`}`)))));
    abap.statements.replace({target: lv_file1, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await this.add_file({iv_url: abap.CharacterFactory.get(9, 'file1.css'), iv_content: lv_file1});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(9, 'file1.css')});
    lv_file2.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 19;\\n`),new abap.types.String().set(`}`))));
    abap.statements.replace({target: lv_file2, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await this.add_file({iv_url: abap.CharacterFactory.get(9, 'file2.css'), iv_content: lv_file2});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(9, 'file2.css')});
    lv_expected.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: 19;\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 6;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 19;\\n`),new abap.types.String().set(`}`))))))));
    abap.statements.replace({target: lv_expected, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_expected});
  }
  async test_overwrite() {
    let lv_file1 = new abap.types.String({qualifiedName: "STRING"});
    let lv_file2 = new abap.types.String({qualifiedName: "STRING"});
    let lv_expected = new abap.types.String({qualifiedName: "STRING"});
    lv_file1.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 5;\\n`),abap.operators.concat(new abap.types.String().set(`  --var1: var(--var2);\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: var(--var3);\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 6;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  width: var(--var1);\\n`),new abap.types.String().set(`}\\n`))))))))));
    abap.statements.replace({target: lv_file1, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await this.add_file({iv_url: abap.CharacterFactory.get(9, 'file1.css'), iv_content: lv_file1});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(9, 'file1.css')});
    lv_file2.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 19;\\n`),new abap.types.String().set(`}\\n`))));
    abap.statements.replace({target: lv_file2, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await this.add_file({iv_url: abap.CharacterFactory.get(9, 'file2.css'), iv_content: lv_file2});
    await this.mo_cut.get().add_file({iv_url: abap.CharacterFactory.get(9, 'file2.css')});
    lv_expected.set(abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 5;\\n`),abap.operators.concat(new abap.types.String().set(`  --var1: 19;\\n`),abap.operators.concat(new abap.types.String().set(`  --var2: 19;\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 6;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`body {\\n`),abap.operators.concat(new abap.types.String().set(`  width: 19;\\n`),abap.operators.concat(new abap.types.String().set(`}\\n`),abap.operators.concat(new abap.types.String().set(`\\n`),abap.operators.concat(new abap.types.String().set(`:root {\\n`),abap.operators.concat(new abap.types.String().set(`  --var3: 19;\\n`),new abap.types.String().set(`}\\n`))))))))))))));
    abap.statements.replace({target: lv_expected, all: true, with: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, of: abap.CharacterFactory.get(2, '\\n')});
    await abap.Classes['CL_ABAP_UNIT_ASSERT'].assert_equals({act: (await this.mo_cut.get().process()), exp: lv_expected});
  }
}
abap.Classes['CLAS-ZCL_ABAPGIT_GUI_CSS_PROCESSOR-LTCL_MULTIPLE_FILES'] = ltcl_multiple_files;
export {ltcl_test_base, ltcl_single_file, ltcl_multiple_files};