77 inbandStandardTests = require ( './name-inband-standard' ) ,
88 tmp = require ( '../lib/tmp' ) ;
99
10+ const isWindows = os . platform ( ) === 'win32' ;
1011
1112describe ( 'tmp' , function ( ) {
1213 describe ( '#tmpNameSync()' , function ( ) {
@@ -39,7 +40,9 @@ describe('tmp', function () {
3940 describe ( 'on issue #176' , function ( ) {
4041 const origfn = os . tmpdir ;
4142 it ( 'must fail on invalid os.tmpdir()' , function ( ) {
42- os . tmpdir = function ( ) { return undefined ; } ;
43+ os . tmpdir = function ( ) {
44+ return undefined ;
45+ } ;
4346 try {
4447 tmp . tmpNameSync ( ) ;
4548 assert . fail ( 'should have failed' ) ;
@@ -50,6 +53,35 @@ describe('tmp', function () {
5053 }
5154 } ) ;
5255 } ) ;
56+ describe ( 'on issue #246' , function ( ) {
57+ const origfn = os . tmpdir ;
58+ it ( 'must produce correct name on os.tmpdir() returning path that includes double quotes' , function ( ) {
59+ const tmpdir = isWindows ? '"C:\\Temp With Spaces"' : '"/tmp with spaces"' ;
60+ os . tmpdir = function ( ) {
61+ return tmpdir ;
62+ } ;
63+ const name = tmp . tmpNameSync ( ) ;
64+ try {
65+ assert . ok ( name . indexOf ( '"' ) === - 1 ) ;
66+ assert . ok ( name . startsWith ( tmpdir . replace ( / [ " ' ] / g, '' ) ) ) ;
67+ } finally {
68+ os . tmpdir = origfn ;
69+ }
70+ } ) ;
71+ it ( 'must produce correct name on os.tmpdir() returning path that includes single quotes' , function ( ) {
72+ const tmpdir = isWindows ? '\'C:\\Temp With Spaces\'' : '\'/tmp with spaces\'' ;
73+ os . tmpdir = function ( ) {
74+ return tmpdir ;
75+ } ;
76+ const name = tmp . tmpNameSync ( ) ;
77+ try {
78+ assert . ok ( name . indexOf ( '\'' ) === - 1 ) ;
79+ assert . ok ( name . startsWith ( tmpdir . replace ( / [ " ' ] / g, '' ) ) ) ;
80+ } finally {
81+ os . tmpdir = origfn ;
82+ }
83+ } ) ;
84+ } ) ;
5385 } ) ;
5486
5587 describe ( 'when running standard outband tests' , function ( ) {
0 commit comments