Skip to content

Commit

Permalink
fix: add inline-bug files
Browse files Browse the repository at this point in the history
  • Loading branch information
wtho committed Jun 30, 2019
1 parent b0b75db commit a383dd8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "ng serve",
"build": "ng build",
"test": "jest",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --runInBand",
"test:coverage": "jest --coverage",
Expand Down Expand Up @@ -37,6 +38,7 @@
"codelyzer": "^4.4.3",
"jest": "^24.0.0",
"jest-preset-angular": "file:../",
"prettier": "^1.18.2",
"protractor": "^5.4.0",
"ts-node": "^8.0.3",
"tslint": "^5.11.0",
Expand Down
54 changes: 54 additions & 0 deletions example/src/app/inline/inline.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component, Input } from "@angular/core";
import { ComponentFixture, TestBed } from "@angular/core/testing";

/**
* Example test component.
*/
@Component({
selector: "tc-jest-inline-test1",
template: `
<div>Line 1</div>
<div>
<div *ngIf="condition1">
{{ value1 }}
</div>
<span *ngIf="condition2">
{{ value2 }}
</span>
</div>
`
})
export class JestInlineSnapBugComponent {
@Input() value1: string = "val1";
@Input() value2: string = "val2";

condition1: boolean = true;
condition2: boolean = false;
}

describe("Jest Snapshot Bug", () => {
let comp: JestInlineSnapBugComponent;
let fixture: ComponentFixture<JestInlineSnapBugComponent>;

beforeEach(() => {
TestBed.configureCompiler({ preserveWhitespaces: false } as any);
TestBed.configureTestingModule({
declarations: [JestInlineSnapBugComponent]
});
fixture = TestBed.createComponent(JestInlineSnapBugComponent);
comp = fixture.componentInstance;
fixture.detectChanges();
});

it("should allow snapshots", () => {
expect(fixture).toMatchInlineSnapshot();

comp.condition2 = true;
fixture.detectChanges();
expect(fixture).toMatchInlineSnapshot();

comp.condition1 = false;
comp.condition2 = false;
expect(fixture).toMatchInlineSnapshot();
});
});
5 changes: 5 additions & 0 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5714,6 +5714,11 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

prettier@^1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==

pretty-format@^24.0.0:
version "24.0.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.0.0.tgz#cb6599fd73ac088e37ed682f61291e4678f48591"
Expand Down

0 comments on commit a383dd8

Please sign in to comment.