From c416dcdfae16ba6edfce699f7902dfd194268636 Mon Sep 17 00:00:00 2001
From: Piotr Kowalczuk
Date: Fri, 17 Apr 2015 00:38:27 +0200
Subject: [PATCH] Selection.AttrOr test
---
property_test.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/property_test.go b/property_test.go
index 38061f0..ee6f821 100644
--- a/property_test.go
+++ b/property_test.go
@@ -14,6 +14,14 @@ func TestAttrExists(t *testing.T) {
}
}
+func TestAttrOr(t *testing.T) {
+ if val := Doc().Find("a").AttrOr("fake-attribute", "alternative"); val != "alternative" {
+ t.Error("Expected an alternative value for 'fake-attribute' attribute.")
+ } else {
+ t.Logf("Value returned for not existing attribute: %v.", val)
+ }
+}
+
func TestAttrNotExist(t *testing.T) {
if val, ok := Doc().Find("div.row-fluid").Attr("href"); ok {
t.Errorf("Expected no value for the href attribute, got %v.", val)