Skip to content

Commit

Permalink
more windows test affordances
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 27, 2023
1 parent 3e68a7b commit 3aa1abd
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions test/match-base.ts
Expand Up @@ -2,6 +2,9 @@ import t from 'tap'
import glob from '../'

import { resolve } from 'path'
import { sep } from 'path'
const alphasort = (a:string, b:string) => a.localeCompare(b, 'en')
const j = (a: string[]) => a.map(s => s.split('/').join(sep)).sort(alphasort)

const fixtureDir = resolve(__dirname, 'fixtures')

Expand All @@ -12,18 +15,14 @@ if (process.platform !== 'win32') {
expect.push('a/symlink/a', 'a/symlink/a/b/c/a')
}

const alphasort = (a: string, b: string) => a.localeCompare(b, 'en')

expect.sort(alphasort)

t.test('chdir', async t => {
const origCwd = process.cwd()
process.chdir(fixtureDir)
t.teardown(() => process.chdir(origCwd))
t.same(glob.sync(pattern, { matchBase: true }).sort(alphasort), expect)
t.same(glob.sync(pattern, { matchBase: true }).sort(alphasort), j(expect))
t.same(
(await glob(pattern, { matchBase: true })).sort(alphasort),
expect
j(expect)
)
})

Expand All @@ -32,13 +31,13 @@ t.test('cwd', async t => {
glob
.sync(pattern, { matchBase: true, cwd: fixtureDir })
.sort(alphasort),
expect
j(expect)
)
t.same(
(await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort(
alphasort
),
expect
j(expect)
)
})

Expand All @@ -55,13 +54,13 @@ t.test('pattern includes /', async t => {
glob
.sync(pattern, { matchBase: true, cwd: fixtureDir })
.sort(alphasort),
expect
j(expect)
)
t.same(
(await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort(
alphasort
),
expect
j(expect)
)
})

Expand All @@ -72,13 +71,13 @@ t.test('one brace section of pattern includes /', async t => {
glob
.sync(pattern, { matchBase: true, cwd: fixtureDir })
.sort(alphasort),
exp
j(exp)
)
t.same(
(await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort(
alphasort
),
exp
j(exp)
)
})

Expand All @@ -89,12 +88,12 @@ t.test('one array member of pattern includes /', async t => {
glob
.sync(pattern, { matchBase: true, cwd: fixtureDir })
.sort(alphasort),
exp
j(exp)
)
t.same(
(await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort(
alphasort
),
exp
j(exp)
)
})

0 comments on commit 3aa1abd

Please sign in to comment.