-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make possible to define official formatter as string (#202)
- Loading branch information
1 parent
75a9ef4
commit 8d6599c
Showing
4 changed files
with
85 additions
and
14 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
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,53 @@ | ||
import { formatters } from 'stylelint'; | ||
|
||
import pack from './utils/pack'; | ||
|
||
describe('formatter', () => { | ||
it('should use default formatter', (done) => { | ||
const compiler = pack('error'); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
expect(stats.compilation.errors[0].message).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should use default formatter when invalid', (done) => { | ||
const compiler = pack('error', { formatter: 'invalid' }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
expect(stats.compilation.errors[0].message).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should use string formatter', (done) => { | ||
const compiler = pack('error', { formatter: 'json' }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
expect(stats.compilation.errors[0].message).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should use function formatter', (done) => { | ||
const compiler = pack('error', { formatter: formatters.verbose }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
expect(stats.compilation.errors[0].message).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
}); |