HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/zaklada/html/node_modules/gulp-flatten/test/flatten-path.js
var should = require('should');
var path = require('path');
var flattenPath = require('../lib/flatten-path');
var fileInstance;

describe('gulp-flatten', function () {

  beforeEach(function () {
    fileInstance = {
      base: '/some/project/src/',
      path: '/some/project/src/top1/top2/bottom2/bottom1/app.css',
      relative: 'top1/top2/bottom2/bottom1/app.css'
    };
  });

  describe('includeParents', function () {
    it('should keep top parent dirs from indludeParents option', function (done) {
      var topOnly = flattenPath(fileInstance, {includeParents: 1});
      topOnly.should.equal('top1/app.css');

      done();
    });

    it('should keep bottom parent dirs from indludeParents option', function (done) {
      var bottomOnly = flattenPath(fileInstance, {includeParents: [0, 1]});
      bottomOnly.should.equal('bottom1/app.css');

      done();
    });

    it('should treat negative number in indludeParents as bottom parent levels', function (done) {
      var bottomOnly = flattenPath(fileInstance, {includeParents: -1});
      bottomOnly.should.equal('bottom1/app.css');

      done();
    });

    it('should keep top and bottom parent dirs from indludeParents option', function (done) {
      var both = flattenPath(fileInstance, {includeParents: [1, 2]});
      both.should.equal('top1/bottom2/bottom1/app.css');

      done();
    });

    it('should pick relative path if indludeParents bottom+top too long', function (done) {
      var relative = flattenPath(fileInstance, {includeParents: [10, 10]});
      relative.should.equal(fileInstance.relative);

      done();
    });
  });

  describe('subPath', function () {
    it('should keep top parent dirs from subPath option', function (done) {
      var topOnly = flattenPath(fileInstance, {subPath: [0, 2]});
      topOnly.should.equal('top1/top2/app.css');

      done();
    });

    it('should keep bottom parent dirs from subPath option', function (done) {
      var bottomOnly = flattenPath(fileInstance, {subPath: -2});
      bottomOnly.should.equal('bottom2/bottom1/app.css');

      done();
    });

    it('should keep top2 and bottom2 from subPath option', function (done) {
      var middleOnly = flattenPath(fileInstance, {subPath: [1, -1]});
      middleOnly.should.equal('top2/bottom2/app.css');

      done();
    });
  });
});