Skip to content

Commit

Permalink
make paths relative to dest
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 17, 2022
1 parent 80ac5a6 commit 0449820
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions standalone-cli/tests/test.js
Expand Up @@ -15,12 +15,8 @@ function exec(args) {
).toString()
}

function relative(...paths) {
return path.resolve(__dirname, ...paths)
}

it('works', () => {
let result = exec(`--content ${relative('./fixtures/basic.html')}`)
let result = exec('--content ./tests/fixtures/basic.html')
expect(result).toContain('.uppercase')
expect(result).toContain('.\\[will-change\\:opacity\\]')
expect(result).toContain('will-change: opacity')
Expand All @@ -30,11 +26,7 @@ it('works', () => {
})

it('supports first-party plugins', () => {
let result = exec(
`--content ${relative('./fixtures/plugins.html')} --config ${relative(
'./fixtures/test.config.js'
)}`
)
let result = exec('--content tests/fixtures/plugins.html --config tests/fixtures/test.config.js')
expect(result).toContain('.aspect-w-1')
expect(result).toContain('.form-input')
expect(result).toContain('.line-clamp-2')
Expand All @@ -43,13 +35,14 @@ it('supports first-party plugins', () => {

it('supports postcss config files', async () => {
// We have to run this test outside of any place with node_modules for it to properly test this situation
let result = await inIsolatedContext(() => {
let result = await inIsolatedContext((base) => {
// Emulate the user adding their own postcss plugins
execSync(`npm install postcss-will-change`)

return exec(
`--content ${relative('./fixtures/basic.html')} --postcss ${relative(
'./fixtures/postcss.config.js'
`--content ${path.resolve(base, 'tests/fixtures/basic.html')} --postcss ${path.resolve(
base,
'tests/fixtures/postcss.config.js'
)}`
)
})
Expand Down Expand Up @@ -86,7 +79,7 @@ async function inIsolatedContext(fn) {
process.chdir(dest)

try {
return await fn()
return await fn(dest)
} finally {
// Change back to the original working directory
process.chdir(__dirname)
Expand Down

0 comments on commit 0449820

Please sign in to comment.