|
| 1 | +package com.flowingcode.vaadin.addons.syntaxhighlighter.test; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertFalse; |
| 5 | +import static org.junit.Assert.assertTrue; |
| 6 | +import com.flowingcode.vaadin.addons.syntaxhighlighter.SHLanguagePrism; |
| 7 | +import com.flowingcode.vaadin.addons.syntaxhighlighter.SHStylePrism; |
| 8 | +import com.flowingcode.vaadin.addons.syntaxhighlighter.SyntaxHighlighterPrism; |
| 9 | +import org.junit.Before; |
| 10 | +import org.junit.Test; |
| 11 | + |
| 12 | +public class SyntaxHighlighterPrismTest { |
| 13 | + |
| 14 | + private SyntaxHighlighterPrism syntaxHighlighter; |
| 15 | + |
| 16 | + @Before |
| 17 | + public void setUp() { |
| 18 | + syntaxHighlighter = new SyntaxHighlighterPrism(); |
| 19 | + } |
| 20 | + |
| 21 | + @Test |
| 22 | + public void testDefaultConstructor() { |
| 23 | + assertEquals(SHLanguagePrism.JAVA, syntaxHighlighter.getSHLanguage()); |
| 24 | + assertEquals(SHStylePrism.A11YDARK, syntaxHighlighter.getSHStyle()); |
| 25 | + assertEquals("", syntaxHighlighter.getContent()); |
| 26 | + assertFalse(syntaxHighlighter.isShowLineNumbers()); |
| 27 | + assertFalse(syntaxHighlighter.isWrapLines()); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + public void testParameterizedConstructor() { |
| 32 | + SyntaxHighlighterPrism sh = new SyntaxHighlighterPrism(SHLanguagePrism.JAVASCRIPT, |
| 33 | + SHStylePrism.DUOTONEDARK, "test", true, true); |
| 34 | + assertEquals(SHLanguagePrism.JAVASCRIPT, sh.getSHLanguage()); |
| 35 | + assertEquals(SHStylePrism.DUOTONEDARK, sh.getSHStyle()); |
| 36 | + assertEquals("test", sh.getContent()); |
| 37 | + assertTrue(sh.isShowLineNumbers()); |
| 38 | + assertTrue(sh.isWrapLines()); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void testSettersAndGetters() { |
| 43 | + syntaxHighlighter.setSHLanguage(SHLanguagePrism.PYTHON); |
| 44 | + syntaxHighlighter.setSHStyle(SHStylePrism.A11YDARK); |
| 45 | + syntaxHighlighter.setContent("test content"); |
| 46 | + syntaxHighlighter.setShowLineNumbers(true); |
| 47 | + syntaxHighlighter.setWrapLines(true); |
| 48 | + |
| 49 | + assertEquals(SHLanguagePrism.PYTHON, syntaxHighlighter.getSHLanguage()); |
| 50 | + assertEquals(SHStylePrism.A11YDARK, syntaxHighlighter.getSHStyle()); |
| 51 | + assertEquals("test content", syntaxHighlighter.getContent()); |
| 52 | + assertTrue(syntaxHighlighter.isShowLineNumbers()); |
| 53 | + assertTrue(syntaxHighlighter.isWrapLines()); |
| 54 | + } |
| 55 | +} |
0 commit comments