-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a66432d
commit 56544e3
Showing
4 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
p {{ foo( }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { format } from 'prettier'; | ||
import { plugin } from '../../../src/index'; | ||
import { LoggerListener } from '../../../src/logger'; | ||
import { loggerInstance } from '../../../src/printer'; | ||
|
||
const loggerListener: LoggerListener = jest.fn(); | ||
|
||
const getFormatWarnings = (): string[] => | ||
loggerListener.mock.calls | ||
.filter((call) => call[0] === 3) | ||
.filter((call) => call[1].toString().startsWith('[PugPrinter:formatText]: ')) | ||
.map((call) => call[1].toString().substring(25)); | ||
|
||
const getCode = (filename: string): string => readFileSync(resolve(__dirname, filename), 'utf8'); | ||
|
||
beforeAll(() => { | ||
loggerInstance.addListener(loggerListener); | ||
}); | ||
beforeEach(() => { | ||
// Clear all instances and calls to constructor and all methods: | ||
loggerListener.mockClear(); | ||
}); | ||
afterAll(() => { | ||
loggerInstance.removeListener(loggerListener); | ||
}); | ||
|
||
describe('Frameworks', () => { | ||
describe('Angular', () => { | ||
test('foo-bar', () => { | ||
// this test is not completed yet | ||
const code: string = getCode('unexpected-end-of-expression.pug'); | ||
format(code, { | ||
parser: 'pug', | ||
plugins: [plugin], | ||
|
||
// @ts-expect-error | ||
pugFramework: 'angular' | ||
}); | ||
const thrownWarnings: string[] = getFormatWarnings(); | ||
|
||
expect(thrownWarnings).toContain(''); | ||
}); | ||
}); | ||
}); |