Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal build service refactor tie in #65

Merged
merged 15 commits into from
Apr 8, 2022
Prev Previous commit
Next Next commit
Add tests for build flags
  • Loading branch information
caendesilva committed Apr 8, 2022
commit c53e5f23c81a2d2f114ed8ebbe5594055e398e08
28 changes: 28 additions & 0 deletions tests/Feature/Commands/BuildStaticSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,34 @@ public function test_progress_bars_are_skipped_when_source_files_are_empty()
->assertExitCode(0);
}

public function testHandleCleanOption()
{
$this->artisan('build --clean')
->expectsOutput('The --clean option will remove all files in the output directory before building.')
->expectsConfirmation('Are you sure?')
->assertExitCode(1);
}

public function testHandlePurgeMethod()
{
touch(Hyde::path('_site/foo.html'));
$this->artisan('build --clean --force')
->expectsOutput('Removing all files from build directory.')
->expectsOutput(' > Directory purged')
->expectsOutput(' > Recreating directories')
->assertExitCode(0);
$this->assertFileDoesNotExist(Hyde::path('_site/foo.html'));
}

public function testNodeActionOutputs()
{
$this->artisan('build --pretty --run-dev --run-prod')
->expectsOutput('Prettifying code! This may take a second.')
->expectsOutput('Building frontend assets for development! This may take a second.')
->expectsOutput('Building frontend assets for production! This may take a second.')
->assertExitCode(0);
}

private function checkIfDirectoryIsEmpty(string $directory): bool
{
$scan = scandir(Hyde::path($directory), SCANDIR_SORT_NONE);
Expand Down