| 1 |
// Copyright 2024 The Hugo Authors. All rights reserved. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
// |
| 8 |
// Unless required by applicable law or agreed to in writing, software |
| 9 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
// See the License for the specific language governing permissions and |
| 12 |
// limitations under the License. |
| 13 |
|
| 14 |
package blockquotes |
| 15 |
|
| 16 |
import ( |
| 17 |
"testing" |
| 18 |
|
| 19 |
qt "github.com/frankban/quicktest" |
| 20 |
) |
| 21 |
|
| 22 |
func TestResolveBlockQuoteAlert(t *testing.T) { |
| 23 |
t.Parallel() |
| 24 |
|
| 25 |
c := qt.New(t) |
| 26 |
|
| 27 |
tests := []struct { |
| 28 |
input string |
| 29 |
expected blockQuoteAlert |
| 30 |
}{ |
| 31 |
{ |
| 32 |
input: "[!NOTE]", |
| 33 |
expected: blockQuoteAlert{typ: "note"}, |
| 34 |
}, |
| 35 |
{ |
| 36 |
input: "[!FaQ]", |
| 37 |
expected: blockQuoteAlert{typ: "faq"}, |
| 38 |
}, |
| 39 |
{ |
| 40 |
input: "[!NOTE]+", |
| 41 |
expected: blockQuoteAlert{typ: "note", sign: "+"}, |
| 42 |
}, |
| 43 |
{ |
| 44 |
input: "[!NOTE]-", |
| 45 |
expected: blockQuoteAlert{typ: "note", sign: "-"}, |
| 46 |
}, |
| 47 |
{ |
| 48 |
input: "[!NOTE] This is a note", |
| 49 |
expected: blockQuoteAlert{typ: "note", title: "This is a note"}, |
| 50 |
}, |
| 51 |
{ |
| 52 |
input: "[!NOTE]+ This is a note", |
| 53 |
expected: blockQuoteAlert{typ: "note", sign: "+", title: "This is a note"}, |
| 54 |
}, |
| 55 |
{ |
| 56 |
input: "[!NOTE]+ This is a title\nThis is not.", |
| 57 |
expected: blockQuoteAlert{typ: "note", sign: "+", title: "This is a title"}, |
| 58 |
}, |
| 59 |
{ |
| 60 |
input: "[!NOTE]\nThis is not.", |
| 61 |
expected: blockQuoteAlert{typ: "note"}, |
| 62 |
}, |
| 63 |
} |
| 64 |
|
| 65 |
for i, test := range tests { |
| 66 |
c.Assert(resolveBlockQuoteAlert("<p>"+test.input+"</p>"), qt.Equals, test.expected, qt.Commentf("Test %d", i)) |
| 67 |
} |
| 68 |
} |