render(''); $this->assertMatchesRegularExpression('/]*type="submit"/', $html); $this->assertMatchesRegularExpression('/class="[^"]*\bbtn\b[^"]*"/', $html); $this->assertMatchesRegularExpression('/class="[^"]*\bbtn-primary\b[^"]*"/', $html); $this->assertStringContainsString(trans('general.save'), $html); } public function test_label_prop_overrides_default() { $html = $this->render(''); $this->assertStringContainsString('Update Widget', $html); $this->assertStringNotContainsString(trans('general.save'), $html); } public function test_icon_defaults_to_checkmark_and_can_be_disabled() { $withIcon = $this->render(''); $withoutIcon = $this->render(''); // Checkmark by default; explicit :icon="false" strips it. // Callers use false (not null) because Blade's @props resolver // treats null as "not passed" and falls back to the default. $this->assertStringContainsString('fa-check', $withIcon); $this->assertStringNotContainsString('fa-check', $withoutIcon); } public function test_caller_class_merges_with_default() { $html = $this->render(''); // Both the caller color and the base .btn should still be present. $this->assertMatchesRegularExpression('/class="[^"]*\bbtn\b[^"]*"/', $html); $this->assertMatchesRegularExpression('/class="[^"]*\bbtn-success\b[^"]*"/', $html); } public function test_disabled_defaults_to_enabled() { // The component does not bake in any disable condition. Callers // pass :disabled="config('app.lock_passwords')" (or any other // reason) at the callsite when they want it off. config()->set('app.lock_passwords', true); $html = $this->render(''); $this->assertDoesNotMatchRegularExpression('/]*\bdisabled\b/', $html); } public function test_disabled_prop_passes_through() { $disabled = $this->render(''); $enabled = $this->render(''); $this->assertMatchesRegularExpression('/]*\bdisabled\b/', $disabled); $this->assertDoesNotMatchRegularExpression('/]*\bdisabled\b/', $enabled); } public function test_forwarded_attributes_reach_the_button() { $html = $this->render(''); $this->assertMatchesRegularExpression('/]*id="my-save"/', $html); $this->assertMatchesRegularExpression('/]*data-marker="X"/', $html); } }