Skip to content

Commit

Permalink
test: for post processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 8, 2018
1 parent 260750c commit 1c50342
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/test-post-processor.js
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(), {});
// });

0 comments on commit 1c50342

Please sign in to comment.