HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/node_modules/deps-sort/test/expose_str.js
var sort = require('../');
var test = require('tap').test;
var through = require('through2');

test('expose string', function (t) {
    t.plan(1);
    var s = sort({
        index: true,
        expose: {
            'f': '/foo.js',
            'b': '/bar.js'
        }
    });
    var rows = [];
    function write (row, enc, next) { rows.push(row); next() }
    function end () {
        t.deepEqual(rows, [
            {
                id: '/main.js',
                deps: { './foo': '/foo.js' },
                index: 1,
                indexDeps: { './foo': 'f' }
            },
            {
                id: 'b',
                deps: {},
                index: 'b',
                indexDeps: {}
            },
            {
                id: 'f',
                deps: { './bar': '/bar.js' },
                index: 'f',
                indexDeps: { './bar': 'b' }
            }
        ]);
    }
    s.pipe(through.obj(write, end));
    
    s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
    s.write({ id: 'f', deps: { './bar': '/bar.js' } });
    s.write({ id: 'b', deps: {} });
    s.end();
});