How to use Contains method of html Package

Best K6 code snippet using html.Contains

administrators_test.go

Source:administrators_test.go Github

copy

Full Screen

...11 as.False(verrs.HasAny())12 res := as.HTML("/login").Post(u)13 res = as.HTML("/administrators/").Get()14 as.Equal(200, res.Code)15 as.Contains(res.Body.String(), "Administrators")16}17func (as *ActionSuite) Test_AdministratorsResource_New_Without_Logged_In_User() {18 res := as.HTML("/administrators/new/").Get()19 as.Equal(302, res.Code)20 as.Equal("/login", res.Location())21}22func (as *ActionSuite) Test_AdministratorsResource_New_Without_Privileges() {23 u := getTestAdmin()24 verrs, err := u.Create(as.DB)25 as.NoError(err)26 as.False(verrs.HasAny())27 res := as.HTML("/login").Post(u)28 res = as.HTML("/administrators/new/").Get()29 as.Equal(302, res.Code)30 as.Equal("/administrators/", res.Location())31}32func (as *ActionSuite) Test_AdministratorsResource_New_With_All_Privileges() {33 as.LoadFixture("insert privileges")34 u := getTestAdminWithPrivs()35 verrs, err := u.Create(as.DB)36 as.NoError(err)37 as.False(verrs.HasAny())38 res := as.HTML("/login").Post(u)39 res = as.HTML("/administrators/new/").Get()40 as.Equal(200, res.Code)41 as.Contains(res.Body.String(), "New Administrator")42 as.Contains(res.Body.String(), "Setup privileges")43}44func (as *ActionSuite) Test_AdministratorsResource_Show_With_All_Privileges() {45 as.LoadFixture("insert privileges")46 u := getTestAdminWithPrivs()47 verrs, err := u.Create(as.DB)48 as.NoError(err)49 as.False(verrs.HasAny())50 _ = as.HTML("/login").Post(u)51 res := as.HTML("/administrators/" + u.ID.String() + "/").Get()52 as.Equal(200, res.Code)53 // Page header54 as.Contains(res.Body.String(), "Administrator#Show")55 // Back button56 as.Contains(res.Body.String(), "Back to all Administrators")57 // Edit button (due to all priv.)58 as.Contains(res.Body.String(), "Edit")59 // Delete button60 as.Contains(res.Body.String(), "Destroy")61 // Name label62 as.Contains(res.Body.String(), "<strong>Name</strong>")63 // Admin name64 as.Contains(res.Body.String(), u.Name)65 // Username label66 as.Contains(res.Body.String(), "<strong>Username</strong>")67 // Admin username68 as.Contains(res.Body.String(), u.Username)69 // Email label70 as.Contains(res.Body.String(), "<strong>Email</strong>")71 // Admin email72 as.Contains(res.Body.String(), u.Email)73 // Privs label74 as.Contains(res.Body.String(), "<strong>Privs</strong>:")75}76func (as *ActionSuite) Test_AdministratorsResource_Show_Without_Admin_Privileges() {77 as.LoadFixture("insert privileges")78 u := getTestAdmin()79 verrs, err := u.Create(as.DB)80 as.NoError(err)81 as.False(verrs.HasAny())82 _ = as.HTML("/login").Post(u)83 res := as.HTML("/administrators/" + u.ID.String() + "/").Get()84 as.Equal(200, res.Code)85 // Page header86 as.Contains(res.Body.String(), "Administrator#Show")87 // Back button88 as.Contains(res.Body.String(), "Back to all Administrators")89 // Edit button90 as.NotContains(res.Body.String(), "Edit")91 // Delete button92 as.NotContains(res.Body.String(), "Destroy")93 // Name label94 as.Contains(res.Body.String(), "<strong>Name</strong>")95 // Admin name96 as.Contains(res.Body.String(), u.Name)97 // Username label98 as.Contains(res.Body.String(), "<strong>Username</strong>")99 // Admin username100 as.Contains(res.Body.String(), u.Username)101 // Email label102 as.Contains(res.Body.String(), "<strong>Email</strong>")103 // Admin email104 as.Contains(res.Body.String(), u.Email)105 // Privs label106 as.Contains(res.Body.String(), "<strong>Privs</strong>:")107}108func (as *ActionSuite) Test_AdministratorsResource_Create_Without_Logged_In_User() {109 res := as.HTML("/administrators/").Post(nil)110 as.Equal(302, res.Code)111 as.Equal("/login", res.Location())112}113func (as *ActionSuite) Test_AdministratorsResource_Create_Without_Privilege() {114 as.LoadFixture("insert privileges")115 u := getTestAdminWithPriv("test-admin@admin.com", "")116 verrs, err := u.Create(as.DB)117 as.NoError(err)118 as.False(verrs.HasAny())119 _ = as.HTML("/login").Post(u)120 res := as.HTML("/administrators/").Post(nil)121 as.Equal(302, res.Code)122 as.Equal("/administrators/", res.Location())123}124func (as *ActionSuite) Test_AdministratorsResource_Create_With_Priv_Priv() {125 as.LoadFixture("insert privileges")126 u := getTestAdminWithPriv("test-admin@admin.com", "Privileges")127 verrs, err := u.Create(as.DB)128 as.NoError(err)129 as.False(verrs.HasAny())130 _ = as.HTML("/login").Post(u)131 res := as.HTML("/administrators/").Post(nil)132 as.Equal(302, res.Code)133 as.Equal("/administrators/", res.Location())134}135func (as *ActionSuite) Test_AdministratorsResource_Create_With_Admin_Priv() {136 as.LoadFixture("insert privileges")137 u := getTestAdminWithPriv("test-admin@admin.com", "Users")138 verrs, err := u.Create(as.DB)139 as.NoError(err)140 as.False(verrs.HasAny())141 _ = as.HTML("/login").Post(u)142 res := as.HTML("/administrators/").Post(nil)143 as.Equal(422, res.Code)144}145func (as *ActionSuite) Test_AdministratorsResource_Create_With_All_Priv() {146 as.LoadFixture("insert privileges")147 u := getTestAdminWithPriv("test-admin@admin.com", "All")148 verrs, err := u.Create(as.DB)149 as.NoError(err)150 as.False(verrs.HasAny())151 _ = as.HTML("/login").Post(u)152 res := as.HTML("/administrators/").Post(nil)153 as.Equal(500, res.Code)154}155func (as *ActionSuite) Test_AdministratorsResource_Create_With_Admin_Priv_Priv_Data() {156 as.LoadFixture("insert privileges")157 u := getTestAdminWithPriv("test-admin@admin.com", "All")158 newAdmin := getTestAdminWithPriv("new-test-admin@admin.com", "")159 verrs, err := u.Create(as.DB)160 as.NoError(err)161 as.False(verrs.HasAny())162 _ = as.HTML("/login").Post(u)163 res := as.HTML("/administrators/").Post(newAdmin)164 as.Equal(302, res.Code)165 as.Contains(res.Location(), "/administrators/")166}167func (as *ActionSuite) Test_AdministratorsResource_Create_Email_Duplication() {168 as.LoadFixture("insert privileges")169 u := getTestAdminWithPriv("test-admin@admin.com", "All")170 verrs, err := u.Create(as.DB)171 as.NoError(err)172 as.False(verrs.HasAny())173 other := getTestAdminWithPriv("other-test-admin@admin.com", "All")174 verrs, err = other.Create(as.DB)175 as.NoError(err)176 as.False(verrs.HasAny())177 _ = as.HTML("/login").Post(u)178 res := as.HTML("/administrators/").Post(other)179 as.Equal(500, res.Code)180}181func (as *ActionSuite) Test_AdministratorsResource_Edit_Without_Logged_In_User() {182 res := as.HTML("/administrators/invalid-id/edit/").Get()183 as.Equal(302, res.Code)184 as.Equal("/login", res.Location())185}186func (as *ActionSuite) Test_AdministratorsResource_Edit_Without_Privilege() {187 as.LoadFixture("insert privileges")188 u := getTestAdminWithPriv("test-admin@admin.com", "Privileges")189 verrs, err := u.Create(as.DB)190 as.NoError(err)191 as.False(verrs.HasAny())192 _ = as.HTML("/login").Post(u)193 res := as.HTML("/administrators/invalid-id/edit/").Get()194 as.Equal(302, res.Code)195 as.Equal("/administrators/", res.Location())196}197func (as *ActionSuite) Test_AdministratorsResource_Edit_With_Priv_Priv() {198 as.LoadFixture("insert privileges")199 u := getTestAdminWithPriv("test-admin@admin.com", "Privileges")200 verrs, err := u.Create(as.DB)201 as.NoError(err)202 as.False(verrs.HasAny())203 _ = as.HTML("/login").Post(u)204 res := as.HTML("/administrators/invalid-id/edit/").Get()205 as.Equal(302, res.Code)206 as.Equal("/administrators/", res.Location())207}208func (as *ActionSuite) Test_AdministratorsResource_Edit_With_Admin_Priv_Fake_User() {209 as.LoadFixture("insert privileges")210 u := getTestAdminWithPriv("test-admin@admin.com", "All")211 verrs, err := u.Create(as.DB)212 as.NoError(err)213 as.False(verrs.HasAny())214 _ = as.HTML("/login").Post(u)215 res := as.HTML("/administrators/invalid-id/edit/").Get()216 as.Equal(404, res.Code)217}218func (as *ActionSuite) Test_AdministratorsResource_Edit_With_Admin_Priv_Valid_User() {219 as.LoadFixture("insert privileges")220 u := getTestAdminWithPriv("test-admin@admin.com", "All")221 verrs, err := u.Create(as.DB)222 as.NoError(err)223 as.False(verrs.HasAny())224 other := getTestAdminWithPriv("other-test-admin@admin.com", "All")225 verrs, err = other.Create(as.DB)226 as.NoError(err)227 as.False(verrs.HasAny())228 _ = as.HTML("/login").Post(u)229 res := as.HTML("/administrators/" + other.ID.String() + "/edit/").Get()230 as.Equal(200, res.Code)231 // Page header232 as.Contains(res.Body.String(), "<h1>Edit Administrator</h1>")233 // Form234 as.Contains(res.Body.String(), "<form action=\"/administrators/"+other.ID.String()+"/\" id=\"administrator-form\" method=\"POST\">")235 // Name label236 as.Contains(res.Body.String(), "<label>Name</label>")237 // Admin name238 as.Contains(res.Body.String(), other.Name)239 // Username label240 as.Contains(res.Body.String(), "<label>Username</label>")241 // Admin username242 as.Contains(res.Body.String(), other.Username)243 // Email label244 as.Contains(res.Body.String(), "<label>Email</label>")245 // Admin email246 as.Contains(res.Body.String(), other.Email)247 // Privs label248 as.Contains(res.Body.String(), "Setup privileges")249}250func (as *ActionSuite) Test_AdministratorsResource_Update_Without_Logged_In_User() {251 res := as.HTML("/administrators/fakeif/").Put(nil)252 as.Equal(302, res.Code)253 as.Equal("/login", res.Location())254}255func (as *ActionSuite) Test_AdministratorsResource_Update_Without_Privilege() {256 as.LoadFixture("insert privileges")257 u := getTestAdminWithPriv("test-admin@admin.com", "")258 verrs, err := u.Create(as.DB)259 as.NoError(err)260 as.False(verrs.HasAny())261 _ = as.HTML("/login").Post(u)262 res := as.HTML("/administrators/fakeid/").Put(nil)263 as.Equal(302, res.Code)264 as.Equal("/administrators/", res.Location())265}266func (as *ActionSuite) Test_AdministratorsResource_Update_With_Priv_Priv() {267 as.LoadFixture("insert privileges")268 u := getTestAdminWithPriv("test-admin@admin.com", "Privileges")269 verrs, err := u.Create(as.DB)270 as.NoError(err)271 as.False(verrs.HasAny())272 _ = as.HTML("/login").Post(u)273 res := as.HTML("/administrators/fakeid/").Put(nil)274 as.Equal(302, res.Code)275 as.Equal("/administrators/", res.Location())276}277func (as *ActionSuite) Test_AdministratorsResource_Update_With_Admin_Priv() {278 as.LoadFixture("insert privileges")279 u := getTestAdminWithPriv("test-admin@admin.com", "Users")280 verrs, err := u.Create(as.DB)281 as.NoError(err)282 as.False(verrs.HasAny())283 _ = as.HTML("/login").Post(u)284 res := as.HTML("/administrators/fakeid/").Put(nil)285 as.Equal(404, res.Code)286}287func (as *ActionSuite) Test_AdministratorsResource_Update_With_All_Priv() {288 as.LoadFixture("insert privileges")289 u := getTestAdminWithPriv("test-admin@admin.com", "All")290 verrs, err := u.Create(as.DB)291 as.NoError(err)292 as.False(verrs.HasAny())293 _ = as.HTML("/login").Post(u)294 res := as.HTML("/administrators/fakeid/").Put(nil)295 as.Equal(404, res.Code)296}297func (as *ActionSuite) Test_AdministratorsResource_Update_With_Admin_Priv_Priv_Data() {298 as.LoadFixture("insert privileges")299 u := getTestAdminWithPriv("test-admin@admin.com", "All")300 verrs, err := u.Create(as.DB)301 as.NoError(err)302 as.False(verrs.HasAny())303 other := getTestAdminWithPriv("other-test-admin@admin.com", "All")304 verrs, err = other.Create(as.DB)305 as.NoError(err)306 as.False(verrs.HasAny())307 _ = as.HTML("/login").Post(u)308 res := as.HTML("/administrators/" + other.ID.String() + "/").Put(other)309 as.Equal(302, res.Code)310 as.Contains(res.Location(), "/administrators/")311}312func (as *ActionSuite) Test_AdministratorsResource_Destroy_Without_Logged_In_User() {313 res := as.HTML("/administrators/fakeif/").Delete()314 as.Equal(302, res.Code)315 as.Equal("/login", res.Location())316}317func (as *ActionSuite) Test_AdministratorsResource_Destroy_Without_Privilege() {318 as.LoadFixture("insert privileges")319 u := getTestAdminWithPriv("test-admin@admin.com", "")320 verrs, err := u.Create(as.DB)321 as.NoError(err)322 as.False(verrs.HasAny())323 _ = as.HTML("/login").Post(u)324 res := as.HTML("/administrators/fakeif/").Delete()...

Full Screen

Full Screen

premailer_test.go

Source:premailer_test.go Github

copy

Full Screen

...37 p, err := NewPremailerFromString(html, nil)38 assert.Nil(t, err)39 resultHTML, err := p.Transform()40 assert.Nil(t, err)41 assert.Contains(t, resultHTML, "<h1 style=\"width:50px;color:red\" width=\"50\">Hi!</h1>")42 assert.Contains(t, resultHTML, "<h2 style=\"vertical-align:top\">There</h2>")43 assert.Contains(t, resultHTML, "<h3 style=\"text-align:right\">Hello</h3>")44 assert.Contains(t, resultHTML, "<p><strong style=\"text-decoration:none\">Yes!</strong></p>")45 assert.Contains(t, resultHTML, "<div style=\"background-color:green\">Green color</div>")46}47func TestDataPremailerIgnore(t *testing.T) {48 html := `<html>49 <head>50 <title>Title</title>51 <style type="text/css" data-premailer="ignore">52 h1, h2 {53 color:red;54 }55 strong {56 text-decoration:none57 }58 </style>59 </head>60 <body>61 <h1>Hi!</h1>62 <p><strong>Yes!</strong></p>63 </body>64 </html>`65 p, err := NewPremailerFromString(html, nil)66 assert.Nil(t, err)67 resultHTML, err := p.Transform()68 assert.Nil(t, err)69 assert.Contains(t, resultHTML, "<h1>Hi!</h1>")70 assert.Contains(t, resultHTML, "<p><strong>Yes!</strong></p>")71}72func TestWithInline(t *testing.T) {73 html := `<html>74 <head>75 <title>Title</title>76 <style type="text/css">77 h1, h2 {78 width: 50px;79 color:red;80 }81 strong {82 text-decoration:none83 }84 </style>85 </head>86 <body>87 <h1 style="width: 100px;">Hi!</h1>88 <p><strong>Yes!</strong></p>89 </body>90 </html>`91 p, err := NewPremailerFromString(html, nil)92 assert.Nil(t, err)93 resultHTML, err := p.Transform()94 assert.Nil(t, err)95 assert.Contains(t, resultHTML, "<h1 style=\"color:red;width:100px\" width=\"100\">Hi!</h1>")96 assert.Contains(t, resultHTML, "<p><strong style=\"text-decoration:none\">Yes!</strong></p>")97 assert.NotContains(t, resultHTML, "<style type=\"text/css\">")98}99func TestWithZeroLength(t *testing.T) {100 html := `<html>101 <head>102 <title>Title</title>103 <style type="text/css">104 h1, h2 {105 width: 0;106 height: 0;107 color:red;108 }109 </style>110 </head>111 <body>112 <h1>Hi!</h1>113 <p><strong>Yes!</strong></p>114 </body>115 </html>`116 p, err := NewPremailerFromString(html, nil)117 assert.Nil(t, err)118 resultHTML, err := p.Transform()119 assert.Nil(t, err)120 assert.Contains(t, resultHTML, "<h1 style=\"width:0;height:0;color:red\" width=\"0\" height=\"0\">Hi!</h1>")121 assert.NotContains(t, resultHTML, "<style type=\"text/css\">")122}123func TestPseudoSelectors(t *testing.T) {124 html := `<html>125 <head>126 <title>Title</title>127 <style type="text/css">128 a:active {129 color: red;130 font-size: 12px;131 }132 a:first-child {133 color: green;134 }135 </style>136 </head>137 <body>138 <h1>Hi!</h1>139 <p>140 <a href="/home">Yes!</a>141 <a href="/away">No!</a>142 </p>143 </body>144 </html>`145 p, err := NewPremailerFromString(html, nil)146 assert.Nil(t, err)147 resultHTML, err := p.Transform()148 assert.Nil(t, err)149 assert.Contains(t, resultHTML, "<a href=\"/home\" style=\"color:green\">Yes!</a>")150 assert.Contains(t, resultHTML, "<style type=\"text/css\">")151}152func TestRemoveClass(t *testing.T) {153 html := `<html>154 <head>155 <title>Title</title>156 <style type="text/css">157 h1, h2 {158 color:red;159 }160 .big {161 font-size: 40px;162 width: 150px;163 }164 </style>165 </head>166 <body>167 <h1 class="big">Hi!</h1>168 <p><strong>Yes!</strong></p>169 </body>170 </html>`171 options := &Options{}172 options.RemoveClasses = true173 p, err := NewPremailerFromString(html, options)174 assert.Nil(t, err)175 resultHTML, err := p.Transform()176 assert.Nil(t, err)177 assert.Contains(t, resultHTML, "<h1 style=\"color:red;font-size:40px;width:150px\">Hi!</h1>")178 assert.Contains(t, resultHTML, "<p><strong>Yes!</strong></p>")179}180func TestCssToAttributesFalse(t *testing.T) {181 html := `<html>182 <head>183 <title>Title</title>184 <style type="text/css">185 h1, h2 {186 color:red;187 }188 .wide {189 width: 1000px;190 }191 </style>192 </head>193 <body>194 <h1 class="wide">Hi!</h1>195 <p><strong>Yes!</strong></p>196 </body>197 </html>`198 options := &Options{}199 options.CssToAttributes = false200 p, err := NewPremailerFromString(html, options)201 assert.Nil(t, err)202 resultHTML, err := p.Transform()203 assert.Nil(t, err)204 assert.Contains(t, resultHTML, "<h1 class=\"wide\" style=\"color:red;width:1000px\">Hi!</h1>")205 assert.Contains(t, resultHTML, "<p><strong>Yes!</strong></p>")206}207func TestWithImportant(t *testing.T) {208 html := `<html>209 <head>210 <title>Title</title>211 <style type="text/css">212 h1, h2 {213 color:red;214 }215 p {216 width: 100px !important;217 color: blue218 }219 .wide {220 width: 1000px;221 }222 </style>223 </head>224 <body>225 <h1>Hi!</h1>226 <p class="wide"><strong>Yes!</strong></p>227 </body>228 </html>`229 p, err := NewPremailerFromString(html, NewOptions())230 assert.Nil(t, err)231 resultHTML, err := p.Transform()232 assert.Nil(t, err)233 assert.Contains(t, resultHTML, "<h1 style=\"color:red\">Hi!</h1>")234 assert.Contains(t, resultHTML, "<p class=\"wide\" style=\"color:blue;width:100px\" width=\"100\"><strong>Yes!</strong></p>")235}236func TestWithKeepImportant(t *testing.T) {237 html := `<html>238 <head>239 <title>Title</title>240 <style type="text/css">241 h1, h2 {242 color:red;243 }244 p {245 width: 100px !important;246 color: blue247 }248 .wide {249 width: 1000px;250 } 251 </style>252 </head>253 <body>254 <h1>Hi!</h1>255 <p class="wide"><strong>Yes!</strong></p>256 </body>257 </html>`258 options := NewOptions()259 options.KeepBangImportant = true260 p, err := NewPremailerFromString(html, options)261 assert.Nil(t, err)262 resultHTML, err := p.Transform()263 assert.Nil(t, err)264 assert.Contains(t, resultHTML, "<h1 style=\"color:red\">Hi!</h1>")265 assert.Contains(t, resultHTML, "<p class=\"wide\" style=\"color:blue;width:100px !important\" width=\"100\"><strong>Yes!</strong></p>")266}267func TestWithMediaRule(t *testing.T) {268 html := `<html>269 <head>270 <title>Title</title>271 <style type="text/css">272 h1, h2 {273 color:red;274 }275 p {276 width: 100px !important;277 color: blue278 }279 .wide {280 width: 1000px;281 }282 @media all and (min-width: 62em) {283 h1 {284 font-size: 55px;285 line-height: 60px;286 padding-top: 0;287 padding-bottom: 5px288 }289 }290 </style>291 </head>292 <body>293 <h1>Hi!</h1>294 <p class="wide"><strong>Yes!</strong></p>295 </body>296 </html>`297 p, err := NewPremailerFromString(html, NewOptions())298 assert.Nil(t, err)299 resultHTML, err := p.Transform()300 assert.Nil(t, err)301 assert.Contains(t, resultHTML, "<h1 style=\"color:red\">Hi!</h1>")302 assert.Contains(t, resultHTML, "<p class=\"wide\" style=\"color:blue;width:100px\" width=\"100\"><strong>Yes!</strong></p>")303 assert.Contains(t, resultHTML, "@media all and (min-width: 62em){")304 assert.Contains(t, resultHTML, "font-size: 55px !important;")305 assert.Contains(t, resultHTML, "line-height: 60px !important;")306 assert.Contains(t, resultHTML, "padding-bottom: 5px !important")307 assert.Contains(t, resultHTML, "padding-top: 0 !important")308}309func TestWithMediaAttribute(t *testing.T) {310 html := `<html>311 <head>312 <title>Title</title>313 <style type="text/css">314 h1, h2 {315 color:red;316 }317 p {318 width: 100px !important;319 color: blue320 }321 .wide {322 width: 1000px;323 }324 </style>325 <style type="text/css" media="all and (min-width: 62em)">326 h1 {327 font-size: 55px;328 line-height: 60px;329 padding-top: 0;330 padding-bottom: 5px331 }332 </style>333 <style type="text/css" media="all">334 h3 {335 color: black;336 }337 </style>338 <style>339 </style>340 </head>341 <body>342 <h1>Hi!</h1>343 <p class="wide"><strong>Yes!</strong></p>344 <h3>Hi, all media style!</h3>345 </body>346 </html>`347 p, err := NewPremailerFromString(html, NewOptions())348 assert.Nil(t, err)349 resultHTML, err := p.Transform()350 assert.Nil(t, err)351 assert.Contains(t, resultHTML, "<h1 style=\"color:red\">Hi!</h1>")352 assert.Contains(t, resultHTML, "<p class=\"wide\" style=\"color:blue;width:100px\" width=\"100\"><strong>Yes!</strong></p>")353 assert.Contains(t, resultHTML, "<h3 style=\"color:black\">Hi, all media style!</h3>")354 assert.Contains(t, resultHTML, "<style type=\"text/css\" media=\"all and (min-width: 62em)\">")355 assert.Contains(t, resultHTML, "font-size: 55px;")356 assert.Contains(t, resultHTML, "line-height: 60px;")357 assert.Contains(t, resultHTML, "padding-top: 0;")358 assert.Contains(t, resultHTML, "padding-bottom: 5px")359 assert.NotContains(t, resultHTML, "<style type=\"text/css\" media=\"all\">")360 assert.NotContains(t, resultHTML, "color: black;")361}362func TestIndexOutOfRange(t *testing.T) {363 html := `<html>364 <head>365 <title>Title</title>366 <style type="text/css">367 h1, h2 {368 color:red;369 }370 p {371 width: 100px !important;372 color: blue373 }374 .wide {375 width: 1000px;376 }377 </style>378 <style type="text/css" media="all and (min-width: 62em)">379 h1 {380 font-size: 55px;381 line-height: 60px;382 padding-top: 0;383 padding-bottom: 5px384 }385 </style>386 <style>387 .some {388 color: red;389 }390 </style>391 </head>392 <body>393 <h1>Hi!</h1>394 <p class="wide"><strong>Yes!</strong></p>395 </body>396 </html>`397 p, err := NewPremailerFromString(html, NewOptions())398 assert.Nil(t, err)399 resultHTML, err := p.Transform()400 assert.Nil(t, err)401 assert.Contains(t, resultHTML, "<h1 style=\"color:red\">Hi!</h1>")402 assert.Contains(t, resultHTML, "<p class=\"wide\" style=\"color:blue;width:100px\" width=\"100\"><strong>Yes!</strong></p>")403 assert.Contains(t, resultHTML, "<style type=\"text/css\" media=\"all and (min-width: 62em)\">")404 assert.Contains(t, resultHTML, "font-size: 55px;")405 assert.Contains(t, resultHTML, "line-height: 60px;")406 assert.Contains(t, resultHTML, "padding-top: 0;")407 assert.Contains(t, resultHTML, "padding-bottom: 5px")408}409func TestSpecificity(t *testing.T) {410 html := `<html>411 <head>412 <title>Title</title>413 <style type="text/css">414 table.bar-chart td.bar-area {415 padding: 10px;416 }417 table { width: 91%; }418 table { width: 92%; }419 table { width: 93%; }420 table { width: 94%; }421 table { width: 95%; }422 table { width: 96%; }423 table { width: 97%; }424 table.bar-chart td {425 padding: 5px;426 }427 </style>428 </head>429 <body>430 <table class="bar-chart">431 <tr><td>1</td></tr>432 <tr><td class="bar-area">2</td></tr>433 </table>434 </body>435 </html>`436 p, err := NewPremailerFromString(html, NewOptions())437 assert.Nil(t, err)438 resultHTML, err := p.Transform()439 assert.Nil(t, err)440 assert.Contains(t, resultHTML, `<tr><td style="padding:5px">1</td></tr>`)441 assert.Contains(t, resultHTML, `<tr><td class="bar-area" style="padding:10px">2</td></tr>`)442}...

