phlox
Version:
A frontend architecture that's easy to visualize
222 lines (211 loc) • 4.74 kB
JavaScript
// Generated by CoffeeScript 2.4.1
(function() {
var R, RE, _, _prepare, createPhloxApp, fdeepEq, invoker, map, match, pick, qq, qqq, throws, type, ːdebug, ːdeps, ːkey, ːtype;
({invoker, map, match, pick, type} = R = require('ramda')); //auto_require: ramda
({} = RE = require('ramda-extras')); //auto_require: ramda-extras
[ːkey, ːdebug, ːdeps, ːtype] = [
'key',
'debug',
'deps',
'type' //auto_sugar
];
qq = function(f) {
return console.log(match(/return (.*);/, f.toString())[1], f());
};
qqq = function(f) {
return console.log(match(/return (.*);/, f.toString())[1], JSON.stringify(f(), null, 2));
};
_ = function(...xs) {
return xs;
};
({fdeepEq, throws} = RE = require('testhelp')); // auto_require: testhelp
({_prepare} = createPhloxApp = require('./createPhloxApp'));
describe('createPhloxApp', function() {
return describe('_prepare', function() {
var f0, fa, fabc, fb1, fd;
f0 = function() {
return 1;
};
fa = function({a}) {
return 1;
};
fabc = function({a}, {b}, {c}) {
return 1;
};
fb1 = function({}, {
b: {b1}
}) {
return 1;
};
fd = function({}, {d}) {
return 1;
};
it('also exists', function() {
return throws(/also exists/, function() {
return _prepare({
ui: {
a: 1
},
queries: {
a: 2
},
lifters: {
b: fa
},
invokers: {
c: fa
}
});
});
});
it('exists twice', function() {
return throws(/exists twice/, function() {
return _prepare({
ui: {
a: 1
},
queries: {
c: 2
},
lifters: {
b: fa
},
invokers: {
c: fa
}
});
});
});
it.only('1', function() {
var res;
res = _prepare({
ui: {
a: 2
},
queries: {
b: f0,
d: fabc
},
lifters: {
c: fa
},
invokers: {
e: fb1,
f: f0
}
});
fdeepEq(map(pick([ːkey, ːtype, ːdeps]), res[0]), [
{
key: 'c',
type: 'lifter',
deps: {
UI: {
a: null
}
}
},
{
key: 'e',
type: 'invoker',
deps: {
Data: {
b: {
b1: null
}
}
}
},
{
key: 'd',
type: 'query',
deps: {
UI: {
a: null
},
Data: {
b: null
},
State: {
c: null
}
}
}
]);
fdeepEq(map(pick([ːkey, ːtype, ːdeps]), res[1]), [
{
key: 'b',
type: 'query',
deps: {}
}
]);
return fdeepEq(map(pick([ːkey, ːtype, ːdeps]), res[2]), [
{
key: 'f',
type: 'invoker',
deps: {}
}
]);
});
it('debug', function() {
var res;
res = _prepare({
ui: {
a_debug: 2
},
queries: {
b_debug: f0,
d: fabc
},
lifters: {
c_debug: fa
},
invokers: {
e_debug: fb1
}
});
fdeepEq(map(pick([ːkey, ːdebug]), res[0]), [
{
key: 'c',
debug: true
},
{
key: 'e',
debug: true
},
{
key: 'd',
debug: false
}
]);
return fdeepEq(map(pick([ːkey, ːdebug]), res[1]), [
{
key: 'b',
debug: true
}
]);
});
return it('cannot resolve', function() {
var fc;
fc = function({}, {}, {c}) {
return 1;
};
return throws(/cannot resolve/, function() {
return _prepare({
ui: {
a: 1
},
queries: {
b: fc
},
lifters: {
c: fb1
},
invokers: {
d: fa
}
});
});
});
});
});
}).call(this);