|
1 | | -describe('markdown-toolbbar-element', function() { |
| 1 | +describe('markdown-toolbar-element', function() { |
2 | 2 | describe('element creation', function() { |
3 | 3 | it('creates from document.createElement', function() { |
4 | 4 | const el = document.createElement('markdown-toolbar') |
@@ -70,10 +70,13 @@ describe('markdown-toolbbar-element', function() { |
70 | 70 | <markdown-toolbar for="textarea_id"> |
71 | 71 | <md-bold>bold</md-bold> |
72 | 72 | <md-header>header</md-header> |
| 73 | + <md-header level="1">h1</md-header> |
| 74 | + <md-header level="10">h1</md-header> |
73 | 75 | <md-italic>italic</md-italic> |
74 | 76 | <md-quote>quote</md-quote> |
75 | 77 | <md-code>code</md-code> |
76 | 78 | <md-link>link</md-link> |
| 79 | + <md-image>image</md-image> |
77 | 80 | <md-unordered-list>unordered-list</md-unordered-list> |
78 | 81 | <md-ordered-list>ordered-list</md-ordered-list> |
79 | 82 | <md-task-list>task-list</md-task-list> |
@@ -489,5 +492,51 @@ describe('markdown-toolbbar-element', function() { |
489 | 492 | assert.equal("GitHub's [homepage](|url|)", visualValue()) |
490 | 493 | }) |
491 | 494 | }) |
| 495 | + |
| 496 | + describe('images', function() { |
| 497 | + it('inserts image syntax with cursor in description', function() { |
| 498 | + setVisualValue('|') |
| 499 | + clickToolbar('md-image') |
| 500 | + assert.equal('', visualValue()) |
| 501 | + }) |
| 502 | + |
| 503 | + it('selected url is wrapped in image syntax with cursor in description', function() { |
| 504 | + setVisualValue('Octocat is |https://octodex.github.com/images/original.png|') |
| 505 | + clickToolbar('md-image') |
| 506 | + assert.equal('Octocat is ', visualValue()) |
| 507 | + }) |
| 508 | + |
| 509 | + it('cursor on url is wrapped in image syntax with cursor in description', function() { |
| 510 | + setVisualValue('Octocat is https://octodex.git|hub.com/images/original.png') |
| 511 | + clickToolbar('md-image') |
| 512 | + assert.equal('Octocat is ', visualValue()) |
| 513 | + }) |
| 514 | + |
| 515 | + it('selected plan text is wrapped in image syntax with cursor in url', function() { |
| 516 | + setVisualValue("GitHub's |logo|") |
| 517 | + clickToolbar('md-image') |
| 518 | + assert.equal("GitHub's ", visualValue()) |
| 519 | + }) |
| 520 | + }) |
| 521 | + |
| 522 | + describe('header', function() { |
| 523 | + it('inserts header syntax with cursor in description', function() { |
| 524 | + setVisualValue('|title|') |
| 525 | + clickToolbar('md-header') |
| 526 | + assert.equal('### |title|', visualValue()) |
| 527 | + }) |
| 528 | + |
| 529 | + it('inserts header 1 syntax with cursor in description', function() { |
| 530 | + setVisualValue('|title|') |
| 531 | + clickToolbar('md-header[level="1"]') |
| 532 | + assert.equal('# |title|', visualValue()) |
| 533 | + }) |
| 534 | + |
| 535 | + it('does not insert header for invalid level', function() { |
| 536 | + setVisualValue('|title|') |
| 537 | + clickToolbar('md-header[level="10"]') |
| 538 | + assert.equal('|title|', visualValue()) |
| 539 | + }) |
| 540 | + }) |
492 | 541 | }) |
493 | 542 | }) |
0 commit comments