github.com/suntong/cascadia@v1.3.0/piece_test.go (about) 1 package main_test 2 3 import ( 4 "testing" 5 ) 6 7 func TestPiece(t *testing.T) { 8 testCases(t, "Piece raw html", []testCase{ 9 {"piece_raw_a", []string{ 10 "-i", "opt_piece_attr.html", "-o", "-c", "ul > li", "-p", "Source=RAW:a", 11 }}, 12 }) 13 testCases(t, "Piece Attributes", []testCase{ 14 {"id", []string{ 15 "-i", "opt_piece_attr.html", "-o", "-c", "li > a", "-p", "id=ATTR:id", 16 }}, 17 {"href", []string{ 18 "-i", "opt_piece_attr.html", "-o", "-c", "li > a", "-p", "url=ATTR:href", 19 }}, 20 {"both_fields", []string{"-i", "opt_piece_attr.html", "-o", "-c", "li > a", 21 "-p", "id=ATTR:id", "-p", "url=ATTR:href", 22 }}, 23 24 {"noexist", []string{ 25 "-i", "opt_piece_attr.html", "-o", "-c", "li > a", "-p", "NoExist=ATTR:noexist", 26 }}, 27 28 {"script_src", []string{ 29 "-i", "opt_piece_script.html", "-o", "-c", "html > head > script", "-p", "SourceJS=ATTR:src", 30 }}, 31 //{}, 32 }) 33 }