forked from npm/cmd-shim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto-batch-syntax-tests.js
25 lines (23 loc) · 1.07 KB
/
to-batch-syntax-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var test = require('tap').test
var toBatchSyntax = require('../lib/to-batch-syntax')
test('replace $ expressions with % pair', function (t) {
var assertReplacement = function(string, expected) {
t.equal(toBatchSyntax.replaceDollarWithPercentPair(string), expected)
}
assertReplacement("$A", "%A%")
assertReplacement("$A:$B", "%A%:%B%")
assertReplacement("$A bla", "%A% bla")
assertReplacement("${A}bla", "%A%bla")
assertReplacement("$A $bla bla", "%A% %bla% bla")
assertReplacement("${A}bla ${bla}bla", "%A%bla %bla%bla")
assertReplacement("./lib:$NODE_PATH", "./lib:%NODE_PATH%")
t.end()
})
test('convert variable declaration to set command', function(t) {
t.equal(toBatchSyntax.convertToSetCommand("A",".lib:$A "), "@SET A=.lib:%A%\r\n")
t.equal(toBatchSyntax.convertToSetCommand("", ""), "")
t.equal(toBatchSyntax.convertToSetCommand(" ", ""), "")
t.equal(toBatchSyntax.convertToSetCommand(" ", " "), "")
t.equal(toBatchSyntax.convertToSetCommand(" ou", " ou "), "@SET ou=ou\r\n")
t.end()
})