@@ -1105,17 +1105,20 @@ test("report markup marks a no-hire and an empty editor", () => {
11051105} ) ;
11061106
11071107test ( "problem markup escapes every field a problem carries" , ( ) => {
1108- const body = problemMarkup ( {
1109- source : "<script>t</script>" ,
1110- brief : [ "<script>s</script>" ] ,
1111- examples : [
1112- {
1113- input : "<script>i</script>" ,
1114- output : "<script>o</script>" ,
1115- explanation : "<script>x</script>" ,
1116- } ,
1117- ] ,
1118- } ) ;
1108+ const body = problemMarkup (
1109+ {
1110+ source : "<script>t</script>" ,
1111+ brief : [ "<script>s</script>" ] ,
1112+ examples : [
1113+ {
1114+ input : "<script>i</script>" ,
1115+ output : "<script>o</script>" ,
1116+ explanation : "<script>x</script>" ,
1117+ } ,
1118+ ] ,
1119+ } ,
1120+ { showSources : true } ,
1121+ ) ;
11191122
11201123 assert . doesNotMatch (
11211124 body ,
@@ -1143,19 +1146,39 @@ test("problem markup shows the scenario and leaves the limits to be asked for",
11431146} ) ;
11441147
11451148test ( "problem markup names the published title once, small, and only when it has one" , ( ) => {
1146- const body = problemMarkup ( {
1147- source : "Two Sum" ,
1148- brief : [ "Match the disputed charge." ] ,
1149- examples : [ { input : "a" , output : "b" } ] ,
1150- } ) ;
1149+ const body = problemMarkup (
1150+ {
1151+ source : "Two Sum" ,
1152+ brief : [ "Match the disputed charge." ] ,
1153+ examples : [ { input : "a" , output : "b" } ] ,
1154+ } ,
1155+ { showSources : true } ,
1156+ ) ;
11511157 assert . equal ( body . match ( / T w o S u m / g) . length , 1 ) ;
11521158 assert . match ( body , / < p c l a s s = " p r o b l e m - s o u r c e " > L e e t C o d e : T w o S u m < \/ p > / ) ;
11531159
1154- const unnamed = problemMarkup ( {
1160+ const unnamed = problemMarkup (
1161+ {
1162+ brief : [ "one" ] ,
1163+ examples : [ { input : "a" , output : "b" } ] ,
1164+ } ,
1165+ { showSources : true } ,
1166+ ) ;
1167+ assert . doesNotMatch ( unnamed , / p r o b l e m - s o u r c e | L e e t C o d e | u n d e f i n e d / ) ;
1168+ } ) ;
1169+
1170+ test ( "problem markup hides published titles by default" , ( ) => {
1171+ const problem = {
1172+ source : "Two Sum" ,
11551173 brief : [ "one" ] ,
11561174 examples : [ { input : "a" , output : "b" } ] ,
1157- } ) ;
1158- assert . doesNotMatch ( unnamed , / p r o b l e m - s o u r c e | L e e t C o d e | u n d e f i n e d / ) ;
1175+ } ;
1176+
1177+ assert . doesNotMatch ( problemMarkup ( problem ) , / L e e t C o d e : / ) ;
1178+ assert . match (
1179+ problemMarkup ( problem , { showSources : true } ) ,
1180+ / L e e t C o d e : T w o S u m / ,
1181+ ) ;
11591182} ) ;
11601183
11611184test ( "problem markup omits the explanation line rather than printing undefined" , ( ) => {
0 commit comments