-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from TunedMidja/fix_394
Fixes #394
- Loading branch information
Showing
3 changed files
with
53 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Just a little file for testing attachments. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
/** | ||
* Dependencies | ||
*/ | ||
const Attachment = require('./attachment'); | ||
|
||
/** | ||
* Tests | ||
*/ | ||
describe('Attachment', function() { | ||
let attachment; | ||
beforeEach(function() { | ||
attachment = new Attachment(); | ||
}); | ||
|
||
//Set content as string | ||
describe('setContent(), string', function() { | ||
it('should set string as content', function() { | ||
attachment.setContent("Just a string."); | ||
expect(attachment.content).to.equal('Just a string.'); | ||
}); | ||
}); | ||
|
||
//Set content as stream | ||
describe('setContent(), stream', function() { | ||
it('should convert stream to string and set as content', function() { | ||
const fileData = fs.readFileSync('./packages/helpers/attachment.txt'); | ||
attachment.setContent(fileData); | ||
expect(attachment.content).to.equal('Just a little file for testing attachments.'); | ||
}); | ||
}); | ||
|
||
//Set content as wrong type | ||
describe('setContent(), wrong type', function() { | ||
it('should not allow setting content of wrong type', function() { | ||
expect(() => attachment.setContent(null)).to.throw('`content` expected to be either Buffer or string'); | ||
}); | ||
}); | ||
|
||
}); |