Skip to content

Commit

Permalink
Add tests for #587
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann Savary authored and rlidwka committed Dec 1, 2020
1 parent fe72979 commit 06eaa69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions test/issues/0369.js
Expand Up @@ -5,7 +5,6 @@ var assert = require('assert');
var yaml = require('../../');


test('should dump astrals as codepoint', function () {
assert.deepEqual(yaml.safeDump('πŸ˜€'), '"\\U0001F600"\n');
test('should load astrals as codepoint', function () {
assert.deepEqual(yaml.safeLoad('"\\U0001F600"'), 'πŸ˜€');
});
20 changes: 20 additions & 0 deletions test/issues/0587.js
@@ -0,0 +1,20 @@
'use strict';


var assert = require('assert');
var yaml = require('../../');


suite('Should not escape emojis', function () {
test('plain', function () {
assert.strictEqual(yaml.safeDump('πŸ˜€'), 'πŸ˜€\n');
});

test('escape \\ and " in double-quoted', function () {
assert.strictEqual(yaml.safeDump('\u0007 πŸ˜€ escape\\ escaper"'), '"\\a πŸ˜€ escape\\\\ escaper\\""\n');
});

test('escape non-printables', function () {
assert.strictEqual(yaml.safeDump('aπŸ˜€\nb\u0001c'), '"aπŸ˜€\\nb\\x01c"\n');
});
});

0 comments on commit 06eaa69

Please sign in to comment.