lowlighter/libs

Improve test coverage

Closed this issue · 0 comments

While the test coverage is pretty good, there are still some cases that needs to be covered, like below:

cover file:///home/runner/work/xml/xml/mod.ts ... 100.000% (3/3)
cover file:///home/runner/work/xml/xml/parse.ts ... 100.000% (9/9)
cover file:///home/runner/work/xml/xml/stringify.ts ... 100.000% (4/4)
cover file:///home/runner/work/xml/xml/utils/parser.ts ... 91.228% (312/342)
  30 |       console.debug(`${path.map((node) => node[$XML].name).join(" > ")} | ${string}`.trim());
-----|-----
  49 |         if (this.#peek(tokens.comment.start)) {
  50 |           clean = false;
  51 |           comments.push(this.#comment({ path }));
  52 |           continue;
  53 |         }
-----|-----
  57 |           if (document.xml) {
  58 |             throw new SyntaxError("Multiple prolog declaration found");
  59 |           }
-----|-----
  65 |           if (document.doctype) {
  66 |             throw new SyntaxError("Multiple doctype declaration found");
  67 |           }
-----|-----
  87 |         if (comments.length) {
  88 |           document[schema.comment] = comments;
  89 |         }
-----|-----
 314 |       else if (this.#peek(tokens.comment.start)) {
 315 |         comments.push(this.#comment({ path: [...path, tag] }));
 316 |       } //Raw text
-----|-----
 332 |     if (comments.length) {
 333 |       this.#debug(path, `parsed comments ${JSON.stringify(comments)}`);
 334 |     }
-----|-----
 339 |       ...(comments.length ? { [schema.comment]: comments } : {}),
-----|-----
 387 |             value = value.replace(
 388 |               tokens.entity.regex.entities,
 389 |               (_, hex, code) => String.fromCharCode(parseInt(code, hex ? 16 : 10)),
 390 |             );
-----|-----
 429 |         if (/\s/.test(this.#stream.peek(1, offset))) {
 430 |           offset++;
 431 |           continue;
 432 |         }
cover file:///home/runner/work/xml/xml/utils/stream.ts ... 100.000% (69/69)
cover file:///home/runner/work/xml/xml/utils/streamable.ts ... 100.000% (27/27)
cover file:///home/runner/work/xml/xml/utils/stringifier.ts ... 84.000% (189/225)
  45 |     if (this.#options.debug) {
  46 |       console.debug(`${path.join(" > ")} | ${string}`.trim());
  47 |     }
-----|-----
  68 |     if (elements.length) {
  69 |       this.#debug([], "stringifying doctype elements");
  70 |       this.#down();
  71 |       this.#write(tokens.doctype.elements.start);
  72 |       this.#down();
  73 |       for (const key of elements) {
  74 |         this.#debug([], `stringifying doctype elements ${key}`);
  75 |         const value = `${tokens.doctype.element.value.start}${doctype[key]}${tokens.doctype.element.value.end}`;
  76 |         this.#write(
  77 |           `${tokens.doctype.element.start} ${
  78 |             this.#quote(key, { optional: true })
  79 |           } ${value} ${tokens.doctype.element.end}`,
  80 |         );
  81 |       }
  82 |       this.#up();
  83 |       this.#write(tokens.doctype.elements.end);
  84 |       this.#up();
  85 |     }
-----|-----
 102 |     if (this.#options.progress) {
 103 |       this.#options.progress(this.#result.length);
 104 |     }
-----|-----
 132 |       if (comments.length) {
 133 |         this.#debug(path, `stringifying comments`);
 134 |         for (const comment of comments) {
 135 |           this.#comment({ text: comment, tag: name });
 136 |         }
 137 |       }
-----|-----
 177 |   #comment({ text, tag }: { text: string; tag: string }) {
 178 |     const comment = this.#replace({ value: text, key: schema.comment, tag, properties: null });
 179 |     this.#write(`${tokens.comment.start} ${comment} ${tokens.comment.end}`);
 180 |   }
-----|-----
 214 |     return stringified.length ? ` ${stringified}` : "";
-----|-----
 293 |       const keys = Object.keys(node ?? {});
cover file:///home/runner/work/xml/xml/utils/types.ts ... 100.000% (101/101)