Skip to content

Commit

Permalink
additional nested and recursive test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Oct 8, 2024
1 parent b71af39 commit e249cff
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
* }
*
* User Workspace
* src/
* src/
* components/
* header/
* header.js
* header.module.css
* index.html
* logo/
* logo.js
* logo.module.css
* index.html
*/
import chai from 'chai';
import { JSDOM } from 'jsdom';
Expand Down Expand Up @@ -187,6 +190,16 @@ describe('Build Greenwood With: ', function() {
});
});
});

describe('Logo component nested in <app-header> component', () => {
it('should have the expected logo CSS inlined into the style tag', () => {
const styles = dom.window.document.querySelectorAll('head style');
const styleText = styles[0].textContent;
const expectedStyles = '.logo-1501575137-container{display:flex}.logo-1501575137-logo{display:inline-block;width:100%;}';

expect(styleText).to.contain(expectedStyles);
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import styles from './header.module.css';
import '../logo/logo.js';

export default class Header extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<header class="${styles.container}">
<app-logo></app-logo>
<ul class="${styles.navBarMenu}">
<li class="${styles.navBarMenuItem}">
<a href="/about/" title="Documentation">About</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styles from './logo.module.css';

export default class Logo extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<div class="${styles.container}">
<img class="${styles.logo}">
</div>
`;
}
}

customElements.define('app-logo', Logo);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.container {
display: flex;
}

.logo {
display: inline-block;
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
* }
*
* User Workspace
* src/
* src/
* components/
* header/
* header.js
* header.module.css
* index.html
* logo/
* logo.js
* logo.module.css
* index.html
*/
import chai from 'chai';
import { JSDOM } from 'jsdom';
Expand Down Expand Up @@ -202,11 +205,22 @@ describe('Develop Greenwood With: ', function() {
});

it('the served content should be untouched', function() {
expect(contents.replace(/ /g, '').replace('\n', '').replace(/;/g, ''))
expect(contents.replace(/ /g, '').replace(/\n/g, '').replace(/;/g, ''))
.to.equal(expectedHeaderCss.replace(/\.header-\[placeholder\]-/g, '.').replace(/ /g, '').replace(/\n/g, '').replace(/;/g, ''));
});
});
});

describe('Logo component nested in <app-header> component', () => {
it('should have the expected logo CSS inlined into the style tag', () => {
const styles = dom.window.document.querySelectorAll('head style');
const styleText = styles[0].textContent;
const expectedStyles = '.logo-1501575137-container{display:flex}.logo-1501575137-logo{display:inline-block;width:100%;}';

expect(styleText.replace(/ /g, '').replace(/\n/g, '').replace(/;/g, ''))
.to.contain(expectedStyles.replace(/;/g, ''));
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styles from './header.module.css';
import '../logo/logo.js';

export default class Header extends HTMLElement {
connectedCallback() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styles from './logo.module.css';

export default class Logo extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<div class="${styles.container}">
<img class="${styles.logo}">
</div>
`;
}
}

customElements.define('app-logo', Logo);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.container {
display: flex;
}

.logo {
display: inline-block;
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
* }
*
* User Workspace
* src/
* src/
* components/
* footer/
* footer.js
* footer.module.css
* header/
* header.js
* header.module.css
* index.html
* logo/
* logo.js
* logo.module.css
* index.html
*/
import chai from 'chai';
import { JSDOM } from 'jsdom';
Expand Down

0 comments on commit e249cff

Please sign in to comment.