1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-10 21:30:06 +02:00
copilot/packages/styled-is/test/index.js
Sérgio Ramos 8295bd6882 chore: initial lerna setup
this shall be a progressive process
2017-05-25 10:56:50 +01:00

53 lines
1.7 KiB
JavaScript

const { default: is, isNot, isOr, isSomeNot } = require('../');
const test = require('ava');
test('should render only if prop is truthy', t => {
const rule = is('test')`hello`;
t.deepEqual(rule({ test: false }), []);
t.deepEqual(rule({ test: true }), ['hello']);
});
test('should render only if prop is falsy', t => {
const rule = isNot('test')`hello`;
t.deepEqual(rule({ test: false }), ['hello']);
t.deepEqual(rule({ test: true }), []);
});
test('should render only if all props are truthy', t => {
const rule = is('t1', 't2')`hello`;
t.deepEqual(rule({ t1: true, t2: false }), []);
t.deepEqual(rule({ t1: false, t2: false }), []);
t.deepEqual(rule({ t1: false, t2: true }), []);
t.deepEqual(rule({ t1: true, t2: true }), ['hello']);
});
test('should render only if all props are falsy', t => {
const rule = isNot('t1', 't2')`hello`;
t.deepEqual(rule({ t1: true, t2: false }), []);
t.deepEqual(rule({ t1: false, t2: false }), ['hello']);
t.deepEqual(rule({ t1: false, t2: true }), []);
t.deepEqual(rule({ t1: true, t2: true }), []);
});
test('should render only if one prop is truthy', t => {
const rule = isOr('t1', 't2')`hello`;
t.deepEqual(rule({ t1: true, t2: false }), ['hello']);
t.deepEqual(rule({ t1: false, t2: false }), []);
t.deepEqual(rule({ t1: false, t2: true }), ['hello']);
t.deepEqual(rule({ t1: true, t2: true }), ['hello']);
});
test('should render only if one prop is falsy', t => {
const rule = isSomeNot('t1', 't2')`hello`;
t.deepEqual(rule({ t1: true, t2: false }), ['hello']);
t.deepEqual(rule({ t1: false, t2: false }), ['hello']);
t.deepEqual(rule({ t1: false, t2: true }), ['hello']);
t.deepEqual(rule({ t1: true, t2: true }), []);
});