dotsara / dotsara.github.io

Toolbox? No, you're a toolbox!
http://toolbox.dotsara.com
1 stars 0 forks source link

using the correct syntax in a test expectation statement #3

Closed dotsara closed 7 years ago

dotsara commented 7 years ago

What was I surprised or confused by

Writing the expectation statement in a test for the categorySort method. I couldn't come up with how to start or what to start writing while in a pairing session with S. I was immediately frustrated and wanted to throw my hands up.

Instead I did tell him that I didn't know what to write—which didn't feel great (and I know I definitely sounded annoyed about it).

What I thought would happen

I don't know.

What actually happened

S was patient and just told me what to write, heh. expect(testArray.sort(categorySort)).toEqual()

What did I learn

Even though my stated m.o. is to be up front when I don't know something, there are still some things that make me feel kind of crappy for not being able to recall super fast and/or flawlessly.

I learned:

Notes

Before we paired on writing the actual test, I was poking around about how to write a test on a private method (in TypeScript) (which isn't actually a thing in Javascript) and found: https://stackoverflow.com/questions/35987055/how-to-write-unit-testing-for-angular-2-typescript-for-private-methods-with-ja

S and I both agreed that this method should be tested, so we went with the "assert the class as any to access its private methods" route.

const { categorySort } = categoryComponent as any

Category

javascript, testing, unit tests, pairing, frustration, ego