Skip to content

Commit

Permalink
test: for config resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 19, 2018
1 parent d11531a commit ebea958
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/config/.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'posthtml-bem': {}
}
56 changes: 56 additions & 0 deletions test/test-cfg-resolve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import test from 'ava';
import isPromise from 'is-promise';
import cfgResolve from '../src/cfg-resolve';

test('should return function', t => {
t.true(typeof cfgResolve === 'function');
});

test('should return promise', t => {
t.true(isPromise(cfgResolve()));
});

test('should return config with one use key without property', async t => {
const flags = {
use: 'posthtml-bem'
};
const config = await cfgResolve(flags);
const expected = {'posthtml-bem': {}};

t.deepEqual(config, expected);
});

test('should return config with one use key with one property', async t => {
const flags = {
use: 'posthtml-bem',
'posthtml-bem': {
prefix: '__'
}
};
const config = await cfgResolve(flags);
const expected = {'posthtml-bem': {prefix: '__'}};

t.deepEqual(config, expected);
});

test('should return config with key config', async t => {
const flags = {
config: 'test/config/.config'
};
const config = await cfgResolve(flags);
const expected = {'posthtml-bem': {}};

t.deepEqual(config, expected);
});

test('should return config with key config and use key', async t => {
const flags = {
use: 'posthtml-assets',
config: 'test/config/.config'
};
const config = await cfgResolve(flags);
const expected = {'posthtml-bem': {}, 'posthtml-assets': {}};

t.deepEqual(config, expected);
});

0 comments on commit ebea958

Please sign in to comment.