Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion fixture/jose/привіт.txt

This file was deleted.

36 changes: 26 additions & 10 deletions test/utf8.js
Original file line number Diff line number Diff line change
@@ -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();
});
Expand Down