Full Screen

Full Screen

graphiql_test.go

Source:graphiql_test.go Github

copy

Full Screen

...14 isMPS: false,15 }16 out, err := testObject.addQuorumHTML(graphiql)17 assert.NoError(t, err)18 assert.NotContains(t, string(out), "access-token")19 assert.NotContains(t, string(out), "psi")20}21func TestAddQuorumHTML_whenMPS(t *testing.T) {22 testObject := GraphiQL{23 authManagerFunc: func() (security.AuthenticationManager, error) {24 return security.NewDisabledAuthenticationManager(), nil25 },26 isMPS: true,27 }28 out, err := testObject.addQuorumHTML(graphiql)29 assert.NoError(t, err)30 html := string(out)31 assert.NotContains(t, html, "access-token")32 assert.Contains(t, html, "psi")33}34func TestAddQuorumHTML_whenRPCSecured(t *testing.T) {35 testObject := GraphiQL{36 authManagerFunc: func() (security.AuthenticationManager, error) {37 return &StubAuthenticationManager{}, nil38 },39 isMPS: false,40 }41 out, err := testObject.addQuorumHTML(graphiql)42 assert.NoError(t, err)43 html := string(out)44 assert.Contains(t, html, "access-token")45 assert.NotContains(t, html, "psi")46}47func TestAddQuorumHTML_whenMPSAndRPCSecured(t *testing.T) {48 testObject := GraphiQL{49 authManagerFunc: func() (security.AuthenticationManager, error) {50 return &StubAuthenticationManager{}, nil51 },52 isMPS: true,53 }54 out, err := testObject.addQuorumHTML(graphiql)55 assert.NoError(t, err)56 html := string(out)57 assert.Contains(t, html, "access-token")58 assert.Contains(t, html, "psi")59}60type StubAuthenticationManager struct {61}62func (s *StubAuthenticationManager) Authenticate(_ context.Context, _ string) (*proto.PreAuthenticatedAuthenticationToken, error) {63 panic("implement me")64}65func (s *StubAuthenticationManager) IsEnabled(_ context.Context) (bool, error) {66 return true, nil67}...

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 node := html.Node{4 }5 fmt.Println(html.Contains(&node))6}7Recommended Posts: HTML | Contains() method

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body><h1>Hello!</h1></body></html>"))4 if err != nil {5 log.Fatal(err)6 }7 fmt.Println(Contains(doc, func(n *html.Node) bool {8 }))9}

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.Contains("Hello World", "Hello"))4 fmt.Println(html.Contains("Hello World", "World"))5 fmt.Println(html.Contains("Hello World", "world"))6 fmt.Println(html.Contains("Hello World", "Hello World"))7}8import (9func main() {10 fmt.Println(html.EscapeString("Hello World"))11}12import (13func main() {14 fmt.Println(html.UnescapeString("Hello World"))15}16import (17func main() {18 fmt.Println(html.EscapeString("Hello World"))19}20import (21func main() {22 fmt.Println(html.UnescapeString("Hello World"))23}24import (25func main() {26 fmt.Println(html.QueryEscape("Hello World"))27}28import (29func main() {30 fmt.Println(html.QueryUnescape("Hello World"))31}32import (33func main() {34 fmt.Println(html.UnescapeString("Hello World"))35}36import (37func main() {38 fmt.Println(html.EscapeString("Hello World"))39}40import (

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("Hello, playground"))4 fmt.Println(html.UnescapeString("Hello, playground"))5}6import (7func main() {8 fmt.Println(template.HTMLEscapeString("Hello, playground"))9 fmt.Println(template.HTMLEscape(nil, []byte("Hello, playground")))10}11import (12func main() {13 fmt.Println(url.QueryEscape("Hello, playground"))14 fmt.Println(url.QueryUnescape("Hello, playground"))15}16import (17func main() {18 fmt.Println(json.Valid([]byte("Hello, playground")))19}20import (21func main() {22 fmt.Println(xml.EscapeText([]byte("Hello, playground")))23}24import (25func main() {26 fmt.Println(time.Now())27}28import (29func main() {30 fmt.Println(time.Now().Format(time.RFC3339))31}32import (33func main()

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 content, err := ioutil.ReadFile("1.html")4 if err != nil {5 fmt.Println("Error in reading file")6 }7 contentString := string(content)8 htmlContent, err := html.Parse(strings.NewReader(contentString))9 if err != nil {10 fmt.Println("Error in parsing html")11 }12 if html.Contains(htmlContent, "Hello") {13 fmt.Println("The content contains the given string")14 } else {15 fmt.Println("The content does not contain the given str

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3n, err := html.Parse(strings.NewReader(data))4if err != nil {5fmt.Println(err)6}7title := findTitle(n)8fmt.Println(title)9}10func findTitle(n *html.Node) string {11if n.Type == html.ElementNode && n.Data == "title" {12}13for c := n.FirstChild; c != nil; c = c.NextSibling {14title := findTitle(c)15if title != "" {16}17}18}19type Node struct {20}21type Attribute struct {22}

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader(htmlCode))4 if err != nil {5 fmt.Println(err)6 }7 if contains(doc, "title") {8 fmt.Println("Tag exists")9 } else {10 fmt.Println("Tag does not exist")11 }12}13func contains(n *html.Node, tag string) bool {14 if n.Type == html.ElementNode && n.Data == tag {15 }16 for c := n.FirstChild; c != nil; c = c.NextSibling {17 if contains(c, tag) {18 }19 }20}

Full Screen

Full Screen

Contains

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(strings.Contains("Hello, World", "Hello"))4 fmt.Println(strings.Contains("Hello, World", "World"))5 fmt.Println(strings.Contains("Hello, World", "world"))6 fmt.Println(strings.Contains("Hello, World", "Hello, World"))7 fmt.Println(strings.Contains("Hello, World", "Hello, Universe"))8}9import (10func main() {11 fmt.Println(strings.ContainsAny("Hello, World", "H"))12 fmt.Println(strings.ContainsAny("Hello, World", "W"))13 fmt.Println(strings.ContainsAny("Hello, World", "w"))14 fmt.Println(strings.ContainsAny("Hello, World", "H, W"))15 fmt.Println(strings.ContainsAny("Hello, World", "H, U"))16}17import (18func main() {19 fmt.Println(strings.ContainsRune("Hello, World", 'H'))20 fmt.Println(strings.ContainsRune("Hello, World", 'W'))21 fmt.Println(strings.ContainsRune("Hello, World", 'w'))22 fmt.Println(strings.ContainsRune("Hello, World", 'H'))23 fmt.Println(strings.ContainsRune("Hello, World", 'U'))24}25import (26func main() {27 fmt.Println(strings.Count("Hello, World", "l"))28 fmt.Println(strings.Count("Hello, World", "o"))29 fmt.Println(strings.Count("Hello, World", "world"))30 fmt.Println(strings.Count("

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful