rokucommunity / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
4 stars 2 forks source link

Use a package like `undent` to allow tests with lists to read a little nicer #59

Open lvcabral opened 3 months ago

lvcabral commented 3 months ago
          Might I suggest using a package like `undent` to allow these tests to read a little nicer? We do this a lot in brighterscript-formatter. (see [here](https://github.com/rokucommunity/brighterscript-formatter/blob/b634f670920cd7a7d78e8cede8a4f0e62e7871b4/src/Formatter.spec.ts#L18-L41)). 

So your test would look something like this:

it("lists values", () => {
    let arr = new RoByteArray(new Uint8Array([1, 2, 3, 4, 5]));
    expect(arr.toString()).toEqual(undent`
        <Component: roByteArray> =
        [
        1
        2
        3
        4
        5
        ]
    `);
});

I feel like it improves the readability of the tests. Maybe that could be a separate PR though to hit all the spots that do tests like this? Anyway, just a thought.

_Originally posted by @TwitchBronBron in https://github.com/rokucommunity/brs/pull/53#discussion_r1549575605_