-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import processor from '../src/post-processor'; | ||
|
||
test('post processor should return function', t => { | ||
t.true(typeof processor === 'function'); | ||
}); | ||
|
||
test('post processor without arguments should return Error', t => { | ||
const error = t.throws(() => { | ||
processor(); | ||
}, TypeError); | ||
|
||
t.is(error.message, 'post-processor did not receive any arguments.'); | ||
}); | ||
|
||
test('post processor without processor should return Error', t => { | ||
const tree = []; | ||
|
||
const error = t.throws(() => { | ||
processor(tree); | ||
}, TypeError); | ||
|
||
t.is(error.message, 'post-processor could not determine the process name.'); | ||
}); | ||
|
||
test('post processor should return posthtml', t => { | ||
const tree = []; | ||
const res = () => {}; | ||
tree.processor = {name: 'posthtml', plugins: []}; | ||
|
||
t.deepEqual(processor(tree, res), {name: 'posthtml', plugins: []}) | ||
}); | ||
|
||
test('post processor should return postcss', t => { | ||
const tree = []; | ||
const res = { | ||
processor: { | ||
plugins: [] | ||
} | ||
}; | ||
|
||
t.deepEqual(processor(tree, res), {name: 'postcss', plugins: []}) | ||
}); | ||
|
||
test('post processor should return reshape', t => { | ||
const tree = []; | ||
const res = { | ||
processor: { | ||
name: 'reshape' | ||
}, | ||
plugins: [] | ||
}; | ||
|
||
t.deepEqual(processor(tree, res), {name: 'reshape', plugins: undefined}) | ||
}); | ||
|
||
// test('post processor call without arguments should return empty object', t => { | ||
// t.deepEqual(processor(), {}); | ||
// }); |