UNPKG

5.28 kBJavaScriptView Raw
1/*jshint node: true */
2var NA = require("../"),
3 expect = require("chai").expect,
4 na = new NA(),
5 na2 = new NA(),
6 naFile = new NA(),
7 na2File = new NA();
8
9Promise.all([new Promise(function (resolve) {
10 describe("Inheritance: NAP inherite from NA", function() {
11 var NAP = function () {
12 if (!(this instanceof NAP)) {
13 return new NAP();
14 }
15
16 NA.call(this);
17 };
18
19 NAP.prototype = Object.create(NA.prototype);
20 NAP.prototype.constructor = NA;
21
22 it("(new NA()) instanceof NA", function() {
23 expect(new NA() instanceof NA).to.equal(true);
24 });
25 it("NA() instanceof NA", function() {
26 expect(NA() instanceof NA).to.equal(true);
27 });
28 it("(new NAP()) instanceof NAP", function() {
29 expect(new NAP() instanceof NAP).to.equal(true);
30 });
31 it("NAP() instanceof NAP", function() {
32 expect(NAP() instanceof NAP).to.equal(true);
33 });
34 it("(new NAP()) instanceof NA", function() {
35 expect(new NAP() instanceof NA).to.equal(true);
36 });
37 it("NAP() instanceof NA", function() {
38 expect(NAP() instanceof NA).to.equal(true);
39 });
40
41 after(function () {
42 resolve();
43 })
44 });
45}), new Promise(function (resolve) {
46 describe("All NodeAtlas property from NA instance and prototype chain", function() {
47 var all = [];
48 function logAllProperties(obj) {
49 if (obj === null) {
50 return;
51 }
52 all.push(Object.getOwnPropertyNames(obj));
53 logAllProperties(Object.getPrototypeOf(obj));
54 }
55 logAllProperties(na);
56
57 it("All properties of NA instance have not changed?", function() {
58 expect(all[0]).to.deep.equal([
59 'configuration',
60 'afterGeneration',
61 'afterClosing',
62 'afterRunning',
63 'afterNewProject'
64 ]);
65 });
66
67 it("All properties of NA prototype have not changed?", function() {
68 expect(all[1]).to.deep.equal([
69 'constructor',
70 'initCliConfiguration',
71 'initRequiredVars',
72 'initRequiredNpmModulesVars',
73 'initWebsite',
74 'initServerModules',
75 'createWebconfig',
76 'initNodeModules',
77 'initNpmModules',
78 'openConfiguration',
79 'log',
80 'openController',
81 "openView",
82 "openVariation",
83 'extend',
84 'clone',
85 'forEach',
86 'ifFileExist',
87 'common',
88 'specific',
89 'view',
90 'simpleWebServer',
91 'nodeAtlasWebServer',
92 'initMiddlewares',
93 'initLessProcess',
94 'initStylusProcess',
95 'initSessions',
96 'initSockets',
97 'initConfigurations',
98 'initServer',
99 'initStatics',
100 'initRoutes',
101 'indexPage',
102 'sendResponse',
103 'redirect',
104 'executeRequest',
105 'request',
106 'requestRegex',
107 'pageNotFound',
108 'prepareResponse',
109 'prepareHeaders',
110 'prepareRenderLanguage',
111 'prepareRenderPath',
112 'prepareRenderVariation',
113 'changeVariationsCommon',
114 'changeVariationsSpecific',
115 'changeDomCommon',
116 'changeDomSpecific',
117 'intoBrowserAndFiles',
118 'renderTemplate',
119 'cssAlreadyParse',
120 'injectCssAuth',
121 'prepareCssInjection',
122 'injectCss',
123 'lessCompilation',
124 'stylusCompilation',
125 'cssCompilation',
126 'cssMinification',
127 'imgOptimization',
128 'jsObfuscation',
129 'createTemplateProject',
130 'initOutputs',
131 'publicsGeneration',
132 'staticsGeneration',
133 'generateAssets',
134 'saveRender',
135 'changeLanguage',
136 'init',
137 'generated',
138 'started',
139 'created',
140 'stopped',
141 'exit',
142 'close',
143 'start',
144 'run'
145 ]);
146 });
147
148 after(function () {
149 resolve();
150 })
151 });
152}), new Promise(function (resolve) {
153 na.started(function () {
154 na2.started(function () {
155 describe("Avoid instance pollution", function() {
156 it("webconfig port different", function() {
157 expect(na.webconfig.httpPort).to.not.equal(na2.webconfig.httpPort);
158 });
159 it("`/` is different", function() {
160 expect(na.webconfig.routes['/']).to.not.equal(na2.webconfig.routes['/']);
161 });
162 na.webconfig.routes['/test'] = 'test.htm';
163 it("`/test` do not exist", function() {
164 expect(na2.webconfig.routes['/test']).to.equal(undefined);
165 });
166
167 after(function () {
168 na.close();
169 na2.close();
170 resolve();
171 })
172 });
173 }).run({
174 "path": __dirname,
175 "webconfig": "webconfig2.json"
176 });
177 }).run({
178 "path": __dirname,
179 "webconfig": "webconfig.json"
180 });
181}), new Promise(function (resolve) {
182 naFile.started(function () {
183 na2File.started(function () {
184 describe("Avoid route pollution", function() {
185 it("webconfig port different", function() {
186 expect(naFile.webconfig.httpPort).to.not.equal(na2File.webconfig.httpPort);
187 });
188 it("`/` is same", function() {
189 expect(naFile.webconfig.routes['/']).to.equal(na2File.webconfig.routes['/']);
190 });
191 naFile.webconfig.routes['/test'] = 'test.htm';
192 it("`/test` do not exist", function() {
193 expect(na2File.webconfig.routes['/test']).to.equal(undefined);
194 });
195
196 after(function () {
197 naFile.close();
198 na2File.close();
199 resolve();
200 });
201 });
202 }).run({
203 "path": __dirname,
204 "webconfig": "webconfig-f2.json"
205 });
206 }).run({
207 "path": __dirname,
208 "webconfig": "webconfig-f.json"
209 });
210})]).then(function () {
211 process.exit(0);
212});
\No newline at end of file