Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Jul 8, 2024
1 parent 94c8845 commit 826400f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 53 deletions.
13 changes: 8 additions & 5 deletions integration/__tests__/missing-information.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,35 @@ import { SeccoCLI } from '../helpers/invoke-cli'

const missingSourcePackagesLocation = join(__dirname, '..', 'fixtures', 'missing-source-packages')

describe('missing .seccorc', () => {
describe('missing information', () => {
it('should display error when no .seccorc or env var is found', () => {
const [exitCode, logs] = SeccoCLI().setFixture('empty').invoke([''])

logs.should.contain('No `.seccorc` file found in')
logs.should.contain('Please run `secco init` to create a new `.seccorc` file.')
expect(exitCode).toBe(0)
})
})

describe('missing package.json', () => {
it('should display error when no package.json is found', () => {
const [exitCode, logs] = SeccoCLI().setFixture('existing-config-file').invoke([''])

logs.should.contain('No `package.json` found in')
logs.should.contain('Current directory must contain a `package.json` file.')
expect(exitCode).toBe(0)
})
})

describe('missing source packages', () => {
it('should display error when no source package is found in package.json', () => {
const [exitCode, logs] = SeccoCLI().setFixture('missing-source-packages').setEnv({ SECCO_SOURCE_PATH: missingSourcePackagesLocation }).invoke([''])

logs.should.contain(`You haven't got any source dependencies in your current \`package.json\`.`)
logs.should.contain(`If you only want to use \`secco\` you'll need to add the dependencies to your \`package.json\`.`)
expect(exitCode).toBe(0)
})

it('should display error when source.path is incorrect', () => {
const [exitCode, logs] = SeccoCLI().setFixture('missing-source-packages').setEnv({ SECCO_SOURCE_PATH: '/Users/secco' }).invoke([''])

logs.should.contain(`[fatal] Couldn't find package.json in /Users/secco`)
expect(exitCode).toBe(0)
})
})
54 changes: 6 additions & 48 deletions integration/__tests__/scan-once.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ describe.sequential('scan-once', () => {

beforeAll(async () => {
app = await presets.kitchenSink.commit()

process.env.VERDACCIO_PORT = '4873'
})

afterAll(async () => {
await app.cleanup()
})

it('should run Verdaccio with --force-verdaccio', () => {
const [exitCode, logs] = app.cli(['--scan-once', '--force-verdaccio'], { verbose: true })
const [exitCode, logs] = app.cli(['--scan-once', '--force-verdaccio', '--verbose'])

logs.should.contain('[log] [Verdaccio] Starting server...')
logs.should.contain('[log] [Verdaccio] Started successfully!')
Expand All @@ -38,24 +40,6 @@ describe.sequential('scan-once', () => {
expect(exitCode).toBe(0)
})

it('verbose should be enabled through --verbose flag', () => {
const [exitCode, logs] = app.cli(['--verbose', '--scan-once'])

logs.should.contain('[debug] Found 1 package in source.')
logs.should.contain('[debug] Found 1 package in destination.')

expect(exitCode).toBe(0)
})

it('verbose should be enabled through VERBOSE env var', () => {
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true })

logs.should.contain('[debug] Found 1 package in source.')
logs.should.contain('[debug] Found 1 package in destination.')

expect(exitCode).toBe(0)
})

it('should copy files on consecutive runs', () => {
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true })

Expand All @@ -79,6 +63,8 @@ describe.sequential('scan-once', () => {
if (process.env.INTEGRATION_PM_NAME === 'pnpm') {
restorePnpmFixture = await renamePnpmWorkspaceFixture(app)
}

process.env.VERDACCIO_PORT = '4874'
})

afterAll(async () => {
Expand All @@ -89,7 +75,7 @@ describe.sequential('scan-once', () => {
}
})

it('should run Verdaccio with --force-verdaccio', () => {
it('should work (with Verdaccio by default)', () => {
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true })

logs.should.contain('[log] [Verdaccio] Starting server...')
Expand All @@ -102,33 +88,5 @@ describe.sequential('scan-once', () => {

expect(exitCode).toBe(0)
})

it('verbose should be enabled through --verbose flag', () => {
const [exitCode, logs] = app.cli(['--verbose', '--scan-once'])

logs.should.contain('[debug] Found 1 package in source.')
logs.should.contain('[debug] Found 1 package in destination.')

expect(exitCode).toBe(0)
})

it('verbose should be enabled through VERBOSE env var', () => {
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true })

logs.should.contain('[debug] Found 1 package in source.')
logs.should.contain('[debug] Found 1 package in destination.')

expect(exitCode).toBe(0)
})

it('should use Verdaccio on consecutive runs', () => {
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true })

logs.should.contain('[log] [Verdaccio] Starting server...')
logs.should.contain('[success] Installation finished successfully!')
logs.should.contain('[info] Copied 0 files. Exiting...')

expect(exitCode).toBe(0)
})
})
})

0 comments on commit 826400f

Please sign in to comment.