403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/vhosts/convo/node_modules/sass-graph/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/convo/node_modules/sass-graph/test/test.js
var assert = require("assert");
var path = require("path");

var fixtures = path.resolve("test/fixtures");
var files = {
  'a.scss': path.join(fixtures, 'a.scss'),
  'b.scss': path.join(fixtures, 'b.scss'),
  '_c.scss': path.join(fixtures, '_c.scss'),
  'd.scss': path.join(fixtures, 'd.scss'),
  '_e.scss': path.join(fixtures, 'components/_e.scss'),
  'f.scss': path.join(fixtures, 'f.scss'),
  'g.scss': path.join(fixtures, 'g.scss'),
  '_h.scss': path.join(fixtures, 'nested/_h.scss'),
  '_i.scss': path.join(fixtures, 'nested/_i.scss'),
  'i.scss': path.join(fixtures, '_i.scss'),
  'j.scss': path.join(fixtures, 'j.scss'),
  'k.l.scss': path.join(fixtures, 'components/k.l.scss'),
  'm.scss': path.join(fixtures, 'm.scss'),
  '_n.scss': path.join(fixtures, 'compass/_n.scss'),
  '_p.scss': path.join(fixtures, '_o.scss/_p.scss'),
  'r.scss': path.join(fixtures, 'r.scss'),
  '_s.scss': path.join(fixtures, 'components/_q.scss/_s.scss'),
  '_compass.scss': path.join(fixtures, 'components/_compass.scss')
}

describe('sass-graph', function(){
  var sassGraph = require('../sass-graph');

  describe('parsing a graph of all scss files', function(){
    var graph = sassGraph.parseDir(fixtures, {loadPaths: [fixtures + '/components']});

    it('should have all files', function(){
      assert.equal(Object.keys(files).length, Object.keys(graph.index).length);
    })

    it('should have the correct imports for a.scss', function() {
      assert.deepEqual([files['b.scss']], graph.index[files['a.scss']].imports);
    });

    it('should have the correct importedBy for _c.scss', function() {
      assert.deepEqual([files['b.scss']], graph.index[files['_c.scss']].importedBy);
    });

    it('should have the correct (nested) imports for g.scss', function() {
      var expectedDescendents = [files['_h.scss'], files['_i.scss']];
      var descendents = [];

      graph.visitDescendents(files['g.scss'], function (imp) {
        descendents.push(imp);
        assert.notEqual(expectedDescendents.indexOf(imp), -1);
      });
    });

    it('should ignore custom imports for m.scss', function() {
      assert.deepEqual([files['_compass.scss'] , files['_n.scss']], graph.index[files['m.scss']].imports);
    });

    it('should ignore folder "_q.scss" which has allowed extensions (but not it’s children), referenced from r.scss', function() {
      assert.deepEqual([files['_compass.scss'], files['_s.scss']], graph.index[files['r.scss']].imports);
    });

    it('should traverse ancestors of _c.scss', function() {
      ancestors = [];
      graph.visitAncestors(files['_c.scss'], function(k) {
        ancestors.push(k);
      })
      assert.deepEqual([files['b.scss'], files['a.scss']], ancestors);
    });

    it('should prioritize cwd', function() {
      var expectedDescendents = [files['_i.scss']];
      var descendents = [];

      graph.visitDescendents(files['_h.scss'], function (imp) {
        descendents.push(imp);
        assert.notEqual(expectedDescendents.indexOf(imp), -1);
      });
    });
  })

  describe('parseFile', function () {
    it('should parse imports', function () {
      var graph = sassGraph.parseFile(files['a.scss']);
      var expectedDescendents = [files['b.scss'], files['_c.scss']];
      var descendents = [];
      graph.visitDescendents(files['a.scss'], function (imp) {
        descendents.push(imp);
        assert.notEqual(expectedDescendents.indexOf(imp), -1);
      });
      assert.equal(expectedDescendents.length, descendents.length);
    });
  });

  describe('parseFile', function () {
    it('should parse imports with loadPaths', function () {
      var graph = sassGraph.parseFile(files['d.scss'], {loadPaths: [fixtures + '/components']} );
      var expectedDescendents = [files['_e.scss']];
      var descendents = [];
      graph.visitDescendents(files['d.scss'], function (imp) {
        descendents.push(imp);
        assert.notEqual(expectedDescendents.indexOf(imp), -1);
      });
      assert.equal(expectedDescendents.length, descendents.length);
    });
  });

  describe('parseFile', function () {
    it('should thow an error', function () {
      try {
        var graph = sassGraph.parseFile(files['d.scss']);
      } catch (e) {
        assert.equal(e, "File to import not found or unreadable: e");
      }
    });
  });

  describe('parseFile', function () {
    it('should not throw an error for a file with no dependencies with Array having added functions', function () {
      try {
        Array.prototype.foo = function() {
          return false;
        }
        var graph = sassGraph.parseFile(files['f.scss']);
      } catch (e) {
        assert.fail("Error: " + e);
      }
    });
  });
});

Youez - 2016 - github.com/yon3zu
LinuXploit