LearningTypeScript / projects

Hands-on real world projects that will help you exercise your knowledge of TypeScript.
https://learningtypescript.com/projects
235 stars 156 forks source link

🐛 Bug: [Text Processor] Inconsistent tests expected results #199

Closed JoseCrz closed 1 year ago

JoseCrz commented 1 year ago

Bug Report Checklist

Expected

Some tests should pass based on the project's specification, examples and other tests results.

Actual

Some tests fail due to the expected result being incorrect.

Impacted Project

Arrays -> Text Processor

Additional Info

In projects/arrays/text-processor/src/index.test.ts there are some inconsistencies in the tests expected results.

For example:

On the test case at lines 31 to 38 we have:

[
  ["ab de", "abc def"],
  { width: 4 },
  [
    ["ab  ", "de  "],
    ["abc ", "def "],
  ],
],

We can see that the first element of the texts array "ab de" gets split in the expected result: ["ab ", "de "],.

This is also true for the immediate next test at lines 39 to 47

[
  ["ab de", "abc def", "abcd ef"],
  { width: 4 },
  [
    ["ab  ", "de  "],
    ["abc ", "def "],
    ["abcd", "ef  "],
  ],
],

We can see the first element of the text array "ab de" also gets split in the expected result: ["ab ", "de "].

However, in the test following this one, the expected result is different doesn't follow this pattern. On line 48 we have:

[["ab de", "abc def"], { width: 5 }, [["ab de"], ["abc  ", "def  "]]],

In this case, the first element of the text array "ab de" doesn't get split, instead we have that its corresponding expected result is ["ab de"] which differs from the previous test cases and ,to my understanding, also differs from the specification of this project.

A gave a quick look an this "inconsistencies" also appear in more test cases like the test on line 49:

[["abc def", "abc def"], { width: 8 }, [["abc def "], ["abc def "]]],

test on line 66:

[["abc def", "abcdefghi"], { width: 8 }, [["abc def "], ["abcdefghi"]]],

or tests at lines 73 to 77

[["abc def"], { align: "left", width: 7 }, [["abc def"]]],
[["abc def"], { align: "left", width: 8 }, [["abc def "]]],
[["abc def"], { align: "left", width: 9 }, [["abc def  "]]],
[["abc def"], { align: "left", width: 10 }, [["abc def   "]]],
[["abc def"], { align: "left", width: 11 }, [["abc def    "]]],

These "inconsistencies" as I'm calling them right now, in turn make some tests fail which I believe shouldn't.

I re-read the project description and specification a couple times but couldn't find anything that suggested this behavior was expected/intentional. An apologize in advance if my reading comprehension baamboozled me.

JoshuaKGoldberg commented 1 year ago

Hey @JoseCrz! So sorry for not replying till now (4 months later! 😩). This project's text is tricky and the description I'd put in wasn't very clear - so I kept getting lost in it, losing track, and then not responding.

However, in the test following this one, the expected result is different doesn't follow this pattern. On line 48 we have:

[["ab de", "abc def"], { width: 5 }, [["ab de"], ["abc  ", "def  "]]],

I don't see how that doesn't follow the pattern?

Am I missing something?

As an apology for taking so long (and because I think it's useful), #256 adds some more details to the README.md