Skip to content

Commit

Permalink
feat(encoding): add tests for encodings with cyrillic characters
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrack committed Oct 16, 2015
1 parent c55b86a commit fd2ce3a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ app.get('/test/objectArray', function(req, res) {
]);
});

app.get('/test/cyrillic/utf8', function(req, res) {
res.csv([
['Привет', 'мир']
]);
});

app.get('/test/cyrillic/cp1251', function(req, res) {
res.charset = "cp-1251";
res.csv([
['Привет', 'мир']
]);
});

app.listen(8383);

describe('csv-express', function() {
Expand Down Expand Up @@ -195,4 +208,25 @@ describe('res.csv()', function() {
done();
});
});

describe('when given cyrillyc data', function() {
it('should response with utf-8 text', function(done) {
request
.get('http://127.0.0.1:8383/test/cyrillic/utf8')
.end(function(error, res) {
res.text.should.equal('"Привет","мир"\r\n');
done();
});
});

it('should response with cp-1251 text', function(done) {
request
.get('http://127.0.0.1:8383/test/cyrillic/cp1251')
.end(function(error, res) {
var text = new Buffer([0x22, 0xcf, 0xf0, 0xe8, 0xe2, 0xe5, 0xf2, 0x22, 0x2c, 0x22, 0xcc, 0xe8, 0xf0, 0x22, 0x0d, 0x0a]);
res.text.should.equal(text.toString());
done();
});
});
});
});

0 comments on commit fd2ce3a

Please sign in to comment.