diff --git a/README.md b/README.md index 39a90be..1577435 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ For all test files, you need to specify serializer in Jest configuration. For ex } ``` +# Example + + Example snapshot outputs could be found in the `examples/` directory. + + # Further reading More details about snapshot plugins could be found in [Pretty format package](https://github.com/facebook/jest/tree/v22.4.0/packages/pretty-format#usage-in-jest) diff --git a/examples/base/__snapshots__/base.component.spec.snap b/examples/base/__snapshots__/base.component.spec.snap new file mode 100644 index 0000000..75d0f66 --- /dev/null +++ b/examples/base/__snapshots__/base.component.spec.snap @@ -0,0 +1,82 @@ +exports[`BaseComponent should render something 1`] = ` + +
+ + +
+ + + + + + + + + + + + + + + + + + + + Just text + YET ANOTHER TEXT + + + + + + + + + + + + + +
+ + + +`; diff --git a/examples/base/base.component.html b/examples/base/base.component.html new file mode 100644 index 0000000..b79338d --- /dev/null +++ b/examples/base/base.component.html @@ -0,0 +1,17 @@ +
+
+ + + + + + + Am I visible? + + Just text + {{'yet another text' | uppercase}} + + + + +
diff --git a/examples/base/base.component.spec.ts b/examples/base/base.component.spec.ts new file mode 100644 index 0000000..dea9cf7 --- /dev/null +++ b/examples/base/base.component.spec.ts @@ -0,0 +1,29 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; + +import { BaseComponent } from './base.component'; + +describe('BaseComponent', () => { + let component: BaseComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [BaseComponent], + schemas: [NO_ERRORS_SCHEMA] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(BaseComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it(`should render something`, () => { + fixture.detectChanges(); + + expect(fixture).toMatchSnapshot(); + }); +}); diff --git a/examples/base/base.component.ts b/examples/base/base.component.ts new file mode 100644 index 0000000..f7b2254 --- /dev/null +++ b/examples/base/base.component.ts @@ -0,0 +1,32 @@ +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; + +import { Component, Input, HostBinding } from '@angular/core'; + +@Component({ + selector: 'xmpl-base', + templateUrl: './base.component.html' +}) +export class BaseComponent { + @Input() promiseValue = Promise.resolve(1); + @Input() observableValue = Observable.of(2); + @Input() twoWayValue = 3; + + @HostBinding('class.bound') + bound = true; + @HostBinding('class.not-bound') + notBound = false; + @HostBinding('attr.title') + title = 'super'; + @HostBinding('style.overflow') + overflow = 'hidden'; + @HostBinding('style.display') + get display() { return 'block'; } + @HostBinding('disabled') + get disabled() { return false; } + + ifPass = true; + ifNotPass = false; + + doStuff() {} +}