Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
332 additions
and
89 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'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) | ||
//ACT | ||
const hash = hashes.createHash('string') | ||
//ASSERT | ||
expect(hash).not.toBe('string') | ||
expect(hash).toHaveLength(32) | ||
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() | ||
} | ||
}) | ||
}) | ||
|
||
describe('sendMail()', () => { | ||
/* // block of tests | ||
beforeEach(async () => { | ||
// runs after each test completes | ||
}) | ||
afterEach(async () => { | ||
// runs after each test completes | ||
}) */ | ||
|
||
test('Valid email', async done => { | ||
expect.assertions(1) | ||
try { | ||
//ACT | ||
hashes.sendMail('test', 'link/localhost:8080/', 'message') | ||
//ASSERT | ||
done.fail('test failed') | ||
} catch (err) { | ||
expect(err.message).toBe('Email invalid') | ||
} finally { | ||
done() | ||
} | ||
}) | ||
|
||
test('Valid link', async done => { | ||
expect.assertions(1) | ||
try { | ||
//ACT | ||
hashes.sendMail('test@', 'link', 'message') | ||
//ASSERT | ||
done.fail('test failed') | ||
} catch (err) { | ||
expect(err.message).toBe('Wrong download link') | ||
} finally { | ||
done() | ||
} | ||
}) | ||
}) | ||
|
Oops, something went wrong.