From 64bb935133b0260c50c08acaade45b257274ec2e Mon Sep 17 00:00:00 2001 From: Oleksiy Krivoshey Date: Tue, 16 Feb 2016 18:22:51 +0200 Subject: [PATCH] Test UTF8 support in RETR, STOR, LIST and DELE commands --- ...1\200\320\270\320\262\321\226\321\202.txt" | 1 - test/utf8.js | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) delete mode 100644 "fixture/jose/\320\277\321\200\320\270\320\262\321\226\321\202.txt" diff --git "a/fixture/jose/\320\277\321\200\320\270\320\262\321\226\321\202.txt" "b/fixture/jose/\320\277\321\200\320\270\320\262\321\226\321\202.txt" deleted file mode 100644 index 81c545e..0000000 --- "a/fixture/jose/\320\277\321\200\320\270\320\262\321\226\321\202.txt" +++ /dev/null @@ -1 +0,0 @@ -1234 diff --git a/test/utf8.js b/test/utf8.js index 4c70c8a..7e5d25b 100644 --- a/test/utf8.js +++ b/test/utf8.js @@ -1,42 +1,58 @@ var common = require('./lib/common'); +var path = require('path'); +var fs = require('fs'); describe('UTF8 support', function() { 'use strict'; var client; var server; + var filename = '/uploads/人人生而自由,在尊嚴和權利上一律平等。.txt'; + var uploadedFile = path.join(common.fixturesPath(), common.defaultOptions().user, 'uploads', path.basename(filename)); beforeEach(function(done) { server = common.server(); client = common.client(done); }); - it('should support UTF8 in LIST command', function(done) { - var filename = 'привіт.txt'; - client.list('/' + filename, function(error, listing) { - error.should.equal(false); - listing = common.splitResponseLines(listing, ' ' + filename); - listing.should.have.lengthOf(1); - listing[0].indexOf(filename).should.be.above(-1); + it('should STOR file with UTF8 in filename', function(done) { + client.put(new Buffer('1234'), filename, function(error) { + error.should.be.eql(false); + fs.existsSync(uploadedFile).should.be.eql(true); done(); }); }); it('should RETR file with UTF8 in filename', function(done) { - var filename = 'привіт.txt'; var str = ''; - client.get('/' + filename, function(error, socket) { + client.get(filename, function(error, socket) { common.should.not.exist(error); socket.on('data', function(data) { str += data.toString(); }).on('close', function(error) { error.should.not.equal(true); - str.should.eql('1234\n'); + str.should.eql('1234'); done(); }).resume(); }); }); + it('should support UTF8 in LIST command', function(done) { + client.list(path.dirname(filename), function(error, listing) { + error.should.equal(false); + listing.indexOf(path.basename(filename)).should.be.above(-1); + done(); + }); + }); + + it('should DELE file with UTF8 in filename', function(done) { + client.raw.dele(filename, function(error) { + common.should.not.exist(error); + fs.existsSync(uploadedFile).should.be.eql(false); + done(); + }); + }); + afterEach(function() { server.close(); });