Skip to content

Commit

Permalink
added install command sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed May 29, 2024
1 parent c00956c commit 83829f7
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/Feature/Commands/InstallCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

use Illuminate\Process\PendingProcess;
use Illuminate\Support\Facades\Process;

beforeEach(function () {
Process::fake();
});

it('follows the happy path')
->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', true)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

it('installs Bun when selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', true)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

Process::assertRan('npm install bun@^1 --save-dev');
});

it('doesnt install Bun when not selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

Process::assertDidntRun('npm install bun@^1 --save-dev');
});

it('installs LightningCSS when selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'css')
->assertSuccessful();

Process::assertRan('npm install lightningcss --save-dev');
});

it('doesnt install LightningCSS when not selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

Process::assertDidntRun('npm install lightningcss --save-dev');
});

it('installs Sass when selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'sass')
->assertSuccessful();

Process::assertRan('npm install lightningcss --save-dev');
Process::assertRan('npm install sass --save-dev');
});

it('doesnt install Sass when not selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

Process::assertDidntRun('npm install lightningcss --save-dev');
Process::assertDidntRun('npm install sass --save-dev');
});

it('doesnt install anything when nothing selected', function () {
$this->artisan('bundle:install')
->expectsQuestion('Do you want to install Bun?', false)
->expectsQuestion('Would you like to use CSS loading?', 'none')
->assertSuccessful();

// Assert for absence of npm install commands
Process::assertDidntRun(function (PendingProcess $process) {
return str($process->command)->startsWith('npm install');
});
});

0 comments on commit 83829f7

Please sign in to comment.