Skip to content

Commit

Permalink
Add test verifying that AttachmentView shows file size
Browse files Browse the repository at this point in the history
FREEBIE
  • Loading branch information
scottnonnenberg committed May 9, 2017
1 parent e7f41be commit 731fcb8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/index.html
Expand Up @@ -503,8 +503,11 @@ <h3>{{ message }}</h3>
{{/action }}
</script>
<script type='text/x-tmpl-mustache' id='file-view'>
<span class='paperclip icon'></span>
<span class='fileName' alt='{{ fileName }}' title='{{ altText }}'>{{ fileName }}</a>
<div class='icon'></div>
<div class='text'>
<div class='fileName' alt='{{ fileName }}' title='{{ altText }}'>{{ fileName }}</div>
<div class='fileSize'>{{ fileSize }}</div>
</div>
</script>


Expand Down
19 changes: 17 additions & 2 deletions test/views/attachment_view_test.js
Expand Up @@ -2,15 +2,30 @@ describe('AttachmentView', function() {

describe('with arbitrary files', function() {
it('should render a file view', function() {
var attachment = { contentType: 'arbitrary/content' };
var attachment = {
contentType: 'unused',
size: 1232
};
var view = new Whisper.AttachmentView({model: attachment}).render();
assert.match(view.el.innerHTML, /fileView/);
});
it('should display the filename if present', function() {
var attachment = { contentType: 'arbitrary/content', fileName: 'foo.txt' };
var attachment = {
fileName: 'foo.txt',
contentType: 'unused',
size: 1232,
};
var view = new Whisper.AttachmentView({model: attachment}).render();
assert.match(view.el.innerHTML, /foo.txt/);
});
it('should render a file size', function() {
var attachment = {
size: 1232,
contentType: 'unused'
};
var view = new Whisper.AttachmentView({model: attachment}).render();
assert.match(view.el.innerHTML, /1.2 KB/);
});
});
it('should render an image for images', function() {
var now = new Date().getTime();
Expand Down

0 comments on commit 731fcb8

Please sign in to comment.