|
| 1 | +/* global describe it */ |
| 2 | +'use strict' |
| 3 | + |
| 4 | +const HtmlPage = require('../../lib/html/htmlPage') |
| 5 | +const chai = require('chai') |
| 6 | +const expect = chai.expect |
| 7 | +const HTMLParser = require('node-html-parser') |
| 8 | + |
| 9 | +describe('htmlPage', () => { |
| 10 | + describe('title', () => { |
| 11 | + it('missing', () => { |
| 12 | + const htmlPage = new HtmlPage({ |
| 13 | + content: HTMLParser.parse(`<!DOCTYPE html> |
| 14 | + <meta charset="utf-8"> |
| 15 | + <script>location="url/to/page.html"</script> |
| 16 | + <meta http-equiv="refresh" content="0; url=url/to/page.html"> |
| 17 | + <meta name="robots" content="noindex"> |
| 18 | + <title>Redirect Notice</title> |
| 19 | + <h1>Redirect Notice</h1> |
| 20 | + <p>The page you requested has been relocated to <a href="url/to/page.html">url/to/page.html</a>.</p> |
| 21 | + ` |
| 22 | + ) |
| 23 | + }) |
| 24 | + expect(htmlPage.getTitle()).eq('') |
| 25 | + }) |
| 26 | + it('exists', () => { |
| 27 | + const htmlPage = new HtmlPage({ |
| 28 | + content: HTMLParser.parse(`<!DOCTYPE html> |
| 29 | + <html lang="en"> |
| 30 | + <head> |
| 31 | + <meta charset="utf-8"> |
| 32 | + <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 33 | + <title>Long Title with spaces</title> |
| 34 | + <meta name="generator" content="Antora 3.1.9"> |
| 35 | + <link rel="stylesheet" href="../../antora/css/site.css"> |
| 36 | + <link rel="stylesheet" href="../../antora/css/custom.css"> |
| 37 | + <link rel="stylesheet" href="../../antora/css/font-awesome.min.css"> |
| 38 | + <link rel="stylesheet" href="../../antora/css/extra.css"> |
| 39 | + <script>var uiRootPath = '../../antora'</script> |
| 40 | + </head> |
| 41 | + <body></body> |
| 42 | + </html> |
| 43 | + ` |
| 44 | + ) |
| 45 | + }) |
| 46 | + expect(htmlPage.getTitle()).eq('Long Title with spaces') |
| 47 | + }) |
| 48 | + it('long title with spaces around', () => { |
| 49 | + const htmlPage = new HtmlPage({ |
| 50 | + content: HTMLParser.parse(`<!DOCTYPE html> |
| 51 | + <html lang="en"> |
| 52 | + <head> |
| 53 | + <meta charset="utf-8"> |
| 54 | + <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 55 | + <title> Long Title with spaces around </title> |
| 56 | + <meta name="generator" content="Antora 3.1.9"> |
| 57 | + <link rel="stylesheet" href="../../antora/css/site.css"> |
| 58 | + <link rel="stylesheet" href="../../antora/css/custom.css"> |
| 59 | + <link rel="stylesheet" href="../../antora/css/font-awesome.min.css"> |
| 60 | + <link rel="stylesheet" href="../../antora/css/extra.css"> |
| 61 | + <script>var uiRootPath = '../../antora'</script> |
| 62 | + </head> |
| 63 | + <body></body> |
| 64 | + </html> |
| 65 | + ` |
| 66 | + ) |
| 67 | + }) |
| 68 | + expect(htmlPage.getTitle()).eq('Long Title with spaces around') |
| 69 | + }) |
| 70 | + }) |
| 71 | +}) |
0 commit comments