Skip to content

Commit f9827db

Browse files
committed
refactor(prettiers): refactor prettiers
1 parent 4346033 commit f9827db

6 files changed

Lines changed: 31 additions & 26 deletions

File tree

projects/pretty-html-log/src/lib/logNgHTML.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ describe('LogNgHTML', () => {
3939
});
4040

4141
it('should call prettyPrintFixture incase we provide a component fixture', () => {
42-
spyOn(fixturePrettier, 'prettyPrintFixture');
42+
spyOn(fixturePrettier, 'fixturePrettier');
4343
logNgHTML<MockComponent>(fixture, theme);
44-
expect(fixturePrettier.prettyPrintFixture).toHaveBeenCalledWith(
44+
expect(fixturePrettier.fixturePrettier).toHaveBeenCalledWith(
4545
fixture,
4646
theme
4747
);

projects/pretty-html-log/src/lib/logNgHTML.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture } from '@angular/core/testing';
22
import { DebugElement } from '@angular/core';
33
import { highlight, Theme } from 'pretty-html-log';
4-
import { prettyPrintFixture } from './prettiers/fixture/pretty-fixture';
4+
import { fixturePrettier } from './prettiers/fixture/pretty-fixture';
55
import {
66
prettyPrintDebugElement,
77
prettyPrintDebugElements
@@ -24,7 +24,7 @@ export const logNgHTML = <T>(
2424
theme?: Theme
2525
) => {
2626
if (ngHTMLElement instanceof ComponentFixture) {
27-
prettyPrintFixture<T>(ngHTMLElement, theme);
27+
fixturePrettier<T>(ngHTMLElement, theme);
2828
return;
2929
}
3030

projects/pretty-html-log/src/lib/prettiers/debugElement/pretty-debugElement.spec.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import * as prettyDebugElement from './pretty-debugElement';
2-
import { prettyPrintDebugElement } from './pretty-debugElement';
31
import { DebugElement } from '@angular/core';
4-
import * as prettyHTMLLog from 'pretty-html-log';
52
import { THEMES } from 'pretty-html-log';
3+
import * as prettyHTMLLog from 'pretty-html-log';
4+
5+
import * as debugElementPrettier from './pretty-debugElement';
6+
import { prettyPrintDebugElement } from './pretty-debugElement';
67

78
describe('pretty debug element', () => {
89
it('should call prettyDebugelement with the debugElement and pass it to console.log', () => {
910
console.log = jest.fn();
1011
const debugElement = {} as DebugElement;
11-
spyOn(prettyDebugElement, 'prettyDebugelement');
12-
prettyDebugElement.prettyPrintDebugElement(debugElement, THEMES.DRACULA);
12+
spyOn(debugElementPrettier, 'prettyDebugelement');
13+
debugElementPrettier.prettyPrintDebugElement(debugElement, THEMES.DRACULA);
1314

1415
expect(console.log).toHaveBeenCalledWith(
1516
prettyPrintDebugElement(debugElement, THEMES.DRACULA)
@@ -30,8 +31,11 @@ describe('pretty debug element', () => {
3031
debugElementTwo,
3132
debugElementThree
3233
] as DebugElement[];
33-
spyOn(prettyDebugElement, 'prettyDebugelement');
34-
prettyDebugElement.prettyPrintDebugElements(debugElements, THEMES.DRACULA);
34+
spyOn(debugElementPrettier, 'prettyDebugelement');
35+
debugElementPrettier.prettyPrintDebugElements(
36+
debugElements,
37+
THEMES.DRACULA
38+
);
3539

3640
expect(console.log).toHaveBeenCalledWith(
3741
prettyPrintDebugElement(debugElementOne, THEMES.DRACULA)
@@ -53,7 +57,7 @@ describe('pretty debug element', () => {
5357
} as DebugElement;
5458
spyOn(prettyHTMLLog, 'highlight');
5559

56-
prettyDebugElement.prettyDebugelement(debugElement, THEMES.DRACULA);
60+
debugElementPrettier.prettyDebugelement(debugElement, THEMES.DRACULA);
5761
expect(prettyHTMLLog.highlight).toHaveBeenCalledWith(
5862
innerHTML,
5963
THEMES.DRACULA

projects/pretty-html-log/src/lib/prettiers/fixture/pretty-fixture.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
import { ComponentFixture } from '@angular/core/testing';
2+
import { THEMES } from 'pretty-html-log';
3+
14
import * as prettyFixture from './pretty-fixture';
2-
import { prettyPrintFixture } from './pretty-fixture';
3-
import { DebugElement } from '@angular/core';
5+
import { fixturePrettier } from './pretty-fixture';
46
import * as prettyHTMLLog from 'pretty-html-log';
5-
import { THEMES } from 'pretty-html-log';
6-
import { ComponentFixture } from '@angular/core/testing';
77

88
describe('pretty fixture', () => {
99
it('should call prettyFixture with the componentFixture and pass it to console.log', () => {
1010
console.log = jest.fn();
1111
const componentFixture = {} as ComponentFixture<any>;
1212
spyOn(prettyFixture, 'prettyFixture');
13-
prettyFixture.prettyPrintFixture(componentFixture, THEMES.DRACULA);
13+
prettyFixture.fixturePrettier(componentFixture, THEMES.DRACULA);
1414

1515
expect(console.log).toHaveBeenCalledWith(
16-
prettyPrintFixture(componentFixture, THEMES.DRACULA)
16+
fixturePrettier(componentFixture, THEMES.DRACULA)
1717
);
1818
});
1919

projects/pretty-html-log/src/lib/prettiers/fixture/pretty-fixture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture } from '@angular/core/testing';
22
import { highlight, Theme } from 'pretty-html-log';
33

4-
export const prettyPrintFixture = <T>(
4+
export const fixturePrettier = <T>(
55
fixture: ComponentFixture<T>,
66
theme?: Theme
77
): void => {

projects/pretty-html-log/src/lib/prettiers/htmlElement/pretty-htmlelement.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import * as prettyHTMLElement from './pretty-htmlelement';
2-
import { prettyPrintHtmlElement } from './pretty-htmlelement';
31
import * as prettyHTMLLog from 'pretty-html-log';
42
import { THEMES } from 'pretty-html-log';
53

4+
import * as htmlElementPrettier from './pretty-htmlelement';
5+
import { prettyPrintHtmlElement } from './pretty-htmlelement';
6+
67
describe('pretty HTML element', () => {
78
it('should call prettyHtmlElement with the htmlElement and pass it to console.log', () => {
89
console.log = jest.fn();
910
const htmlElement = {} as HTMLElement;
10-
spyOn(prettyHTMLElement, 'prettyHtmlElement');
11-
prettyHTMLElement.prettyPrintHtmlElement(htmlElement, THEMES.DRACULA);
11+
spyOn(htmlElementPrettier, 'prettyHtmlElement');
12+
htmlElementPrettier.prettyPrintHtmlElement(htmlElement, THEMES.DRACULA);
1213

1314
expect(console.log).toHaveBeenCalledWith(
1415
prettyPrintHtmlElement(htmlElement, THEMES.DRACULA)
@@ -29,8 +30,8 @@ describe('pretty HTML element', () => {
2930
htmlElementTwo,
3031
htmlElementThree
3132
] as HTMLElement[];
32-
spyOn(prettyHTMLElement, 'prettyHtmlElement');
33-
prettyHTMLElement.prettyPrintHtmlElements(htmlElements, THEMES.DRACULA);
33+
spyOn(htmlElementPrettier, 'prettyHtmlElement');
34+
htmlElementPrettier.prettyPrintHtmlElements(htmlElements, THEMES.DRACULA);
3435

3536
expect(console.log).toHaveBeenCalledWith(
3637
prettyPrintHtmlElement(htmlElementOne, THEMES.DRACULA)
@@ -50,7 +51,7 @@ describe('pretty HTML element', () => {
5051
} as HTMLElement;
5152
spyOn(prettyHTMLLog, 'highlight');
5253

53-
prettyHTMLElement.prettyHtmlElement(htmlElement, THEMES.DRACULA);
54+
htmlElementPrettier.prettyHtmlElement(htmlElement, THEMES.DRACULA);
5455
expect(prettyHTMLLog.highlight).toHaveBeenCalledWith(
5556
innerHTML,
5657
THEMES.DRACULA

0 commit comments

Comments
 (0)