Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4e6753

Browse files
committed
test: add test coverage for some globOptions
No change to logic. This adds test coverage support for all of theglobOptions which share the same name between node-glob and fast-glob.Seehttps://github.com/mrmlnc/fast-glob?tab=readme-ov-file#compatible-with-node-globIssue#828
1 parent3529d50 commite4e6753

File tree

1 file changed

+79
-18
lines changed

1 file changed

+79
-18
lines changed

‎test/config.js‎

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
importpathfrom'path';
2+
13
importtestfrom'ava';
24

35
importshellfrom'..';
@@ -51,25 +53,84 @@ test.cb('config.fatal = true', t => {
5153
// config.globOptions
5254
//
5355

54-
test('Expands to directories by default',t=>{
56+
test('config.globOptions expands directories by default',t=>{
5557
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);
6280
});
6381

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);
74112
}
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+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp