Skip to content

Commit f050f8f

Browse files
committed
test(prettyfixture): test pretty fixture
1 parent c0a9755 commit f050f8f

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as prettyFixture from './pretty-fixture';
2+
import { prettyPrintFixture } from './pretty-fixture';
3+
import { DebugElement } from '@angular/core';
4+
import * as prettyHTMLLog from 'pretty-html-log';
5+
import { THEMES } from 'pretty-html-log';
6+
import { ComponentFixture } from '@angular/core/testing';
7+
8+
describe('pretty fixture', () => {
9+
it('should call prettyFixture with the componentFixture and pass it to console.log', () => {
10+
console.log = jest.fn();
11+
const componentFixture = {} as ComponentFixture<any>;
12+
spyOn(prettyFixture, 'prettyFixture');
13+
prettyFixture.prettyPrintFixture(componentFixture, THEMES.DRACULA);
14+
15+
expect(console.log).toHaveBeenCalledWith(
16+
prettyPrintFixture(componentFixture, THEMES.DRACULA)
17+
);
18+
});
19+
20+
it('should call the highlight method with the innerHTML', () => {
21+
const innerHTML = '<h1>Foo</h1>';
22+
const componentFixture = {
23+
debugElement: {
24+
nativeElement: {
25+
innerHTML
26+
}
27+
}
28+
} as ComponentFixture<any>;
29+
spyOn(prettyHTMLLog, 'highlight');
30+
31+
prettyFixture.prettyFixture(componentFixture, THEMES.DRACULA);
32+
expect(prettyHTMLLog.highlight).toHaveBeenCalledWith(
33+
innerHTML,
34+
THEMES.DRACULA
35+
);
36+
});
37+
});

0 commit comments

Comments
 (0)