-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRemoveCommandTest.php
More file actions
88 lines (59 loc) · 2.95 KB
/
Copy pathRemoveCommandTest.php
File metadata and controls
88 lines (59 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
use Illuminate\Console\BufferedConsoleOutput;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
it("removes an installed component", function () {
$component = 'separator';
$componentDirectory = resource_path("views/components/ui/$component");
$this->artisan("sheaf:install $component")
->assertExitCode(0)
->run();
expect(File::isDirectory($componentDirectory))->toBeTrue();
$this->view("components.ui.$component.index");
$this->artisan("sheaf:remove $component")
->assertExitCode(0)
->expectsOutputToContain("Deleted directory: resources/views/components/ui/$component")
->run();
expect(File::isDirectory($componentDirectory))->toBeFalse();
$sheafLock = File::get(base_path("sheaf-lock.json"));
expect($sheafLock)->not->toContain("$component");
});
it("quits successfully when attempting to remove a non-installed component", function () {
$component = 'modal';
$componentDirectory = resource_path("views/components/ui/$component");
$this->artisan("sheaf:remove $component")
->assertExitCode(0)
->expectsOutputToContain("Component is not installed in this project.")
->run();
expect(File::isDirectory($componentDirectory))->toBeFalse();
$sheafLock = File::get(base_path("sheaf-lock.json"));
expect($sheafLock)->not->toContain("$component");
});
it("removes an installed component with dependencies", function () {
$component = 'select';
$dependency = 'icon';
$helper = 'popup';
$baseDirectory = resource_path("views/components/ui/");
//* using force option to ensure the command runs
$this->artisan("sheaf:install $component --force --internal-deps")
->assertExitCode(0)
->run();
expect(File::isDirectory("$baseDirectory/$component"))->toBeTrue();
expect(File::isDirectory("$baseDirectory/$dependency"))->toBeTrue();
expect(File::exists("$baseDirectory/$helper.blade.php"))->toBeTrue();
expect(view()->exists("components.ui.$component.index"))->toBeTrue();
expect(view()->exists("components.ui.$dependency.index"))->toBeTrue();
expect(view()->exists("components.ui.$helper"))->toBeTrue();
$this->artisan("sheaf:remove $component")
->assertExitCode(0)
->expectsOutputToContain("Deleted directory: resources/views/components/ui/$component")
->expectsOutputToContain("Deleted directory: resources/views/components/ui/$dependency")
->expectsOutputToContain("Removed internal dependency: $dependency (no longer used.)")
->expectsOutputToContain("Removed helper: $helper (no longer used.)")
->run();
expect(File::isDirectory("$baseDirectory/$component"))->toBeFalse();
expect(File::isDirectory("$baseDirectory/$dependency"))->toBeFalse();
$sheafLock = File::get(base_path("sheaf-lock.json"));
expect($sheafLock)->not->toContain("$component");
expect($sheafLock)->not->toContain("$dependency");
});