Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Feb 18, 2024
1 parent 432520c commit bf64368
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions tests/commands/add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { join } from 'node:path'
import { test } from '@japa/runner'
import { fileURLToPath } from 'node:url'
import { ListLoader } from '@adonisjs/ace'
import type { FileSystem } from '@japa/file-system'

Expand Down Expand Up @@ -76,7 +75,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE
await command.exec()

Expand All @@ -97,7 +96,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE
await command.exec()

Expand All @@ -118,7 +117,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE
command.packageManager = 'pnpm'

Expand All @@ -141,7 +140,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE

await command.exec()
Expand All @@ -151,10 +150,7 @@ test.group('Install', (group) => {

test('should install dev dependency', async ({ assert, fs }) => {
const ace = await new AceFactory().make(fs.baseUrl, {
importer: async (filePath) => {
console.log('load', filePath)
return await import(join(filePath, `index.js?${Math.random()}`))
},
importer: async (filePath) => await import(join(filePath, `index.js?${Math.random()}`)),
})

await setupProject(fs, 'npm')
Expand All @@ -166,13 +162,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

console.log(fs.baseUrl)
console.log(fileURLToPath(fs.baseUrl))
console.log(join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo'))
const command = await ace.create(Add, [
join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo'),
'-D',
])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href, '-D'])
command.verbose = VERBOSE

await command.exec()
Expand Down Expand Up @@ -200,10 +190,8 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

console.log(fileURLToPath(new URL('node_modules/foo', fs.baseUrl)))
console.log(new URL('node_modules/foo', fs.baseUrl).toString())
const command = await ace.create(Add, [
new URL('node_modules/foo', fs.baseUrl).toString(),
new URL('node_modules/foo', fs.baseUrl).href,
'--foo',
'--auth=session',
'-x',
Expand All @@ -213,7 +201,6 @@ test.group('Install', (group) => {
await command.exec()

const logs = command.logger.getLogs()
console.log(logs)

assert.deepInclude(logs, {
message: { foo: 'true', auth: 'session', x: 'true', verbose: VERBOSE },
Expand Down Expand Up @@ -241,7 +228,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE

await command.exec()
Expand All @@ -264,7 +251,7 @@ test.group('Install', (group) => {
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [
join(fileURLToPath(fs.baseUrl), 'node_modules', 'inexistent'),
new URL('node_modules/inexistent', fs.baseUrl).toString(),
])
command.verbose = VERBOSE

Expand All @@ -287,7 +274,7 @@ test.group('Install', (group) => {
ace.ui.switchMode('raw')
ace.prompt.trap('install').accept()

const command = await ace.create(Add, [join(fileURLToPath(fs.baseUrl), 'node_modules', 'foo')])
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
command.verbose = VERBOSE

await command.exec()
Expand Down

0 comments on commit bf64368

Please sign in to comment.