|
| 1 | +describe('VCodeBlock Component - Highlight.js', () => { |
| 2 | + beforeEach(() => { |
| 3 | + cy.visit('/'); |
| 4 | + cy.get('[data-cy="library-select"]').parent().click().type('highlightjs'); |
| 5 | + }); |
| 6 | + |
| 7 | + it('should have v-code-block--highlightjs on all v-code-block elements', () => { |
| 8 | + cy.get('.v-code-block').should('have.class', 'v-code-block--highlightjs'); |
| 9 | + }); |
| 10 | + |
| 11 | + describe('JavaScript Example', () => { |
| 12 | + const codeBlockExamples = '#lang-js-examples .v-code-block'; |
| 13 | + |
| 14 | + it('should have 1 code block', () => { |
| 15 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should have code block classes', () => { |
| 19 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 20 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 21 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 22 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should have a pre and code elements', () => { |
| 26 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should have a pre/code elements with language-javascript & code.hljs class', () => { |
| 30 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-javascript'); |
| 31 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should contain rendered code', () => { |
| 35 | + cy.get(codeBlockExamples).find('code').should('contain.text', 'const numbers = [1, 2, 3, 4, 5];'); |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + describe('Vue Example', () => { |
| 40 | + const codeBlockExamples = '#lang-vue-examples .v-code-block'; |
| 41 | + |
| 42 | + it('should have 1 code block', () => { |
| 43 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should have code block classes', () => { |
| 47 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 48 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 49 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 50 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should have a pre and code elements', () => { |
| 54 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 55 | + }); |
| 56 | + |
| 57 | + it('should have a pre/code elements with language-html class & code.hljs class', () => { |
| 58 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-html'); |
| 59 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 60 | + }); |
| 61 | + |
| 62 | + it('should contain rendered code', () => { |
| 63 | + cy.get(codeBlockExamples).find('code').should('contain.text', '<template>'); |
| 64 | + }); |
| 65 | + }); |
| 66 | + |
| 67 | + describe('CSS Example', () => { |
| 68 | + const codeBlockExamples = '#lang-css-examples .v-code-block'; |
| 69 | + |
| 70 | + it('should have 1 code block', () => { |
| 71 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 72 | + }); |
| 73 | + |
| 74 | + it('should have code block classes', () => { |
| 75 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 76 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 77 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 78 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 79 | + }); |
| 80 | + |
| 81 | + it('should have a pre and code elements', () => { |
| 82 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 83 | + }); |
| 84 | + |
| 85 | + it('should have a pre/code elements with language-css class & code.hljs class', () => { |
| 86 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-css'); |
| 87 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 88 | + }); |
| 89 | + |
| 90 | + it('should contain rendered code', () => { |
| 91 | + cy.get(codeBlockExamples).find('code').should('contain.text', 'WebDevNerdStuff Neon Bunny'); |
| 92 | + }); |
| 93 | + }); |
| 94 | + |
| 95 | + describe('HTML Example', () => { |
| 96 | + const codeBlockExamples = '#lang-html-examples .v-code-block'; |
| 97 | + |
| 98 | + it('should have 1 code block', () => { |
| 99 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 100 | + }); |
| 101 | + |
| 102 | + it('should have code block classes', () => { |
| 103 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 104 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 105 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 106 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 107 | + }); |
| 108 | + |
| 109 | + it('should have a pre and code elements', () => { |
| 110 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 111 | + }); |
| 112 | + |
| 113 | + it('should have a pre/code elements with language-html class & code.hljs class', () => { |
| 114 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-html'); |
| 115 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 116 | + }); |
| 117 | + |
| 118 | + it('should contain rendered code', () => { |
| 119 | + cy.get(codeBlockExamples).find('code').should('contain.text', '<!DOCTYPE html>'); |
| 120 | + }); |
| 121 | + }); |
| 122 | + |
| 123 | + describe('SVG Example', () => { |
| 124 | + const codeBlockExamples = '#lang-svg-examples .v-code-block'; |
| 125 | + |
| 126 | + it('should have 1 code block', () => { |
| 127 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 128 | + }); |
| 129 | + |
| 130 | + it('should have code block classes', () => { |
| 131 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 132 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 133 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 134 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 135 | + }); |
| 136 | + |
| 137 | + it('should have a pre and code elements', () => { |
| 138 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 139 | + }); |
| 140 | + |
| 141 | + it('should have a pre/code elements with language-svg class & code.hljs class', () => { |
| 142 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-svg'); |
| 143 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 144 | + }); |
| 145 | + |
| 146 | + it('should contain rendered code', () => { |
| 147 | + cy.get(codeBlockExamples).find('code').should('contain.text', '<svg xmlns='); |
| 148 | + }); |
| 149 | + }); |
| 150 | + |
| 151 | + describe('Typescript Example', () => { |
| 152 | + const codeBlockExamples = '#additional-languages-ts-example .v-code-block'; |
| 153 | + |
| 154 | + it('should have 1 code block', () => { |
| 155 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 156 | + }); |
| 157 | + |
| 158 | + it('should have code block classes', () => { |
| 159 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 160 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 161 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 162 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 163 | + }); |
| 164 | + |
| 165 | + it('should have a pre and code elements', () => { |
| 166 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 167 | + }); |
| 168 | + |
| 169 | + it('should have a pre/code elements with language-typescript class & code.hljs class', () => { |
| 170 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-typescript'); |
| 171 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 172 | + }); |
| 173 | + |
| 174 | + it('should contain rendered code', () => { |
| 175 | + cy.get(codeBlockExamples).find('code').should('contain.text', 'private name: string;'); |
| 176 | + }); |
| 177 | + }); |
| 178 | + |
| 179 | + describe('JSON Example', () => { |
| 180 | + const codeBlockExamples = '#additional-languages-json-example .v-code-block'; |
| 181 | + |
| 182 | + it('should have 1 code block', () => { |
| 183 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 184 | + }); |
| 185 | + |
| 186 | + it('should have code block classes', () => { |
| 187 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 188 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 189 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 190 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 191 | + }); |
| 192 | + |
| 193 | + it('should have a pre and code elements', () => { |
| 194 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 195 | + }); |
| 196 | + |
| 197 | + it('should have a pre/code elements with language-json class & code.hljs class', () => { |
| 198 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-json'); |
| 199 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 200 | + }); |
| 201 | + |
| 202 | + it('should contain rendered code', () => { |
| 203 | + cy.get(codeBlockExamples).find('code').should('contain.text', '"name": "John Doe",'); |
| 204 | + }); |
| 205 | + }); |
| 206 | + |
| 207 | + describe('PHP Example', () => { |
| 208 | + const codeBlockExamples = '#additional-languages-php-example .v-code-block'; |
| 209 | + |
| 210 | + it('should have 1 code block', () => { |
| 211 | + cy.get(codeBlockExamples).should('have.length', 1); |
| 212 | + }); |
| 213 | + |
| 214 | + it('should have code block classes', () => { |
| 215 | + cy.get(codeBlockExamples).children('.v-code-block--code').should('exist'); |
| 216 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button').should('exist'); |
| 217 | + cy.get(codeBlockExamples).find('.v-code-block--code-copy-button-status-copy').should('exist'); |
| 218 | + cy.get(codeBlockExamples).find('.v-code-block--button-copy-icon').should('exist'); |
| 219 | + }); |
| 220 | + |
| 221 | + it('should have a pre and code elements', () => { |
| 222 | + cy.get(codeBlockExamples).find('pre, code').should('exist'); |
| 223 | + }); |
| 224 | + |
| 225 | + it('should have a pre/code elements with language-php class & code.hljs class', () => { |
| 226 | + cy.get(codeBlockExamples).find('pre, code').should('have.class', 'language-php'); |
| 227 | + cy.get(codeBlockExamples).find('code').should('have.class', 'hljs'); |
| 228 | + }); |
| 229 | + |
| 230 | + it('should contain rendered code', () => { |
| 231 | + cy.get(codeBlockExamples).find('code').should('contain.text', 'namespace App\\Http\\Controllers;'); |
| 232 | + }); |
| 233 | + }); |
| 234 | + |
| 235 | +}); |
0 commit comments