3 var Buffer
= require('node:buffer').Buffer
4 var express
= require('../')
5 , request
= require('supertest');
7 describe('res', function(){
8 describe('.attachment()', function(){
9 it('should Content-Disposition to attachment', function(done
){
12 app
.use(function(req
, res
){
13 res
.attachment().send('foo');
18 .expect('Content-Disposition', 'attachment', done
);
22 describe('.attachment(filename)', function(){
23 it('should add the filename param', function(done
){
26 app
.use(function(req
, res
){
27 res
.attachment('/path/to/image.png');
33 .expect('Content-Disposition', 'attachment; filename="image.png"', done
);
36 it('should set the Content-Type', function(done
){
39 app
.use(function(req
, res
){
40 res
.attachment('/path/to/image.png');
41 res
.send(Buffer
.alloc(4, '.'))
46 .expect('Content-Type', 'image/png', done
);
50 describe('.attachment(utf8filename)', function(){
51 it('should add the filename and filename* params', function(done
){
54 app
.use(function(req
, res
){
55 res
.attachment('/locales/日本語.txt');
61 .expect('Content-Disposition', 'attachment; filename="???.txt"; filename*=UTF-8\'\'%E6%97%A5%E6%9C%AC%E8%AA%9E.txt')
65 it('should set the Content-Type', function(done
){
68 app
.use(function(req
, res
){
69 res
.attachment('/locales/日本語.txt');
75 .expect('Content-Type', 'text/plain; charset=utf-8', done
);