-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/issue 456 top level pages not building correctly (#476)
* better support for top level pages * minor refactor
- Loading branch information
1 parent
285aa2f
commit 08b710b
Showing
5 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...s/build.default.workspace-top-level-pages/build.default.workspace-top-level-pages.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Use Case | ||
* Run Greenwood with default config and mixed HTML and markdown top level pages. | ||
* | ||
* Result | ||
* Test for correct page output and layout. | ||
* | ||
* Command | ||
* greenwood build | ||
* | ||
* User Config | ||
* None (Greenwood default) | ||
* | ||
* User Workspace | ||
* src/ | ||
* pages/ | ||
* about.html | ||
* contact.md | ||
* index.html | ||
*/ | ||
const expect = require('chai').expect; | ||
const fs = require('fs'); | ||
const { JSDOM } = require('jsdom'); | ||
const path = require('path'); | ||
const TestBed = require('../../../../../test/test-bed'); | ||
|
||
describe('Build Greenwood With: ', function() { | ||
const LABEL = 'Default Greenwood Configuration and Default Workspace w/ Top Level Pages'; | ||
let setup; | ||
|
||
before(async function() { | ||
setup = new TestBed(); | ||
this.context = await setup.setupTestBed(__dirname); | ||
}); | ||
|
||
describe(LABEL, function() { | ||
before(async function() { | ||
await setup.runGreenwoodCommand('build'); | ||
}); | ||
|
||
// TODO runSmokeTest(['public', 'not-found', 'index'], LABEL); | ||
runSmokeTest(['public'], LABEL); | ||
|
||
describe('Home (index) Page', function() { | ||
let dom; | ||
|
||
before(async function() { | ||
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); | ||
}); | ||
|
||
it('should create a top level home (index) page with just an index.html', function() { | ||
expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; | ||
}); | ||
|
||
it('should have the correct content for the home page', function() { | ||
const h1Tags = dom.window.document.querySelectorAll('h1'); | ||
|
||
expect(h1Tags.length).to.equal(1); | ||
expect(h1Tags[0].textContent).to.equal('Hello from the home page!!!!'); | ||
}); | ||
}); | ||
|
||
describe('About Page', function() { | ||
let dom; | ||
|
||
before(async function() { | ||
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', 'index.html')); | ||
}); | ||
|
||
it('should create a top level about page with a directory and index.html', function() { | ||
expect(fs.existsSync(path.join(this.context.publicDir, 'about', 'index.html'))).to.be.true; | ||
}); | ||
|
||
it('should have the correct content for the about page', function() { | ||
const h1Tags = dom.window.document.querySelectorAll('h1'); | ||
const pTags = dom.window.document.querySelectorAll('p'); | ||
|
||
expect(h1Tags.length).to.equal(1); | ||
expect(h1Tags[0].textContent).to.equal('Hello from about.html'); | ||
|
||
expect(pTags.length).to.equal(1); | ||
expect(pTags[0].textContent).to.equal('Lorum Ipsum'); | ||
}); | ||
}); | ||
|
||
describe('Contact Page', function() { | ||
let dom; | ||
|
||
before(async function() { | ||
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'contact', 'index.html')); | ||
}); | ||
|
||
it('should create a top level contact page with a directory and index.html', function() { | ||
expect(fs.existsSync(path.join(this.context.publicDir, 'contact', 'index.html'))).to.be.true; | ||
}); | ||
|
||
it('should have the correct content for the contact page', function() { | ||
const h3Tags = dom.window.document.querySelectorAll('h3'); | ||
const pTags = dom.window.document.querySelectorAll('p'); | ||
|
||
expect(h3Tags.length).to.equal(1); | ||
expect(h3Tags[0].textContent).to.equal('Contact Page'); | ||
|
||
expect(pTags.length).to.equal(1); | ||
expect(pTags[0].textContent).to.equal('Thanks for contacting us.'); | ||
}); | ||
}); | ||
}); | ||
|
||
after(function() { | ||
setup.teardownTestBed(); | ||
}); | ||
|
||
}); |
9 changes: 9 additions & 0 deletions
9
packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/about.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" prefix="og:http://ogp.me/ns#"> | ||
|
||
<body> | ||
<h1>Hello from about.html</h1> | ||
<p>Lorum Ipsum</p> | ||
</body> | ||
|
||
</html> |
3 changes: 3 additions & 0 deletions
3
...ges/cli/test/cases/build.default.workspace-top-level-pages/src/pages/contact.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Contact Page | ||
|
||
Thanks for contacting us. |
8 changes: 8 additions & 0 deletions
8
packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" prefix="og:http://ogp.me/ns#"> | ||
|
||
<body> | ||
<h1>Hello from the home page!!!!</h1> | ||
</body> | ||
|
||
</html> |