Offroaders123 / NBTify

A library to read and write NBT files on the web!
http://npm.im/nbtify
MIT License
42 stars 5 forks source link

Unit Tests #24

Closed LeoDog896 closed 1 year ago

LeoDog896 commented 1 year ago

Create proper unit tests with Jest instead of using a browser test.

Offroaders123 commented 1 year ago

Looked into this a few times, thanks to learning about ways to do it from some other projects I've been working with recently (jsmediatags). Here's a look at what's coming up!

Up until now, I've been running the reader and writer functions from NBTify over various files with different format type options, which has helped check if the current code is up to handling each of the formats specifically.

Since the actual implementations weren't done yet for each format, having tests for each one wouldn't be as helpful quite yet, since I still had to add the logic itself to manage each of these. Now that NBTify has proven to work well with all of these formats, now it's a great time to set up tests for each of the formats, as I can ensure that the existing behavior will be maintained automatically, without having to manually check the results for each one myself.

Also, the original ./test/index.ts file wasn't solely for checking if things were working right (well, they were partially for that), but it was also to track how NBTify actually outputs and works with it's data. I was using it to decide how the library should work as a whole, not only to check if it's working right (because it inherently wasn't yet).

Test Runner | Node.js

NBTify File Reading Unit Tests