|
@@ -93,4 +93,49 @@ describe('Filters', function() {
|
|
|
});
|
|
|
|
|
|
});
|
|
|
+
|
|
|
+ describe('htmlToAsciiMarkup', function() {
|
|
|
+
|
|
|
+ this.testPatterns = (cases) => {
|
|
|
+ const filter = $filter('htmlToAsciiMarkup');
|
|
|
+ for (let testcase of cases) {
|
|
|
+ const input = testcase[0];
|
|
|
+ const expected = testcase[1];
|
|
|
+ expect(filter(input)).toEqual(expected);
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ it('converts bold text', () => {
|
|
|
+ this.testPatterns([
|
|
|
+ ['<b>bold</b>', '*bold*'],
|
|
|
+ ['<strong>bold</strong>', '*bold*'],
|
|
|
+ ['<b><b>bold</b></b>', '**bold**'],
|
|
|
+ ['<b><strong>bold</strong></b>', '**bold**'],
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('converts italic text', () => {
|
|
|
+ this.testPatterns([
|
|
|
+ ['<i>italic</i>', '_italic_'],
|
|
|
+ ['<em>italic</em>', '_italic_'],
|
|
|
+ ['<i><em>italic</em></i>', '__italic__'],
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('converts strikethrough text', () => {
|
|
|
+ this.testPatterns([
|
|
|
+ ['<strike>strikethrough</strike>', '~strikethrough~'],
|
|
|
+ ['<del>strikethrough</del>', '~strikethrough~'],
|
|
|
+ ['<s>strikethrough</s>', '~strikethrough~'],
|
|
|
+ ['<strike><del><s>strikethrough</s></del></strike>', '~~~strikethrough~~~'],
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('combination of all', () => {
|
|
|
+ this.testPatterns([
|
|
|
+ ['<b><em><del>foo</del></em></b>', '*_~foo~_*'],
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
});
|