Skip to content

Commit

Permalink
fix(utils): fix lint rules and some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba committed Nov 9, 2023
1 parent d30a976 commit a82538b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/lib/implementation/persist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('persistReport', () => {

it('should stdout as format by default`', async () => {
await persistReport(dummyReport, dummyConfig);
expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
expect(logs.join('\n')).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);

expect(() => readReport('json')).not.toThrow();
expect(() => readReport('md')).toThrow('no such file or directory');
Expand All @@ -89,7 +89,7 @@ describe('persistReport', () => {
...dummyConfig,
persist,
});
expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
expect(logs.join('\n')).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);

expect(() => readReport('json')).not.toThrow('no such file or directory');
expect(() => readReport('md')).toThrow('no such file or directory');
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('persistReport', () => {
`${FOOTER_PREFIX} [Code PushUp](${README_LINK})`,
);

expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
expect(logs.join('\n')).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
});

it('should persist some formats`', async () => {
Expand All @@ -162,7 +162,7 @@ describe('persistReport', () => {
`${FOOTER_PREFIX} [Code PushUp](${README_LINK})`,
);

expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
expect(logs.join('\n')).toMatch(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
});

// @TODO: should throw PersistDirError
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/src/lib/report-to-stdout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('report-to-stdout', () => {
it('should contain all sections when using the fixture report', () => {
reportToStdout(scoreReport(report()));
const logOutput = logs.join('\n');
expect(logOutput.replace(/\u001B\[\d+m/g, ''), '').toMatchSnapshot();
// eslint-disable-next-line no-control-regex
expect(logOutput.replace(/\u001B\[\d+m/g, '')).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion packages/utils/src/lib/report-to-stdout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

let output = '';

const addLine = (text: string = '') => (output += text + '\n');
const addLine = (text = '') => (output += text + '\n');
const print = (text: string) => console.log(text);

export function reportToStdout(report: ScoredReport): void {
Expand Down

0 comments on commit a82538b

Please sign in to comment.