Ejemplo n.º 1
0
test('fQuery.fn.isPending() false for new object', () => {
    let x = fQuery();
    assert.equal(x.isPending(), false);

    x = fQuery('test/assets/files-abc/*');
    assert.equal(x.isPending(), false);
});
Ejemplo n.º 2
0
test('fQuery.fn.then() returns this, is chainable', () => {
    const x = fQuery();
    const y = x.then();
    const z = y.then();
    assert.equal(x, y);
    assert.equal(y, z);
});
Ejemplo n.º 3
0
test('modulejs.log() two definitions with deps', () => {
    const modjs = modulejs.create();
    modjs.define('a', {});
    modjs.define('b', ['a'], {});
    assert.equal(modjs.log(), '\n  a -> [  ]\n  b -> [ a ]\n');
    assert.equal(modjs.log(true), '\n  a -> [ b ]\n  b -> [  ]\n');
});
Ejemplo n.º 4
0
test('core.format', () => {
    assert.equal(typeof format, 'object');
    assert.deepEqual(Object.keys(format).sort(), ['setDefaultMetric', 'formatSize', 'setDefaultDateFormat', 'formatDate'].sort());
    assert.equal(typeof format.setDefaultMetric, 'function');
    assert.equal(typeof format.formatSize, 'function');
    assert.equal(typeof format.setDefaultDateFormat, 'function');
    assert.equal(typeof format.formatDate, 'function');
});
Ejemplo n.º 5
0
test('modulejs.log() in order of definition', () => {
    const modjs = modulejs.create();
    modjs.define('c', {});
    modjs.define('a', {});
    modjs.define('d', ['c', 'b'], {});
    modjs.define('b', ['a'], {});
    assert.equal(modjs.log(), '\n  c -> [  ]\n  a -> [  ]\n  d -> [ c, a, b ]\n  b -> [ a ]\n');
    assert.equal(modjs.log(true), '\n  c -> [ d ]\n  a -> [ d, b ]\n  d -> [  ]\n  b -> [ d ]\n');
});
Ejemplo n.º 6
0
 test(`util.forOwn(${insp(x)}, fn)`, () => {
     const keys = Object.keys(x);
     const fn = spy();
     assert.equal(util.forOwn(x, fn), undefined);
     assert.equal(fn.calls.length, keys.length);
     fn.calls.forEach((call, idx) => {
         assert.equal(call.args[1], keys[idx]);
         assert.equal(call.args[0], x[keys[idx]]);
     });
 });
Ejemplo n.º 7
0
Archivo: ghor.js Proyecto: lrsjng/ghor
test('ghor runs function defs only once', () => {
    const obj = {};
    const fn = spy(obj);
    const defs = {a: fn};
    const resolve = ghor(defs);
    assert.equal(fn.calls.length, 0);
    assert.equal(resolve('a'), obj);
    assert.equal(fn.calls.length, 1);
    assert.equal(resolve('a'), obj);
    assert.equal(fn.calls.length, 1);
});
Ejemplo n.º 8
0
test('Target constructor with arguments', () => {
    const obj1 = {};
    const obj2 = {};
    const obj3 = {};
    const target = new Target(obj1, obj2, obj3);

    assert.equal(target.name, obj1);
    assert.equal(target.dependencies, obj2);
    assert.equal(target.description, obj3);
    assert.deepEqual(target._tasks, []);
});
Ejemplo n.º 9
0
test('Target task() multiple calls', () => {
    const obj = {};
    const obj2 = {};
    const target = new Target();
    assert.deepEqual(target._tasks, []);
    assert.equal(target.task([obj, obj2]), target);
    assert.deepEqual(target._tasks, [new Task([obj, obj2])]);
    assert.equal(target.task([obj]), target);
    assert.deepEqual(target._tasks, [new Task([obj, obj2]), new Task([obj])]);
    assert.equal(target.task(), target);
    assert.deepEqual(target._tasks, [new Task([obj, obj2]), new Task([obj]), new Task()]);
});
Ejemplo n.º 10
0
test('Suite target() sets arguments correct', () => {
    const obj1 = {};
    const obj2 = {};
    const obj3 = {};
    const suite = new Suite();
    const target = suite.target(obj1, obj2, obj3);

    assert.equal(target.name, obj1);
    assert.equal(target.dependencies, obj2);
    assert.equal(target.description, obj3);
    assert.deepEqual(target._tasks, []);
});
Ejemplo n.º 11
0
test('fQuery.fn.select() non blob select', () => {
    const v = {};
    const x = fQuery().select(v);
    assert.deep_equal(x._stack, [[], []]);
    assert.deep_equal(to_arr(x), []);
    assert.equal(x.length, 0);
});
Ejemplo n.º 12
0
test('fQuery.fn.select() non blob array select', () => {
    const v = [{}, 1, true, null, undefined, 'text'];
    const x = fQuery().select(v);
    assert.deep_equal(x._stack, [[], []]);
    assert.deep_equal(to_arr(x), []);
    assert.equal(x.length, 0);
});
Ejemplo n.º 13
0
test('proc - file.nd', () => {
    const env = {
        PATH_TRANSLATED: 'test/assets/d.nd'
    };
    const expected = readr('test/assets/d.txt');
    assert.equal(proc(env), expected);
});
Ejemplo n.º 14
0
test('fQuery.fn.select() blob select', () => {
    const b = fQuery.Blob.fromPath('test/assets/files-abc/a');
    const x = fQuery().select(b);
    assert.deep_equal(x._stack, [[b], []]);
    assert.deep_equal(to_arr(x), [b]);
    assert.equal(x.length, 1);
});
Ejemplo n.º 15
0
Archivo: ghor.js Proyecto: lrsjng/ghor
test('ghor injects _resolve', () => {
    const defs = {
        a: ({_resolve} = {}) => _resolve
    };
    const resolve = ghor(defs);
    assert.equal(resolve('a'), resolve);
});
Ejemplo n.º 16
0
test('Target constructor without arguments', () => {
    const target = new Target();

    assert.equal(target.name, 'unnamed');
    assert.deepEqual(target.dependencies, []);
    assert.deepEqual(target.description, '');
    assert.deepEqual(target._tasks, []);
});
Ejemplo n.º 17
0
Archivo: ghor.js Proyecto: lrsjng/ghor
test('ghor resolves function definitions', () => {
    const obj = {};
    const defs = {
        a: () => obj
    };
    const resolve = ghor(defs);
    assert.equal(resolve('a'), obj);
});
Ejemplo n.º 18
0
    return new Promise(resolve => {
        const x = fQuery();
        const after_then = () => {
            assert.equal(x.isPending(), false);
            resolve();
        };

        assert.equal(x.isPending(), false);

        x.then(() => {
            assert.equal(x.isPending(), true);
            setTimeout(after_then, 0);
            assert.equal(x.isPending(), true);
        });

        assert.equal(x.isPending(), true);
    });
