Update tests
This commit is contained in:
parent
c9b4ae6e80
commit
6c7e1aa283
2 changed files with 27 additions and 6 deletions
|
@ -502,6 +502,10 @@
|
||||||
</div>
|
</div>
|
||||||
{{/action }}
|
{{/action }}
|
||||||
</script>
|
</script>
|
||||||
|
<script type='text/x-tmpl-mustache' id='file-view'>
|
||||||
|
<span class='paperclip icon'></span>
|
||||||
|
<span class='fileName' alt='{{ fileName }}' title='{{ altText }}'>{{ fileName }}</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="../js/components.js"></script>
|
<script type="text/javascript" src="../js/components.js"></script>
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
describe('AttachmentView', function() {
|
describe('AttachmentView', function() {
|
||||||
|
|
||||||
it('should render a data url for arbitrary content', function() {
|
describe('with arbitrary files', function() {
|
||||||
var attachment = { contentType: 'arbitrary/content' };
|
it('should render a file view', function() {
|
||||||
var view = new Whisper.AttachmentView({model: attachment}).render();
|
var attachment = { contentType: 'arbitrary/content' };
|
||||||
assert.equal(view.el.firstChild.tagName, "A");
|
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 view = new Whisper.AttachmentView({model: attachment}).render();
|
||||||
|
assert.match(view.el.innerHTML, /foo.txt/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an image for images', function() {
|
it('should render an image for images', function() {
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
var attachment = { contentType: 'image/png', data: 'grumpy cat' };
|
var attachment = { contentType: 'image/png', data: 'grumpy cat' };
|
||||||
|
@ -13,7 +19,18 @@ describe('AttachmentView', function() {
|
||||||
assert.equal(view.el.firstChild.tagName, "IMG");
|
assert.equal(view.el.firstChild.tagName, "IMG");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shoud have correct filename format', function() {
|
it('should display a filename', function() {
|
||||||
|
var epoch = new Date((new Date(0)).getTimezoneOffset() * 60 * 1000);
|
||||||
|
var attachment = { contentType: 'image/png', data: 'grumpy cat' };
|
||||||
|
var result = new Whisper.AttachmentView({
|
||||||
|
model: attachment,
|
||||||
|
timestamp: epoch
|
||||||
|
}).suggestedName();
|
||||||
|
|
||||||
|
var expected = '1970-01-01-000000';
|
||||||
|
assert(result === 'signal-' + expected + '.png');
|
||||||
|
});
|
||||||
|
it('should auto-generate a filename', function() {
|
||||||
var epoch = new Date((new Date(0)).getTimezoneOffset() * 60 * 1000);
|
var epoch = new Date((new Date(0)).getTimezoneOffset() * 60 * 1000);
|
||||||
var attachment = { contentType: 'image/png', data: 'grumpy cat' };
|
var attachment = { contentType: 'image/png', data: 'grumpy cat' };
|
||||||
var result = new Whisper.AttachmentView({
|
var result = new Whisper.AttachmentView({
|
||||||
|
|
Loading…
Add table
Reference in a new issue