1
1
/* global describe, it */
2
2
import { strictEqual } from 'assert'
3
3
import { tokenizeArgString } from '../../lib/tokenize-arg-string.js'
4
- import { expect } from 'chai'
5
4
6
5
describe ( 'TokenizeArgString' , function ( ) {
7
6
it ( 'handles unquoted string' , function ( ) {
@@ -24,109 +23,109 @@ describe('TokenizeArgString', function () {
24
23
25
24
it ( 'handles single quoted string with spaces' , function ( ) {
26
25
const args = tokenizeArgString ( "--foo 'hello world' --bar='foo bar'" )
27
- args [ 0 ] . should . equal ( '--foo' )
28
- args [ 1 ] . should . equal ( "'hello world'" )
29
- args [ 2 ] . should . equal ( "--bar='foo bar'" )
26
+ strictEqual ( args [ 0 ] , '--foo' )
27
+ strictEqual ( args [ 1 ] , "'hello world'" )
28
+ strictEqual ( args [ 2 ] , "--bar='foo bar'" )
30
29
} )
31
30
32
31
it ( 'handles double quoted string with spaces' , function ( ) {
33
32
const args = tokenizeArgString ( '--foo "hello world" --bar="foo bar"' )
34
- args [ 0 ] . should . equal ( '--foo' )
35
- args [ 1 ] . should . equal ( '"hello world"' )
36
- args [ 2 ] . should . equal ( '--bar="foo bar"' )
33
+ strictEqual ( args [ 0 ] , '--foo' )
34
+ strictEqual ( args [ 1 ] , '"hello world"' )
35
+ strictEqual ( args [ 2 ] , '--bar="foo bar"' )
37
36
} )
38
37
39
38
it ( 'handles single quoted empty string' , function ( ) {
40
39
const args = tokenizeArgString ( '--foo \'\' --bar=\'\'' )
41
- args [ 0 ] . should . equal ( '--foo' )
42
- args [ 1 ] . should . equal ( "''" )
43
- args [ 2 ] . should . equal ( "--bar=''" )
40
+ strictEqual ( args [ 0 ] , '--foo' )
41
+ strictEqual ( args [ 1 ] , "''" )
42
+ strictEqual ( args [ 2 ] , "--bar=''" )
44
43
} )
45
44
46
45
it ( 'handles double quoted empty string' , function ( ) {
47
46
const args = tokenizeArgString ( '--foo "" --bar=""' )
48
- args [ 0 ] . should . equal ( '--foo' )
49
- args [ 1 ] . should . equal ( '""' )
50
- args [ 2 ] . should . equal ( '--bar=""' )
47
+ strictEqual ( args [ 0 ] , '--foo' )
48
+ strictEqual ( args [ 1 ] , '""' )
49
+ strictEqual ( args [ 2 ] , '--bar=""' )
51
50
} )
52
51
53
52
it ( 'handles quoted string with embedded quotes' , function ( ) {
54
53
var args = tokenizeArgString ( '--foo "hello \'world\'" --bar=\'foo "bar"\'' )
55
- args [ 0 ] . should . equal ( '--foo' )
56
- args [ 1 ] . should . equal ( '"hello \'world\'"' )
57
- args [ 2 ] . should . equal ( '--bar=\'foo "bar"\'' )
54
+ strictEqual ( args [ 0 ] , '--foo' )
55
+ strictEqual ( args [ 1 ] , '"hello \'world\'"' )
56
+ strictEqual ( args [ 2 ] , '--bar=\'foo "bar"\'' )
58
57
} )
59
58
60
59
// https://github.com/yargs/yargs-parser/pull/100
61
60
// https://github.com/yargs/yargs-parser/pull/106
62
61
it ( 'ignores unneeded spaces' , function ( ) {
63
62
const args = tokenizeArgString ( ' foo bar "foo bar" ' )
64
- args [ 0 ] . should . equal ( 'foo' )
65
- expect ( args [ 1 ] ) . equal ( 'bar' )
66
- expect ( args [ 2 ] ) . equal ( '"foo bar"' )
63
+ strictEqual ( args [ 0 ] , 'foo' )
64
+ strictEqual ( args [ 1 ] , 'bar' )
65
+ strictEqual ( args [ 2 ] , '"foo bar"' )
67
66
} )
68
67
69
68
it ( 'handles boolean options' , function ( ) {
70
69
const args = tokenizeArgString ( '--foo -bar' )
71
- expect ( args [ 0 ] ) . to . equal ( ( '--foo' ) )
72
- expect ( args [ 1 ] ) . to . equal ( ( '-bar' ) )
70
+ strictEqual ( args [ 0 ] , '--foo' )
71
+ strictEqual ( args [ 1 ] , '-bar' )
73
72
} )
74
73
75
74
it ( 'handles empty string' , function ( ) {
76
75
const args = tokenizeArgString ( '' )
77
- expect ( args . length ) . to . equal ( 0 )
76
+ strictEqual ( args . length , 0 )
78
77
} )
79
78
80
79
it ( 'handles array with unquoted string' , function ( ) {
81
80
const args = tokenizeArgString ( [ '--foo' , '99' ] )
82
- args [ 0 ] . should . equal ( '--foo' )
83
- args [ 1 ] . should . equal ( '99' )
81
+ strictEqual ( args [ 0 ] , '--foo' )
82
+ strictEqual ( args [ 1 ] , '99' )
84
83
} )
85
84
86
85
it ( 'handles array with quoted string with no spaces' , function ( ) {
87
86
const args = tokenizeArgString ( [ '--foo' , "'hello'" ] )
88
- args [ 0 ] . should . equal ( '--foo' )
89
- args [ 1 ] . should . equal ( "'hello'" )
87
+ strictEqual ( args [ 0 ] , '--foo' )
88
+ strictEqual ( args [ 1 ] , "'hello'" )
90
89
} )
91
90
92
91
it ( 'handles array with single quoted string with spaces' , function ( ) {
93
92
const args = tokenizeArgString ( [ '--foo' , "'hello world'" , "--bar='foo bar'" ] )
94
- args [ 0 ] . should . equal ( '--foo' )
95
- args [ 1 ] . should . equal ( "'hello world'" )
96
- args [ 2 ] . should . equal ( "--bar='foo bar'" )
93
+ strictEqual ( args [ 0 ] , '--foo' )
94
+ strictEqual ( args [ 1 ] , "'hello world'" )
95
+ strictEqual ( args [ 2 ] , "--bar='foo bar'" )
97
96
} )
98
97
99
98
it ( 'handles array with double quoted string with spaces' , function ( ) {
100
99
const args = tokenizeArgString ( [ '--foo' , '"hello world"' , '--bar="foo bar"' ] )
101
- args [ 0 ] . should . equal ( '--foo' )
102
- args [ 1 ] . should . equal ( '"hello world"' )
103
- args [ 2 ] . should . equal ( '--bar="foo bar"' )
100
+ strictEqual ( args [ 0 ] , '--foo' )
101
+ strictEqual ( args [ 1 ] , '"hello world"' )
102
+ strictEqual ( args [ 2 ] , '--bar="foo bar"' )
104
103
} )
105
104
106
105
it ( 'handles array with single quoted empty string' , function ( ) {
107
106
const args = tokenizeArgString ( [ '--foo' , "''" , "--bar=''" ] )
108
- args [ 0 ] . should . equal ( '--foo' )
109
- args [ 1 ] . should . equal ( "''" )
110
- args [ 2 ] . should . equal ( "--bar=''" )
107
+ strictEqual ( args [ 0 ] , '--foo' )
108
+ strictEqual ( args [ 1 ] , "''" )
109
+ strictEqual ( args [ 2 ] , "--bar=''" )
111
110
} )
112
111
113
112
it ( 'handles array with double quoted empty string' , function ( ) {
114
113
const args = tokenizeArgString ( [ '--foo' , '""' , '--bar=""' ] )
115
- args [ 0 ] . should . equal ( '--foo' )
116
- args [ 1 ] . should . equal ( '""' )
117
- args [ 2 ] . should . equal ( '--bar=""' )
114
+ strictEqual ( args [ 0 ] , '--foo' )
115
+ strictEqual ( args [ 1 ] , '""' )
116
+ strictEqual ( args [ 2 ] , '--bar=""' )
118
117
} )
119
118
120
119
it ( 'handles array with quoted string with embedded quotes' , function ( ) {
121
120
var args = tokenizeArgString ( [ '--foo' , '"hello \'world\'"' , '--bar=\'foo "bar"\'' ] )
122
- args [ 0 ] . should . equal ( '--foo' )
123
- args [ 1 ] . should . equal ( '"hello \'world\'"' )
124
- args [ 2 ] . should . equal ( '--bar=\'foo "bar"\'' )
121
+ strictEqual ( args [ 0 ] , '--foo' )
122
+ strictEqual ( args [ 1 ] , '"hello \'world\'"' )
123
+ strictEqual ( args [ 2 ] , '--bar=\'foo "bar"\'' )
125
124
} )
126
125
127
126
it ( 'handles array with boolean options' , function ( ) {
128
127
const args = tokenizeArgString ( [ '--foo' , '-bar' ] )
129
- expect ( args [ 0 ] ) . to . equal ( '--foo' )
130
- expect ( args [ 1 ] ) . to . equal ( '-bar' )
128
+ strictEqual ( args [ 0 ] , '--foo' )
129
+ strictEqual ( args [ 1 ] , '-bar' )
131
130
} )
132
131
} )
0 commit comments