Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 29, 2020
1 parent bc28c89 commit ac5802c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion test/at-rule.test.ts
Expand Up @@ -11,7 +11,9 @@ it('initializes with properties', () => {

it('does not fall on childless at-rule', () => {
let rule = new AtRule()
expect(rule.each(i => i)).not.toBeDefined()
rule.each(() => {
throw new Error('AtRule has no children')
})
})

it('creates nodes property on prepend()', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/lazy-result.test.ts
Expand Up @@ -55,7 +55,9 @@ it('executes on finally callback', () => {
let mockCallback = jest.fn()
return new LazyResult(processor, 'a {}', {})
.finally(mockCallback)
.then(() => expect(mockCallback).toHaveBeenCalledTimes(1))
.then(() => {
expect(mockCallback).toHaveBeenCalledTimes(1)
})
})

it('prints its object type', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/map.test.ts
Expand Up @@ -18,7 +18,9 @@ function read (result: { css: string }): any {
let dir = join(__dirname, 'map-fixtures')

let doubler = postcss((css: Root) => {
css.walkDecls(decl => decl.parent?.prepend(decl.clone()))
css.walkDecls(decl => {
decl.parent?.prepend(decl.clone())
})
})
let lighter = postcss((css: Root) => {
css.walkDecls(decl => {
Expand Down
2 changes: 1 addition & 1 deletion test/node.test.ts
Expand Up @@ -14,7 +14,7 @@ import postcss, {

function stringify (node: AnyNode, builder: (str: string) => void) {
if (node.type === 'rule') {
return builder(node.selector)
builder(node.selector)
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/postcss.test.ts
Expand Up @@ -45,7 +45,9 @@ it('creates plugin', () => {
jest.spyOn(console, 'warn').mockImplementation(() => true)
let plugin = (postcss as any).plugin('test', (filter?: string) => {
return (root: Root) => {
root.walkDecls(filter ?? 'two', i => i.remove())
root.walkDecls(filter ?? 'two', i => {
i.remove()
})
}
})
expect(console.warn).toHaveBeenCalledTimes(1)
Expand Down
8 changes: 6 additions & 2 deletions test/processor.test.ts
Expand Up @@ -186,7 +186,9 @@ it('calls all plugins once', async () => {
it('parses, converts and stringifies CSS', () => {
expect(
typeof new Processor([
(css: Root) => expect(css instanceof Root).toBe(true)
(css: Root) => {
expect(css instanceof Root).toBe(true)
}
]).process('a {}').css
).toEqual('string')
})
Expand Down Expand Up @@ -328,7 +330,9 @@ it('throws parse error in async', async () => {

it('throws error on sync method to async plugin', () => {
let async = () => {
return new Promise<void>(resolve => resolve())
return new Promise<void>(resolve => {
resolve()
})
}
expect(() => {
new Processor([async]).process('a{}').css
Expand Down

0 comments on commit ac5802c

Please sign in to comment.