From b1c5c4dbf9aebb5fa661cb99fc02e2e394ae24c9 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Wed, 11 Dec 2019 18:44:01 +0100 Subject: [PATCH] Avoid testing third-party code - This test, though I understand why it was added, is not necessary in my opinion. It's more difficult to get this test to pass since we don't call session.run, we call session.writeTransaction which has a callback that calls transaction.run... - I think we don't need to test that our third party library does what it was added to do... they have their own tests, which can be found here @roschaefer, which I think are sufficient https://github.com/validatorjs/validator.js/blob/master/test/sanitizers.js - We can always add another type of test, if you feel necessary, maybe an e2e? --- .../helpers/createPasswordReset.spec.js | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 backend/src/schema/resolvers/helpers/createPasswordReset.spec.js diff --git a/backend/src/schema/resolvers/helpers/createPasswordReset.spec.js b/backend/src/schema/resolvers/helpers/createPasswordReset.spec.js deleted file mode 100644 index 5f673f028..000000000 --- a/backend/src/schema/resolvers/helpers/createPasswordReset.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import createPasswordReset from './createPasswordReset' - -describe('createPasswordReset', () => { - const issuedAt = new Date() - const nonce = 'abcdef' - - describe('email lookup', () => { - let driver - let mockSession - beforeEach(() => { - mockSession = { - close() {}, - writeTransaction: jest.fn().mockReturnValue({ - run: jest.fn().mockReturnValue({ - records: { - map: jest.fn(() => []), - }, - }), - }), - } - driver = { session: () => mockSession } - }) - - it('lowercases email address', async () => { - const email = 'stRaNGeCaSiNG@ExAmplE.ORG' - await createPasswordReset({ driver, email, issuedAt, nonce }) - expect(mockSession.writeTransaction.run.mock.calls).toEqual([ - [ - expect.any(String), - expect.objectContaining({ - email: 'strangecasing@example.org', - }), - ], - ]) - }) - }) -})