Pubs not Puns

August 28, 2020

Categories: Code , Tags: Software, Testing, Jest

I was talking with a friend today online, and he mentioned my love of pubs. This was actually a typo, as he was aiming to be sarcastic about my lack of love for puns:


You love a pub


I do!



Well both statements are true 😁

I typed pun. Bloody iPhone decided it knew best

It didn’t


Today I’m focusing on writing a test suite - so I could quickly throw together a test for that claim.

So, here's my Jest test case for my friend's claim that I like both pubs and puns. I'm pretty sure it proves once and for all that I'm not a fan of puns.

function like(thing) {
	if (thing === 'pub') return true;
	else if (thing === 'pun') return false;
	return undefined;

describe('Mark', () => {
	it('likes', () => {
		test('a pub', () => expect(like('pub')).toBeTruthy());
		test('a pun', () => expect(like('pun')).toBeFalsy());
		test('a pug', () => expect(like('pug')).toBeUndefined());
		test('another pug', () => expect(like('pug2')).toBeUndefined());