Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
adamwathan committed Nov 3, 2017
commit f80537a85d93bfbd812cb5a94e1fd6ed2e453972
11 changes: 5 additions & 6 deletions __tests__/applyAtRule.test.js
Original file line number Diff line number Diff line change
@@ -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)
})
Expand Down Expand Up @@ -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.')
})
})
4 changes: 2 additions & 2 deletions __tests__/focusableAtRule.test.js
Original file line number Diff line number Diff line change
@@ -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)
}

Expand All @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions __tests__/hoverableAtRule.test.js
Original file line number Diff line number Diff line change
@@ -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)
}

Expand All @@ -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)
})
Expand Down