github.com/secoba/wails/v2@v2.6.4/pkg/mac/notification_darwin_test.go (about)

     1  package mac
     2  
     3  import "testing"
     4  
     5  func TestShowNotification(t *testing.T) {
     6  	type args struct {
     7  		title    string
     8  		subtitle string
     9  		message  string
    10  		sound    string
    11  	}
    12  	tests := []struct {
    13  		name     string
    14  		title    string
    15  		subtitle string
    16  		message  string
    17  		sound    string
    18  		wantErr  bool
    19  	}{
    20  		{"No message", "", "", "", "", false},
    21  		{"Title only", "I am a Title", "", "", "", false},
    22  		{"SubTitle only", "", "I am a subtitle", "", "", false},
    23  		{"Message only", "", "", "I am a message!", "", false},
    24  		{"Sound only", "", "", "", "submarine.aiff", false},
    25  		{"Full", "Title", "Subtitle", "This is a long message to show that text gets wrapped in a notification", "submarine.aiff", false},
    26  	}
    27  	for _, tt := range tests {
    28  		t.Run(tt.name, func(t *testing.T) {
    29  			if err := ShowNotification(tt.title, tt.subtitle, tt.message, tt.sound); (err != nil) != tt.wantErr {
    30  				t.Errorf("ShowNotification() error = %v, wantErr %v", err, tt.wantErr)
    31  			}
    32  		})
    33  	}
    34  }