-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
additional test cases and refactoring
- Loading branch information
1 parent
ecbe3b4
commit 9a9af77
Showing
13 changed files
with
282 additions
and
56 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Use Case | ||
* Run wcc against a single custom element using with no customElements.define | ||
* | ||
* User Result | ||
* Should run without any errors from the DOM shim. | ||
* | ||
* User Workspace | ||
* src/ | ||
* no-define.js | ||
* footer.js | ||
* header.js | ||
*/ | ||
|
||
import chai from 'chai'; | ||
import { renderToString, renderFromHTML } from '../../../src/wcc.js'; | ||
|
||
const expect = chai.expect; | ||
|
||
describe('Run WCC For ', function() { | ||
const LABEL = 'Single Custom Element with no customElements.define'; | ||
|
||
describe(LABEL, function() { | ||
describe('renderToString', () => { | ||
let rawHtml; | ||
let meta; | ||
|
||
before(async function() { | ||
const { html, metadata } = await renderToString(new URL('./src/no-define.js', import.meta.url)); | ||
|
||
rawHtml = html; | ||
meta = metadata; | ||
}); | ||
|
||
it('should not throw an error', function() { | ||
expect(rawHtml).to.equal(undefined); | ||
}); | ||
|
||
it('should not have any definition', function() { | ||
expect(meta.length).to.equal(0); | ||
}); | ||
}); | ||
|
||
describe('renderFromHTML', () => { | ||
let rawHtml; | ||
let meta; | ||
const contents = ` | ||
<html> | ||
<head> | ||
<title>No Export Test</title> | ||
</head> | ||
<body> | ||
<app-no-define-header></app-no-define-header> | ||
<h1>Hello World</h1> | ||
<app-no-define-footer></app-no-define-footer> | ||
</body> | ||
</html> | ||
`; | ||
|
||
before(async function() { | ||
const { html, metadata } = await renderFromHTML(contents, [ | ||
new URL('./src/footer.js', import.meta.url), | ||
new URL('./src/header.js', import.meta.url) | ||
]); | ||
|
||
rawHtml = html; | ||
meta = metadata; | ||
}); | ||
|
||
it('should not throw an error and return the expected contents', function() { | ||
expect(rawHtml.replace(/ /g, '').replace(/\n/g, '')).to.equal(contents.replace(/ /g, '').replace(/\n/g, '')); | ||
}); | ||
|
||
// I think this is broken, should actually be equal to 2? | ||
it('should not have any definition', function() { | ||
expect(meta.length).to.equal(0); | ||
}); | ||
}); | ||
}); | ||
}); |
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,16 @@ | ||
const template = document.createElement('template'); | ||
|
||
template.innerHTML = '<footer>This is the footer component.</footer>'; | ||
|
||
class FooterComponent extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }); | ||
} | ||
|
||
connectedCallback() { | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
} | ||
} | ||
|
||
customElements.define('app-no-define-footer', FooterComponent); |
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,18 @@ | ||
const template = document.createElement('template'); | ||
|
||
template.innerHTML = ` | ||
<header>This is the header component.</header> | ||
`; | ||
|
||
class HeaderComponent extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }); | ||
} | ||
|
||
connectedCallback() { | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
} | ||
} | ||
|
||
customElements.define('app-no-define-header', HeaderComponent); |
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,15 @@ | ||
const template = document.createElement('template'); | ||
|
||
template.innerHTML = '<p>This is the NoDefineComponent component.</p>'; | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
class NoDefineComponent extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }); | ||
} | ||
|
||
connectedCallback() { | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
} | ||
} |
Oops, something went wrong.