3 var express
= require('../')
4 , request
= require('supertest');
6 describe('res', function(){
7 describe('.attachment()', function(){
8 it('should Content-Disposition to attachment', function(done
){
11 app
.use(function(req
, res
){
12 res
.attachment().send('foo');
17 .expect('Content-Disposition', 'attachment', done
);
21 describe('.attachment(filename)', function(){
22 it('should add the filename param', function(done
){
25 app
.use(function(req
, res
){
26 res
.attachment('/path/to/image.png');
32 .expect('Content-Disposition', 'attachment; filename="image.png"', done
);
35 it('should set the Content-Type', function(done
){
38 app
.use(function(req
, res
){
39 res
.attachment('/path/to/image.png');
40 res
.send(Buffer
.alloc(4, '.'))
45 .expect('Content-Type', 'image/png', done
);
49 describe('.attachment(utf8filename)', function(){
50 it('should add the filename and filename* params', function(done
){
53 app
.use(function(req
, res
){
54 res
.attachment('/locales/日本語.txt');
60 .expect('Content-Disposition', 'attachment; filename="???.txt"; filename*=UTF-8\'\'%E6%97%A5%E6%9C%AC%E8%AA%9E.txt')
64 it('should set the Content-Type', function(done
){
67 app
.use(function(req
, res
){
68 res
.attachment('/locales/日本語.txt');
74 .expect('Content-Type', 'text/plain; charset=utf-8', done
);