-
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.
* implemented global CSS support with style-loader * unit tests * unit testing
- Loading branch information
1 parent
bb5639f
commit ca44424
Showing
18 changed files
with
287 additions
and
34 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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
test/cli/cases/build.config.error-theme-file/build.config.error-theme-file.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,44 @@ | ||
/* | ||
* Use Case | ||
* Run Greenwood build command with a bad value for themeFile in a custom config. | ||
* | ||
* User Result | ||
* Should throw an error. | ||
* | ||
* User Command | ||
* greenwood build | ||
* | ||
* User Config | ||
* { | ||
* themeFile: '{}' | ||
* } | ||
* | ||
* User Workspace | ||
* Greenwood default | ||
*/ | ||
const expect = require('chai').expect; | ||
const TestBed = require('../../test-bed'); | ||
|
||
describe('Build Greenwood With: ', () => { | ||
let setup; | ||
|
||
before(async () => { | ||
setup = new TestBed(); | ||
setup.setupTestBed(__dirname); | ||
}); | ||
|
||
describe('Custom Configuration with a bad value for theme file', () => { | ||
it('should throw an error that themeFile must be a filename', async () => { | ||
try { | ||
await setup.runGreenwoodCommand('build'); | ||
} catch (err) { | ||
expect(err).to.contain('Error: greenwood.config.js themeFile must be a valid filename. got {} instead.'); | ||
} | ||
}); | ||
}); | ||
|
||
after(function() { | ||
setup.teardownTestBed(); | ||
}); | ||
|
||
}); |
3 changes: 3 additions & 0 deletions
3
test/cli/cases/build.config.error-theme-file/greenwood.config.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,3 @@ | ||
module.exports = { | ||
themeFile: '{}' | ||
}; |
95 changes: 95 additions & 0 deletions
95
test/cli/cases/build.config.theme/build.config.theme.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,95 @@ | ||
/* | ||
* Use Case | ||
* Run Greenwood with a custom themeFile file in config and default workspace with a page template. | ||
* | ||
* User Result | ||
* Should generate a bare bones Greenwood build. (same as build.default.spec.js) with custom theme styles | ||
* | ||
* User Command | ||
* greenwood build | ||
* | ||
* User Config | ||
* { | ||
* title: 'My Custom Greenwood App' | ||
* } | ||
* | ||
* User Workspace | ||
* Greenwood default | ||
* src/ | ||
* templates/ | ||
* page-template.js | ||
* styles/ | ||
* my-brand.css | ||
*/ | ||
const fs = require('fs'); | ||
const { JSDOM } = require('jsdom'); | ||
const path = require('path'); | ||
const expect = require('chai').expect; | ||
const runSmokeTest = require('../../smoke-test'); | ||
const TestBed = require('../../test-bed'); | ||
|
||
describe('Build Greenwood With: ', async function() { | ||
const LABEL = 'Custom Theme Configuration and Default Workspace'; | ||
let setup; | ||
|
||
before(async function() { | ||
setup = new TestBed(); | ||
|
||
this.context = setup.setupTestBed(__dirname); | ||
}); | ||
|
||
describe(LABEL, function() { | ||
before(async function() { | ||
await setup.runGreenwoodCommand('build'); | ||
}); | ||
|
||
runSmokeTest(['public', 'not-found', 'index'], LABEL); | ||
|
||
describe('Theme Styled Page Template', function() { | ||
let dom; | ||
|
||
before(async function() { | ||
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); | ||
}); | ||
|
||
it('should output a single index.html file using our custom styled page template', function() { | ||
expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; | ||
}); | ||
|
||
it('should have the expected font import', async function() { | ||
const styles = '@import url(//fonts.googleapis.com/css?family=Roboto'; | ||
const styleTags = dom.window.document.querySelectorAll('head style'); | ||
let importCount = 0; | ||
|
||
styleTags.forEach((tag) => { | ||
if (tag.textContent.indexOf(styles) >= 0) { | ||
importCount += 1; | ||
} | ||
}); | ||
|
||
expect(importCount).to.equal(1); | ||
}); | ||
|
||
it('should have the expected font family', async function() { | ||
const styles = 'body{font-family:Roboto,sans-serif}'; | ||
const styleTags = dom.window.document.querySelectorAll('head style'); | ||
let fontCount = 0; | ||
|
||
styleTags.forEach((tag) => { | ||
if (tag.textContent.indexOf(styles) >= 0) { | ||
fontCount += 1; | ||
} | ||
}); | ||
|
||
expect(fontCount).to.equal(1); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
after(function() { | ||
setup.teardownTestBed(); | ||
}); | ||
|
||
}); |
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 @@ | ||
module.exports = { | ||
themeFile: 'my-brand.css' | ||
}; |
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,5 @@ | ||
@import url('//fonts.googleapis.com/css?family=Roboto'); | ||
|
||
body { | ||
font-family: 'Roboto', sans-serif; | ||
} |
20 changes: 20 additions & 0 deletions
20
test/cli/cases/build.config.theme/src/templates/page-template.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,20 @@ | ||
import { html, LitElement } from 'lit-element'; | ||
import '../styles/my-brand.css'; | ||
MDIMPORT; | ||
METAIMPORT; | ||
METADATA; | ||
|
||
class PageTemplate extends LitElement { | ||
render() { | ||
return html` | ||
METAELEMENT | ||
<div class='wrapper'> | ||
<div class='page-template content owen-test'> | ||
<entry></entry> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
customElements.define('page-template', PageTemplate); |
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
Oops, something went wrong.