github.com/prebid/prebid-server/v2@v2.18.0/adapters/smaato/native_test.go (about) 1 package smaato 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6 ) 7 8 func TestExtractAdmNative(t *testing.T) { 9 tests := []struct { 10 testName string 11 adMarkup string 12 expectedAdMarkup string 13 expectedError string 14 }{ 15 { 16 testName: "extract native", 17 adMarkup: "{\"native\":{\"assets\":[]}}", 18 expectedAdMarkup: `{"assets":[]}`, 19 expectedError: "", 20 }, 21 { 22 testName: "invalid adMarkup", 23 adMarkup: "{", 24 expectedAdMarkup: "", 25 expectedError: "Invalid ad markup {.", 26 }, 27 } 28 29 for _, tt := range tests { 30 t.Run(tt.testName, func(t *testing.T) { 31 adMarkup, err := extractAdmNative(tt.adMarkup) 32 33 if tt.expectedError != "" { 34 assert.EqualError(t, err, tt.expectedError) 35 } else { 36 assert.NoError(t, err) 37 } 38 39 assert.Equal(t, tt.expectedAdMarkup, adMarkup) 40 }) 41 } 42 }