Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed May 13, 2022
1 parent fc19f1b commit 2295e28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions test/postcss.test.ts
Expand Up @@ -121,8 +121,6 @@ test('has deprecated method to creat plugins', () => {
})
}
})
equal(warn.callCount, 1)
match(warn.calls[0][0], /postcss\.plugin was deprecated/)

This comment has been minimized.

Copy link
@ai

ai May 13, 2022

Member

Let’s add check

equal(warn.callCount, 0)

let func1: any = postcss(plugin).plugins[0]
is(func1.postcssPlugin, 'test')
Expand All @@ -134,9 +132,13 @@ test('has deprecated method to creat plugins', () => {

let result1 = postcss(plugin('one')).process('a{ one: 1; two: 2 }')
is(result1.css, 'a{ two: 2 }')
equal(warn.callCount, 1)

let result2 = postcss(plugin).process('a{ one: 1; two: 2 }')
is(result2.css, 'a{ one: 1 }')

equal(warn.callCount, 1)
match(warn.calls[0][0], /postcss\.plugin was deprecated/)
})

test('creates a shortcut to process css', async () => {
Expand All @@ -148,7 +150,6 @@ test('creates a shortcut to process css', async () => {
})
}
})
equal(warn.callCount, 1)

let result1 = plugin.process('a{value:foo}')
is(result1.css, 'a{value:bar}')
Expand All @@ -159,6 +160,8 @@ test('creates a shortcut to process css', async () => {
let result = await plugin.process('a{value:foo}', { from: 'a' }, 'baz')
equal(result.opts, { from: 'a' })
is(result.css, 'a{value:baz}')

equal(warn.callCount, 1)
})

test('does not call plugin constructor', () => {
Expand All @@ -169,13 +172,14 @@ test('does not call plugin constructor', () => {
return () => {}
})
is(calls, 0)
equal(warn.callCount, 1)

postcss(plugin).process('a{}')
is(calls, 1)

postcss(plugin()).process('a{}')
is(calls, 2)

equal(warn.callCount, 1)
})

test.run()
4 changes: 2 additions & 2 deletions test/processor.test.ts
Expand Up @@ -390,8 +390,8 @@ test('checks plugin compatibility', () => {
throw new Error('Er')
}
})
equal(warn.callCount, 1)
let func = plugin()
equal(warn.callCount, 1)
func.postcssVersion = '2.1.5'

function processBy(version: string): void {
Expand Down Expand Up @@ -562,9 +562,9 @@ test('supports plugins returning processors', () => {
let other: any = (postcss as any).plugin('test', () => {
return new Processor([a])
})
equal(warn.callCount, 1)
processor.use(other)
equal(processor.plugins, [a])
equal(warn.callCount, 1)
})

test('supports plugin creators returning processors', () => {
Expand Down

0 comments on commit 2295e28

Please sign in to comment.