Ejemplo n.º 19
0
test('Target task() with arguments', () => {
    const obj = {};
    const obj2 = {};
    const target = new Target();
    assert.deepEqual(target._tasks, []);
    assert.equal(target.task([obj, obj2]), target);
    assert.deepEqual(target._tasks, [new Task([obj, obj2])]);
});
Ejemplo n.º 20
0
test('fQuery.fn.select() multi blob array select', () => {
    const b1 = fQuery.Blob.fromPath('test/assets/files-abc/a');
    const b2 = fQuery.Blob.fromPath('test/assets/files-abc/b');
    const b3 = fQuery.Blob.fromPath('test/assets/files-abc/c');
    const x = fQuery().select([b1, b2, b3]).select([b1]).select(b3);
    assert.deep_equal(x._stack, [[b3], [b1], [b1, b2, b3], []]);
    assert.deep_equal(to_arr(x), [b3]);
    assert.equal(x.length, 1);
});
Ejemplo n.º 21
0
Archivo: ghor.js Proyecto: lrsjng/ghor
test('ghor resolves transitive', () => {
    const obj = {};
    const defs = {
        a: ({b} = {}) => b,
        b: obj
    };
    const resolve = ghor(defs);
    assert.equal(resolve('a'), obj);
});
Ejemplo n.º 22
0
Archivo: ghor.js Proyecto: lrsjng/ghor
test('ghor throws when no Proxy', () => {
    const bak = global.Proxy;
    global.Proxy = null;
    try {
        ghor({});
        global.Proxy = bak;
        throw new Error('no error thrown');
    } catch (err) {
        global.Proxy = bak;
        assert.equal(err.message, 'ghor-no-proxy');
    }
});
Ejemplo n.º 23
0
test('lolight is function', () => {
    assert.equal(typeof lolight, 'function');
});
Ejemplo n.º 24
0
test('util.forOwn is function', () => {
    assert.equal(typeof util.forOwn, 'function');
});
Ejemplo n.º 25
0
 fn.calls.forEach((call, idx) => {
     assert.equal(call.args[1], keys[idx]);
     assert.equal(call.args[0], x[keys[idx]]);
 });
Ejemplo n.º 26
0
test('event is object', () => {
    assert.equal(typeof event, 'object');
});
Ejemplo n.º 27
0
test('event.pub is function', () => {
    assert.equal(typeof event.pub, 'function');
});
Ejemplo n.º 28
0
test('run', () => {
    assert.equal(typeof run, 'function');
});
Ejemplo n.º 29
0
test('proc', () => {
    assert.equal(typeof proc, 'function');
});
Ejemplo n.º 30
0
test('cgi', () => {
    assert.equal(typeof cgi, 'function');
});