yeoman / generator

Rails-inspired generator system that provides scaffolding for your apps
http://yeoman.io
BSD 2-Clause "Simplified" License
1.21k stars 299 forks source link

fs.test.ts: Improve readbility, add types to fix TS problems #1482

Closed weedySeaDragon closed 1 year ago

weedySeaDragon commented 1 year ago

addresses #1481

  1. Improve readability to make it easier for readers to use tests to understand the generator code / use the tests as specifications

    • I created constants to use as array indices so that the intent is explicit.
  2. Fix TypeScript problems: Added, defined types where needed.

    • In order to use ejs Data type for templates, had to explicitly include @types/ejs and ejs in the package.
    • GeneratorOptions requires help: be included; added it to a new Generator.... call where it was missing
    • I had to add a @ts-expect-error comment for a line where esmocha.spyOn(...) is used. I referenced the known GitHub issue. I added a comment noting that the spyOn could be replaced with a sinonStub(), since the result of the spy is never checked.

I did not squash my commits. I thought it might be helpful to see exactly what changes I made.