Beispiel #1
0
 it('service module', function(){
   var instance = new Base({res: {}, req: {}});
   muk(think, 'module', ['home']);
   var cls = instance.service('fasdfasdfasfww', 'home');
   assert.equal(think.isFunction(cls), true);
   muk.restore();
 })
Beispiel #2
0
      think.middleware('parse_form_payload', http).then(function(data){
        assert.equal(data, undefined);
        assert.deepEqual(http._post, {});

        muk.restore();
        done();
      }).catch(function(err){
Beispiel #3
0
 think.npm('source-map@0.5.3').then(function(){
   var result = instance.compileByTypeScript('let a = 1', 'a.ts');
   var content = fs.readFileSync(outPath + think.sep + 'a.js', 'utf8');
   assert.equal(content.trim(), '"use strict";\n\nvar a = 1;\n//# sourceMappingURL=a.js.map');
   muk.restore();
   think.rmdir(outPath).then(function(){
     done();
   });
 })
Beispiel #4
0
 it('service module not exist', function(){
   var instance = new Base({res: {}, req: {}});
   muk(think, 'module', ['home']);
   try{
     var cls = instance.service('fasdfasdfasfww', 'not exist');
     assert.equal(1, 2);
   }catch(e){}
   //assert.equal(think.isFunction(cls), true);
   muk.restore();
 })
Beispiel #5
0
 it('log connect off', function(){
   var instance = new BaseSocket();
   instance.config = {log_connect: false};
   var flag = false;
   muk(think, 'log', function(fn, type){
     flag = true;
   })
   instance.logConnect();
   muk.restore();
   assert.equal(flag, false);
 })
Beispiel #6
0
 it('log connect', function(){
   var instance = new BaseSocket();
   instance.config = {log_connect: true};
   muk(think, 'log', function(fn, type){
     assert.equal(type, 'SOCKET');
     var str = fn && fn({magenta: function(){}});
     assert.equal(str.indexOf('Connect') > -1, true)
   })
   instance.logConnect();
   muk.restore();
 })
Beispiel #7
0
  it('compileByTypeScript, show log', function(done){
   var srcPath = __dirname + think.sep + 'compile_src';
   var outPath = __dirname + think.sep + 'compile_output';
   var instance = new Compile(srcPath, outPath, {log: true});
   var result = instance.compileByTypeScript('let a = 1', 'a.ts');
   var content = fs.readFileSync(outPath + think.sep + 'a.js', 'utf8');
   assert.equal(content.trim(), '"use strict";\n\nvar a = 1;\n//# sourceMappingURL=a.js.map');
   muk.restore();
   think.rmdir(outPath).then(function(){
     done();
   });
 })
Beispiel #8
0
 it('merge config', function(done){
   var instance = new baseTemplate();
   muk(think, 'log', function(msg){
     assert.equal(msg.indexOf('view.options') > -1, true);
   })
   var data = instance.parseConfig({
     options: {name: 111}
   });
   assert.deepEqual(data.name, 111);
   muk.restore();
   done();
 })
Beispiel #9
0
 it('compileByBabel, show log', function(done){
   muk(think, 'log', function(msg, type){
     assert.equal(type, 'Babel')
   })
   var srcPath = __dirname + think.sep + 'compile_src';
   var outPath = __dirname + think.sep + 'compile_output';
   var instance = new Compile(srcPath, outPath, {retainLines: true, log: true});
   var result = instance.compileByBabel('let a = 1', 'a.js');
   var content = fs.readFileSync(outPath + think.sep + 'a.js', 'utf8');
   assert.equal(content, '"use strict";\n\nvar a = 1;\n//# sourceMappingURL=a.js.map');
   muk.restore();
   think.rmdir(outPath).then(function(){
     done();
   });
 })
Beispiel #10
0
 it('merge config', function(done){
   var instance = new baseTemplate();
   muk(think, 'log', function(callback){
     var msg = callback && callback({
       yellow: function(msg){
         return msg
       }
     });
     assert.equal(msg.indexOf('[DEPRECATED]') > -1, true);
   })
   var data = instance.parseConfig({
     options: {name: 111}
   });
   assert.deepEqual(data.name, 111);
   muk.restore();
   done();
 })
Beispiel #11
0
  it('parseWhere, with _id, mongoid', function(){
    var instance = new Parse();
    var req = think.require;
    muk(think, 'require', function(name){
      if(name === 'validator'){
        return req('validator');
      }
      return {
        ObjectID: function(){
          return {}
        }
      }
    })
    var data = instance.parseWhere({
      _id: '563473fae61a1b3709e43ae2'
    });
    assert.equal(typeof data._id, 'object');
    //assert.equal(JSON.stringify(data), '{"_id":"563473fae61a1b3709e43ae2"}');

    muk.restore();
  })
Beispiel #12
0
 it('close', function(done){
   muk(think, 'npm', function(name){
     return {
       Client: {
         create: function(str){
           assert.equal(str, 'welefen:suredy@127.0.0.1:11211');
           return {
             connection: 'connection',
             close: function(key, amount, callback){
               
             }
           }
         }
       }
     }
   })
   var instance = new memcacheSocket({
     username: '******',
     password: '******'
   });
   instance.close();
   muk.restore();
   done();
 })
Beispiel #13
0
exports.restore = function () {
  getAgent(http).request = getAgent(http).__sourceRequest;
  getAgent(https).request = getAgent(https).__sourceRequest;
  muk.restore();
  return this;
};
Beispiel #14
0
 setTimeout(function(){
   muk.restore();
   done();
 }, 20)
Beispiel #15
0
 instance.query('SELECT * FROM `empty`').catch(function(){
   assert.equal(flag, true);
   muk.restore();
   done();
 })
Beispiel #16
0
 instance.delete('welefen').then(function(){
   muk.restore();
   done();
 })
 after(function () {
   muk.restore();
 });
Beispiel #18
0
 instance.run(__filename).then(function(data){
   assert.equal(data.indexOf("describe('adapter/template/nunjucks.js'") > -1, true);
   muk.restore();
   done();
 }).catch(function(err){
Beispiel #19
0
 }).then(function(data){
   assert.equal(data, 'cache_content');
   thinkCache(thinkCache.VIEW_CONTENT, __filename + '-compile', null);
   muk.restore();
   done();
 })
Beispiel #20
0
 instance.getConnection().then(function(){
   muk.restore();
   done();
 });
Beispiel #21
0
 instance.decrement('welefen', 1000).catch(function(){
   muk.restore();
   done();
 })
Beispiel #22
0
 instance.decrement('welefen', 1000, 2000).then(function(){
   muk.restore();
   done();
 })
Beispiel #23
0
 instance.delete('welefen').catch(function(err){
   assert.equal(err.message, 'memcache delete data error')
   muk.restore();
   done();
 })
Beispiel #24
0
 ]).then(function(){
   muk.restore();
   think.compileError = null;
   done();
 });
Beispiel #25
0
 }).then(function(data){
   assert.equal(data.indexOf("describe('adapter/template/jade.js'") > -1, true);
   muk.restore();
   assert.equal(flag, true);
   done();
 })
Beispiel #26
0
 instance.run().then(function(){
   muk.restore();
   done();
 }).catch(function(err){
Beispiel #27
0
 }).then(function(data){
   assert.equal(data.indexOf("describe('adapter/template/base.js'") > -1, true);
   muk.restore();
   done();
 }).catch(function(err){
Beispiel #28
0
 it('after', function(){
   C('url_route_rules', []);
   muk.restore();
 })
Beispiel #29
0
 instance.getConnection().then(function(){
   muk.restore();
   return instance.getConnection();
 }).then(function(connection){
Beispiel #30
0
 instance.set('welefen', 'suredy', 1000).catch(function(){
   muk.restore();
   done();
 })