Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
File-Sharing-Website/unit tests/mailer.spec.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (38 sloc)
799 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const hashes = require('../modules/mailer.js') | |
describe('createHash()', () => { | |
// block of tests | |
beforeEach(async() => { | |
// runs after each test completes | |
}) | |
afterEach(async() => { | |
// runs after each test completes | |
}) | |
test('create hash', async done => { | |
expect.assertions(2) | |
try { | |
//ACT | |
const hash = hashes.createHash('string') | |
//ASSERT | |
expect(hash).not.toBe('string') | |
expect(hash).toHaveLength(32) | |
} catch (err) { | |
done.fail('Failed to create a hash.') | |
} finally { | |
done() | |
} | |
}) | |
test('string must not be empty', async done => { | |
expect.assertions(1) | |
try { | |
//ACT | |
hashes.createHash('') | |
//ASSERT | |
done.fail('test failed') | |
} catch (err) { | |
expect(err.message).toBe('String cannot be empty.') | |
} finally { | |
done() | |
} | |
}) | |
}) |