Update tests

This commit is contained in:
Adam Wathan 2017-11-03 10:04:48 -04:00
parent b2b95d5738
commit f80537a85d
3 changed files with 9 additions and 10 deletions

View File

@ -1,14 +1,14 @@
import postcss from 'postcss'
import plugin from '../src/lib/substituteClassApplyAtRules'
function run(input, opts) {
function run(input, opts = () => {}) {
return postcss([plugin(opts)]).process(input)
}
test("it copies a class's declarations into itself", () => {
const output = '.a { color: red; } .b { color: red; }'
return run('.a { color: red; } .b { @apply .a; }', {}).then(result => {
return run('.a { color: red; } .b { @apply .a; }').then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})
@ -38,16 +38,15 @@ test("it doesn't copy a media query definition into itself", () => {
.b {
@apply .a;
}`,
{}
).then(result => {
}`)
.then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})
})
test('it fails if the class does not exist', () => {
run('.b { @apply .a; }', {}).catch(error => {
run('.b { @apply .a; }').catch(error => {
expect(error.reason).toEqual('No .a class found.')
})
})

View File

@ -1,7 +1,7 @@
import postcss from 'postcss'
import plugin from '../src/lib/substituteFocusableAtRules'
function run(input, opts = {}) {
function run(input, opts = () => {}) {
return postcss([plugin(opts)]).process(input)
}
@ -18,7 +18,7 @@ test("it adds a focusable variant to each nested class definition", () => {
.chocolate, .focus\\:chocolate:focus { color: brown; }
`
return run(input, {}).then(result => {
return run(input).then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})

View File

@ -1,7 +1,7 @@
import postcss from 'postcss'
import plugin from '../src/lib/substituteHoverableAtRules'
function run(input, opts = {}) {
function run(input, opts = () => {}) {
return postcss([plugin(opts)]).process(input)
}
@ -18,7 +18,7 @@ test("it adds a hoverable variant to each nested class definition", () => {
.chocolate, .hover\\:chocolate:hover { color: brown; }
`
return run(input, {}).then(result => {
return run(input).then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})