|
| 1 | +importpathfrom'path'; |
| 2 | + |
1 | 3 | importtestfrom'ava'; |
2 | 4 |
|
3 | 5 | importshellfrom'..'; |
@@ -51,25 +53,84 @@ test.cb('config.fatal = true', t => { |
51 | 53 | // config.globOptions |
52 | 54 | // |
53 | 55 |
|
54 | | -test('Expands to directories by default',t=>{ |
| 56 | +test('config.globOptions expands directories by default',t=>{ |
55 | 57 | constresult=common.expand(['test/resources/*a*']); |
56 | | -t.is(result.length,5); |
57 | | -t.truthy(result.indexOf('test/resources/a.txt')>-1); |
58 | | -t.truthy(result.indexOf('test/resources/badlink')>-1); |
59 | | -t.truthy(result.indexOf('test/resources/cat')>-1); |
60 | | -t.truthy(result.indexOf('test/resources/head')>-1); |
61 | | -t.truthy(result.indexOf('test/resources/external')>-1); |
| 58 | +constexpected=[ |
| 59 | +'test/resources/a.txt', |
| 60 | +'test/resources/badlink', |
| 61 | +'test/resources/cat', |
| 62 | +'test/resources/external', |
| 63 | +'test/resources/head', |
| 64 | +]; |
| 65 | +t.deepEqual(result,expected); |
| 66 | +}); |
| 67 | + |
| 68 | +test('config.globOptions respects cwd',t=>{ |
| 69 | +// Both node-glob and fast-glob call this option 'cwd'. |
| 70 | +shell.config.globOptions={cwd:'test'}; |
| 71 | +constresult=common.expand(['resources/*a*']); |
| 72 | +constexpected=[ |
| 73 | +'resources/a.txt', |
| 74 | +'resources/badlink', |
| 75 | +'resources/cat', |
| 76 | +'resources/external', |
| 77 | +'resources/head', |
| 78 | +]; |
| 79 | +t.deepEqual(result,expected); |
62 | 80 | }); |
63 | 81 |
|
64 | | -test( |
65 | | -'Check to make sure options get passed through (nodir is an example)', |
66 | | -t=>{ |
67 | | -shell.config.globOptions={nodir:true}; |
68 | | -constresult=common.expand(['test/resources/*a*']); |
69 | | -t.is(result.length,2); |
70 | | -t.truthy(result.indexOf('test/resources/a.txt')>-1); |
71 | | -t.truthy(result.indexOf('test/resources/badlink')>-1); |
72 | | -t.truthy(result.indexOf('test/resources/cat')<0); |
73 | | -t.truthy(result.indexOf('test/resources/external')<0); |
| 82 | +test('config.globOptions respects dot',t=>{ |
| 83 | +// Both node-glob and fast-glob call this option 'dot'. |
| 84 | +shell.config.globOptions={dot:true}; |
| 85 | +constresult=common.expand(['test/resources/ls/*']); |
| 86 | +t.is(result.length,8); |
| 87 | +t.truthy(result.indexOf('test/resources/ls/.hidden_dir')>-1); |
| 88 | +t.truthy(result.indexOf('test/resources/ls/.hidden_file')>-1); |
| 89 | +}); |
| 90 | + |
| 91 | +test('config.globOptions respects ignore',t=>{ |
| 92 | +// Both node-glob and fast-glob call this option 'ignore'. |
| 93 | +shell.config.globOptions={ignore:['test/resources/external']}; |
| 94 | +constresult=common.expand(['test/resources/*a*']); |
| 95 | +constexpected=[ |
| 96 | +'test/resources/a.txt', |
| 97 | +'test/resources/badlink', |
| 98 | +'test/resources/cat', |
| 99 | +'test/resources/head', |
| 100 | +]; |
| 101 | +t.deepEqual(result,expected); |
| 102 | +// Does not include the result that we chose to ignore |
| 103 | +t.truthy(result.indexOf('test/resources/external')<0); |
| 104 | +}); |
| 105 | + |
| 106 | +test('config.globOptions respects absolute',t=>{ |
| 107 | +// Both node-glob and fast-glob call this option 'absolute'. |
| 108 | +shell.config.globOptions={absolute:true}; |
| 109 | +constresult=common.expand(['test/resources/*a*']); |
| 110 | +functionabs(file){ |
| 111 | +returnpath.join(process.cwd(),file); |
74 | 112 | } |
75 | | -); |
| 113 | +constexpected=[ |
| 114 | +abs(path.join('test','resources','a.txt')), |
| 115 | +abs(path.join('test','resources','badlink')), |
| 116 | +abs(path.join('test','resources','cat')), |
| 117 | +abs(path.join('test','resources','external')), |
| 118 | +abs(path.join('test','resources','head')), |
| 119 | +]; |
| 120 | +t.deepEqual(result,expected); |
| 121 | +}); |
| 122 | + |
| 123 | +test('config.globOptions respects nodir',t=>{ |
| 124 | +shell.config.globOptions={nodir:true}; |
| 125 | +constresult=common.expand(['test/resources/*a*']); |
| 126 | +// Includes files and symlinks. |
| 127 | +constexpected=[ |
| 128 | +'test/resources/a.txt', |
| 129 | +'test/resources/badlink', |
| 130 | +]; |
| 131 | +t.deepEqual(result,expected); |
| 132 | +// Does not include the directories. |
| 133 | +t.truthy(result.indexOf('test/resources/cat')<0); |
| 134 | +t.truthy(result.indexOf('test/resources/head')<0); |
| 135 | +t.truthy(result.indexOf('test/resources/external')<0); |
| 136 | +}); |