Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stub-deps): ability to stub dependencies for ComponentTester #89

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/resources2/child-component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
${message}
</template>
5 changes: 5 additions & 0 deletions test/resources2/child-component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { bindable } from 'aurelia-framework';

export class ChildComponent {
@bindable() public message = '';
}
4 changes: 4 additions & 0 deletions test/resources2/parent-component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<require from="./child-component"></require>
Parent <child-component message.bind="'Child'"></child-component>
</template>
2 changes: 2 additions & 0 deletions test/resources2/parent-component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export class ParentComponent {
}
37 changes: 37 additions & 0 deletions test/template-dependency-stub.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './setup';
import { StageComponent } from '../src/component-tester';
import { bootstrap } from 'aurelia-bootstrapper';
import { PLATFORM } from 'aurelia-pal';

describe('Template dependency stubbing', () => {

Expand Down Expand Up @@ -183,3 +184,39 @@ describe('Template dependency stubbing', () => {
});
});
});

fdescribe('sample', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is debug code?


it('should render without and with child', async () => {
let component;
let subComponent;

PLATFORM.moduleName('test/resources2/parent-component');
PLATFORM.moduleName('test/resources2/child-component');

// First block, ignoring Child-component
component = await StageComponent
.withResources('test/resources2/parent-component')
.inView('<parent-component></parent-component>')
.ignoreDependencies('test/resources2/child-component');

await component.create(bootstrap);
subComponent = component.element as HTMLElement;
expect(subComponent.textContent!.trim()).toEqual('Parent');
expect(subComponent.textContent!.trim()).not.toContain('Child');

await component.dispose();

// Second block, keeping Child-component
component = await StageComponent
.withResources('test/resources2/parent-component')
.inView('<parent-component></parent-component>');
// .ignoreDependencies('child-component');

await component.create(bootstrap);
subComponent = component.element as HTMLElement;
expect(subComponent.textContent!.trim()).toContain('Child');

component.dispose();
});
});