-
Notifications
You must be signed in to change notification settings - Fork 6
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
779b0c3
commit edbff18
Showing
3 changed files
with
72 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import './greeting.ts'; | ||
|
||
export default class App extends HTMLElement { | ||
connectedCallback() { | ||
this.innerHTML = ` | ||
<wcc-greeting name="WCC"></wcc-greeting> | ||
`; | ||
} | ||
} | ||
|
||
customElements.define('wcc-app', App); |
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 @@ | ||
interface User { | ||
name: string; | ||
} | ||
|
||
export default class Greeting extends HTMLElement { | ||
connectedCallback() { | ||
const user: User = { | ||
name: this.getAttribute('name') || 'World' | ||
}; | ||
|
||
this.innerHTML = ` | ||
<h3>Hello ${user.name}!</h3> | ||
`; | ||
} | ||
} | ||
|
||
customElements.define('wcc-greeting', Greeting); |
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 wcc against a custom elements using TypeScript | ||
* | ||
* User Result | ||
* Should return the expected HTML and JavaScript output. | ||
* | ||
* User Workspace | ||
* src/ | ||
* greeting.ts | ||
* app.ts | ||
*/ | ||
import chai from 'chai'; | ||
import { JSDOM } from 'jsdom'; | ||
import { renderToString } from '../../../src/wcc.js'; | ||
|
||
const expect = chai.expect; | ||
|
||
describe('Run WCC For ', function() { | ||
const LABEL = 'Single Custom Element using JSX'; | ||
let dom; | ||
|
||
before(async function() { | ||
const { html } = await renderToString(new URL('./src/app.ts', import.meta.url)); | ||
|
||
dom = new JSDOM(html); | ||
}); | ||
|
||
describe(LABEL, function() { | ||
|
||
describe('Greeting component in TypeScript', function() { | ||
let headings; | ||
|
||
before(async function() { | ||
headings = dom.window.document.querySelectorAll('h3'); | ||
}); | ||
|
||
it('should server render the expected greeting', () => { | ||
expect(headings.length).to.equal(1); | ||
expect(headings[0].textContent).to.equal('Hello WCC!'); | ||
}); | ||
}); | ||
}); | ||
}); |