diff --git a/src/analyzers/practice/two-fer/index.ts b/src/analyzers/practice/two-fer/index.ts index 9a32859c..7580ae70 100644 --- a/src/analyzers/practice/two-fer/index.ts +++ b/src/analyzers/practice/two-fer/index.ts @@ -154,6 +154,8 @@ export class TwoFerAnalyzer extends AnalyzerImpl { this.comment(NO_NAMED_EXPORT({ 'export.name': 'twoFer' })) } + console.log(exported?.node.type, this.mainMethod.body.type) + if (this.hasCommentary) { this.disapprove() } diff --git a/test/analyzers/two-fer/issue64.ts b/test/analyzers/two-fer/issue64.ts new file mode 100644 index 00000000..2ecba0ed --- /dev/null +++ b/test/analyzers/two-fer/issue64.ts @@ -0,0 +1,30 @@ +import { TwoFerAnalyzer } from '~src/analyzers/practice/two-fer' +import { makeAnalyze } from '~test/helpers/smoke' + +const analyze = makeAnalyze(() => new TwoFerAnalyzer()) + +describe('When running analysis on two-fer', () => { + it('disapproves an incorrect solution without an explicit return', async () => { + const solutionContent = ` + export const twoFer = (name = 'you') => { + console.log(\`One for \${name}, one for me.\`) + } + `.trim() + + const output = await analyze(solutionContent) + + expect(output.comments.length).toBeGreaterThan(1) + expect(output.comments[0].type).not.toBe('celebratory') + }) + + it('disapproves an incorrect solution without a return value', async () => { + const solutionContent = ` + export const twoFer = (name = 'you') => console.log(\`One for \${name}, one for me.\`) + `.trim() + + const output = await analyze(solutionContent) + + expect(output.comments.length).toBeGreaterThan(1) + expect(output.comments[0].type).not.toBe('celebratory') + }) +})