mirror of
https://github.com/yldio/copilot.git
synced 2024-11-11 05:40:11 +02:00
962bc85b28
fixes #356 implementation with @juditgreskovits tests with @alex-windett
108 lines
1.7 KiB
JavaScript
108 lines
1.7 KiB
JavaScript
const test = require('ava');
|
|
|
|
const selectors = require('@state/selectors');
|
|
const flatten = require('lodash.flatten');
|
|
const moment = require('moment');
|
|
|
|
const {
|
|
accountSelector,
|
|
orgByIdSelector,
|
|
// orgsSelector,
|
|
// orgSectionsSelector,
|
|
// projectsByOrgIdSelector
|
|
} = selectors;
|
|
|
|
test('accountSelector with empty input', (t) => {
|
|
t.deepEqual(accountSelector(), {});
|
|
|
|
t.deepEqual(accountSelector({
|
|
account: undefined
|
|
}), {});
|
|
|
|
t.deepEqual(accountSelector({
|
|
account: {}
|
|
}), {});
|
|
|
|
t.deepEqual(accountSelector({
|
|
account: {
|
|
data: undefined
|
|
}
|
|
}), {});
|
|
|
|
t.deepEqual(accountSelector({
|
|
account: {
|
|
data: {}
|
|
}
|
|
}), {});
|
|
});
|
|
|
|
test('accountSelector with attrs', (t) => {
|
|
t.deepEqual(accountSelector({
|
|
account: {
|
|
data: {
|
|
id: '[id]',
|
|
uuid: '[uuid]'
|
|
}
|
|
}
|
|
}), {
|
|
id: '[id]',
|
|
uuid: '[uuid]'
|
|
});
|
|
});
|
|
|
|
test('orgByIdSelector with empty input', (t) => {
|
|
t.deepEqual(orgByIdSelector()(), undefined);
|
|
|
|
t.deepEqual(orgByIdSelector()({
|
|
orgs: undefined
|
|
}), undefined);
|
|
|
|
t.deepEqual(orgByIdSelector()({
|
|
orgs: {}
|
|
}), undefined);
|
|
|
|
t.deepEqual(orgByIdSelector()({
|
|
orgs: {
|
|
data: undefined
|
|
}
|
|
}), undefined);
|
|
|
|
t.deepEqual(orgByIdSelector()({
|
|
orgs: {
|
|
data: {}
|
|
}
|
|
}), undefined);
|
|
});
|
|
|
|
test('orgByIdSelector should find org', (t) => {
|
|
const orgs = [{
|
|
id: '1'
|
|
}, {
|
|
id: '2'
|
|
}, {
|
|
id: '3'
|
|
}];
|
|
|
|
t.deepEqual(orgByIdSelector('1')({
|
|
orgs: {
|
|
data: orgs
|
|
}
|
|
}), {
|
|
id: '1'
|
|
});
|
|
|
|
t.deepEqual(orgByIdSelector('2')({
|
|
orgs: {
|
|
data: orgs
|
|
}
|
|
}), {
|
|
id: '2'
|
|
});
|
|
|
|
t.deepEqual(orgByIdSelector('4')({
|
|
orgs: {
|
|
data: orgs
|
|
}
|
|
}), undefined);
|
|
});
|