Skip to content

Instantly share code, notes, and snippets.

@nerdic-coder
Created May 27, 2018 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdic-coder/10a25952a541f3ccdf8b04296b70e546 to your computer and use it in GitHub Desktop.
Save nerdic-coder/10a25952a541f3ccdf8b04296b70e546 to your computer and use it in GitHub Desktop.
st-container.spec.ts
import { TestWindow } from '@stencil/core/testing';
import { StContainer } from './st-container';
describe('st-container', () => {
it('should build', () => {
expect(new StContainer()).toBeTruthy();
});
describe('rendering', () => {
let element;
beforeAll(async () => {
const window = new TestWindow();
element = await window.load({
components: [StContainer],
html: '<st-container><div>Hello, World!</div></st-container>'
});
});
it('should work without parameters', () => {
expect(element.textContent.trim()).toEqual('Hello, World!');
});
it('should work with st-if true', async () => {
const window = new TestWindow();
element = await window.load({
components: [StContainer],
html: '<st-container st-if="true"><div>Hello, World!</div></st-container>'
});
expect(element.stIf).toEqual('true');
expect(element.shouldRender).toBeTruthy();
expect(element.textContent.trim()).toEqual('Hello, World!');
});
it('should not work with st-if false', async () => {
const window = new TestWindow();
element = await window.load({
components: [StContainer],
html: '<st-container st-if="false"><div>Hello, World!</div></st-container>'
});
expect(element.stIf).toEqual('false');
expect(element.shouldRender).toBeFalsy();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment