Skip to content

Commit

Permalink
wip2
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Apr 18, 2023
1 parent 7d9a539 commit 15e0a9a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/tests/e2e/options/absolute.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ runner.suite('Options Absolute', {
});

runner.suite('Options Absolute (ignore)', {
debug: true,
resultTransform,
tests: [
{
Expand Down
8 changes: 0 additions & 8 deletions src/tests/e2e/options/case-sensitive-match.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as runner from '../runner';
import * as utils from '../..';

runner.suite('Options CaseSensitiveMatch', {
tests: [
Expand All @@ -9,13 +8,6 @@ runner.suite('Options CaseSensitiveMatch', {
{
pattern: 'fixtures/File.md',
options: { caseSensitiveMatch: false }
},

{
pattern: '/tmp/*',
options: { caseSensitiveMatch: false, onlyFiles: false },
condition: () => !utils.platform.isWindows(),
issue: 276
}
]
});
37 changes: 29 additions & 8 deletions src/tests/e2e/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export function suite(name: string, suite: Suite): void {
const definition = getTestMochaDefinition(suite, test);
const transformers: TransformFunction[] = [];

const isDebug = suite.debug !== undefined || test.debug !== undefined;

if (suite.resultTransform !== undefined) {
transformers.push(suite.resultTransform);
}
Expand All @@ -64,21 +66,30 @@ export function suite(name: string, suite: Suite): void {
}

definition(`${title} (sync)`, () => {
const actual = getFastGlobEntriesSync(test.pattern, options);
let actual = getFastGlobEntriesSync(test.pattern, options);

actual = transform(actual, transformers);

snapshot(actual, transformers);
debug(actual, isDebug);
snapshot(actual);
});

definition(`${title} (async)`, async () => {
const actual = await getFastGlobEntriesAsync(test.pattern, options);
let actual = await getFastGlobEntriesAsync(test.pattern, options);

actual = transform(actual, transformers);

snapshot(actual, transformers);
debug(actual, isDebug);
snapshot(actual);
});

definition(`${title} (stream)`, async () => {
const actual = await getFastGlobEntriesStream(test.pattern, options);
let actual = await getFastGlobEntriesStream(test.pattern, options);

snapshot(actual, transformers);
actual = transform(actual, transformers);

debug(actual, isDebug);
snapshot(actual);
});
}
});
Expand Down Expand Up @@ -136,12 +147,22 @@ async function getFastGlobEntriesStream(pattern: Pattern, options?: fg.Options):
return entries.sort((a, b) => a.localeCompare(b));
}

function snapshot(entries: string[], transformers: TransformFunction[]): void {
function transform(entries: string[], transformers: TransformFunction[]): string[] {
let result = entries;

for (const transformer of transformers) {
result = result.map((item) => transformer(item));
}

snapshotIt(result);
return result;
}

function snapshot(entries: string[]): void {
snapshotIt(entries);
}

function debug(entries: string[], isEnabled: boolean): void {
if (isEnabled) {
console.dir(entries, { colors: true });
}
}

0 comments on commit 15e0a9a

Please sign in to comment.