package extractor import "testing" func TestEscapeJavaScript(t *testing.T) { tests := []struct { input string want string }{ {"hello", "hello"}, {"it's", "it\\'s"}, {`back\slash`, `back\\slash`}, {`both\'`, `both\\\'`}, {"", ""}, } for _, tt := range tests { got := escapeJavaScript(tt.input) if got != tt.want { t.Errorf("escapeJavaScript(%q) = %q, want %q", tt.input, got, tt.want) } } }