-
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.
- Loading branch information
1 parent
4d85d8b
commit 77f10de
Showing
6 changed files
with
87 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.12.1 | ||
18.20.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
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,54 @@ | ||
/* | ||
* Use Case | ||
* Run wcc against a custom element using import attributes. | ||
* | ||
* User Result | ||
* Should return the expected HTML and no error parsing an import attribute. | ||
* | ||
* User Workspace | ||
* src/ | ||
* components/ | ||
* header.js | ||
* pages/ | ||
* index.js | ||
*/ | ||
import chai from 'chai'; | ||
import { JSDOM } from 'jsdom'; | ||
import { renderToString } from '../../../src/wcc.js'; | ||
|
||
const expect = chai.expect; | ||
|
||
describe.only('Run WCC For ', function() { | ||
const LABEL = 'Import Attributes usage'; | ||
let dom; | ||
|
||
before(async function() { | ||
const { html } = await renderToString(new URL('./src/pages/index.js', import.meta.url)); | ||
|
||
dom = new JSDOM(html); | ||
}); | ||
|
||
describe(LABEL, function() { | ||
it('should not have any <template> tags within the document', function() { | ||
expect(dom.window.document.querySelectorAll('template').length).to.equal(0); | ||
}); | ||
|
||
describe('static page content', function() { | ||
it('should have the expected static content for the page', function() { | ||
expect(dom.window.document.querySelector('h1').textContent).to.equal('Home Page'); | ||
}); | ||
}); | ||
|
||
describe('custom header element navigation content sourced from a JSON file', function() { | ||
it('should have a <header> tag within the document', function() { | ||
expect(dom.window.document.querySelectorAll('header').length).to.equal(1); | ||
}); | ||
|
||
it('should have three links within the <nav> element', function() { | ||
const links = dom.window.document.querySelectorAll('header nav ul li'); | ||
|
||
expect(links.length).to.equal(2); | ||
}); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"links": ["Home", "About"] | ||
} |
17 changes: 17 additions & 0 deletions
17
test/cases/import-attributes/src/components/header/header.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,17 @@ | ||
import data from './data.json' with { type: 'json' }; | ||
|
||
export default class Header extends HTMLElement { | ||
connectedCallback() { | ||
this.innerHTML = ` | ||
<header> | ||
<nav> | ||
<ul> | ||
${data.links.map((item) => `<li>${item}</li>`).join('\n')} | ||
</ul> | ||
</nav> | ||
</header> | ||
` | ||
} | ||
} | ||
|
||
customElements.define('wcc-header', Header); |
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,10 @@ | ||
import '../components/header/header.js'; | ||
|
||
export default class HomePage extends HTMLElement { | ||
connectedCallback() { | ||
this.innerHTML = ` | ||
<wcc-header></wcc-header> | ||
<h1>Home Page</h1> | ||
`; | ||
} | ||
} |