Skip to content
Snippets Groups Projects
Select Git revision
  • 022ff1229c9804650d323d72d9edef240ade1367
  • master default protected
  • 1.31
  • 4.38.8
  • 4.38.7
  • 4.38.6
  • 4.38.5
  • 4.38.4
  • 4.38.3
  • 4.38.2
  • 4.38.1
  • 4.38.0
  • 4.37.2
  • 4.37.1
  • 4.37.0
  • 4.36.0
  • 4.35.0
  • 4.34.1
  • 4.34.0
  • 4.33.1
  • 4.33.0
  • 4.32.2
  • 4.32.1
23 results

column-bar.pcss

Blame
  • pipe.mjs 3.75 KiB
    "use strict";
    
    import {expect} from "chai"
    import {Pipe} from "../../../source/data/pipe.mjs";
    import {initJSDOM} from "../../util/jsdom.mjs";
    import {Embed} from "../../../source/i18n/providers/embed.mjs";
    
    
    describe('Pipe', function () {
    
        before(function (done) {
    
            let promises = []
            if (!globalThis['crypto']) {
                promises.push(import("@peculiar/webcrypto").then(m => {
                    globalThis['crypto'] = new m.Crypto();
                    return true;
                }))
            }
    
            Promise.all(promises).then(() => {
                done()
            });
    
        });
    
        describe('run different pipes', function () {
            [
                ['path:b | if:x:\\ ', {a: true}, ' '],   // '\\ '.length ↦ 2
                ['path:a | if:x:\\ ', {a: true}, 'x'],
                ['nop', 'abcdefghijklmnop', 'abcdefghijklmnop'],
    
            ].forEach(function (data) {
    
                let a = data.shift()
                let b = data.shift()
                let c = data.shift()
    
                it('Pipe.run(' + JSON.stringify(a) + ').run(' + JSON.stringify(b) + ') should return ' + JSON.stringify(c), function () {
                    let t = new Pipe(a);
    
                    const r = t.run(b);
                    expect(r).to.be.eql(c);
                });
            });
    
    
        });
    
    
        describe('new Pipe should create new Instance', function () {
    
            it('should return Instance', function () {
                expect(new Pipe('')).to.be.instanceOf(Pipe);
            });
    
            it('should return Instance', function () {
                expect(new Pipe('index:a|toupper |prefix:a').run({a: "test"})).to.be.equal('aTEST');
            });
    
            [
                ['index:a|toupper |prefix:a', {a: "test"}, 'aTEST'],
                ['path:a.b.c.d | toupper | prefix:Hello\\ ', {
                    a: {
                        b: {
                            c: {
                                d: "world"
                            }
                        }
                    }