not-node 5.1.44 → 5.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,126 +1,121 @@
1
- const mock = require('mock-require');
1
+ const mock = require("mock-require");
2
2
 
3
- let staticFunction = function(){
4
-
5
- };
3
+ let staticFunction = function () {};
6
4
 
7
5
  const mod = {
8
- static: function(){
9
- return staticFunction;
10
- }
6
+ static: function () {
7
+ return staticFunction;
8
+ },
11
9
  };
12
- mock.stop('serve-static');
13
- mock('serve-static', mod.static);
14
-
15
- const InitStatic = require('../../src/init/static');
16
-
17
- module.exports = ({expect})=>{
18
- describe('Static', ()=>{
19
- describe('getUserRole', ()=>{
20
- it('user exists', ()=>{
21
- const res = InitStatic.getUserRole({
22
- user:{
23
- role: 'user'
24
- }
25
- });
26
- expect(res).to.be.equal('user');
27
- });
28
-
29
- it('user not exists', ()=>{
30
- const res = InitStatic.getUserRole({});
31
- expect(res).to.be.equal('guest');
32
- });
33
- });
10
+ mock.stop("serve-static");
11
+ mock("serve-static", mod.static);
34
12
 
35
- describe('selectVersion', ()=>{
36
- it('user exists, ext - js', ()=>{
37
- const config = {
38
- get(str){
39
- return {
40
- 'user:roles:priority': ['root','user','guest'],
41
- 'path:front': 'path_from_fake'
42
- }[str];
43
- }
44
- };
45
- const res = InitStatic.selectVersion(config, {
46
- user:{
47
- role: 'user'
48
- }
49
- }, 'js');
50
- expect(res).to.be.equal('path_from_fake/user.js');
51
- });
13
+ const InitStatic = require("../../src/init/lib/static");
52
14
 
53
- it('user role not in list', ()=>{
54
- const config = {
55
- get(str){
56
- return {
57
- 'path:front': 'path_from_fake'
58
- }[str];
59
- }
60
- };
61
- const res = InitStatic.selectVersion(config, {
62
- user:{
63
- role: 'manager'
64
- }
65
- }, 'js');
66
- expect(res).to.be.equal('path_from_fake/guest.js');
67
- });
68
- });
15
+ module.exports = ({ expect }) => {
16
+ describe("Static", () => {
17
+ describe("getUserRole", () => {
18
+ it("user exists", () => {
19
+ const res = InitStatic.getUserRole({
20
+ user: {
21
+ role: "user",
22
+ },
23
+ });
24
+ expect(res).to.be.equal("user");
25
+ });
69
26
 
70
- describe('createStaticFrontServer', ()=>{
27
+ it("user not exists", () => {
28
+ const res = InitStatic.getUserRole({});
29
+ expect(res).to.be.equal("guest");
30
+ });
31
+ });
71
32
 
72
- it('user exists, ext - js', ()=>{
73
- InitStatic.serveStatic = mod.static;
74
- const config = {
75
- get(str){
76
- return {
77
- 'user:roles:priority': ['root','user','guest'],
78
- 'path:front': 'path_from_fake'
79
- }[str];
80
- }
81
- };
82
- const res = InitStatic.createStaticFrontServer(
83
- 'js',
84
- {
85
- config,
86
- options: {
87
- pathToApp: 'pathToApp__fake'
88
- }
89
- }
90
- );
91
- staticFunction = (rq,rs,nxt)=>{
92
- console.log('new static function');
93
- throw new Error('Some fake error');
94
- };
95
- expect(typeof res).to.be.equal('function');
96
- res(
97
- {},
98
- {},
99
- (e)=>{
100
- expect(e).to.be.instanceof(Error);
101
- expect(e.message).to.be.equal('Some fake error');
102
- }
103
- );
104
- });
105
- });
33
+ describe("selectVersion", () => {
34
+ it("user exists, ext - js", () => {
35
+ const config = {
36
+ get(str) {
37
+ return {
38
+ "user:roles:priority": ["root", "user", "guest"],
39
+ "path:front": "path_from_fake",
40
+ }[str];
41
+ },
42
+ };
43
+ const res = InitStatic.selectVersion(
44
+ config,
45
+ {
46
+ user: {
47
+ role: "user",
48
+ },
49
+ },
50
+ "js"
51
+ );
52
+ expect(res).to.be.equal("path_from_fake/user.js");
53
+ });
106
54
 
55
+ it("user role not in list", () => {
56
+ const config = {
57
+ get(str) {
58
+ return {
59
+ "path:front": "path_from_fake",
60
+ }[str];
61
+ },
62
+ };
63
+ const res = InitStatic.selectVersion(
64
+ config,
65
+ {
66
+ user: {
67
+ role: "manager",
68
+ },
69
+ },
70
+ "js"
71
+ );
72
+ expect(res).to.be.equal("path_from_fake/guest.js");
73
+ });
74
+ });
107
75
 
108
- describe('run', ()=>{
76
+ describe("createStaticFrontServer", () => {
77
+ it("user exists, ext - js", () => {
78
+ InitStatic.serveStatic = mod.static;
79
+ const config = {
80
+ get(str) {
81
+ return {
82
+ "user:roles:priority": ["root", "user", "guest"],
83
+ "path:front": "path_from_fake",
84
+ }[str];
85
+ },
86
+ };
87
+ const res = InitStatic.createStaticFrontServer("js", {
88
+ config,
89
+ options: {
90
+ pathToApp: "pathToApp__fake",
91
+ },
92
+ });
93
+ staticFunction = (rq, rs, nxt) => {
94
+ console.log("new static function");
95
+ throw new Error("Some fake error");
96
+ };
97
+ expect(typeof res).to.be.equal("function");
98
+ res({}, {}, (e) => {
99
+ expect(e).to.be.instanceof(Error);
100
+ expect(e.message).to.be.equal("Some fake error");
101
+ });
102
+ });
103
+ });
109
104
 
110
- it('generic', async ()=>{
111
- const master = {
112
- getServer(){
113
- return {
114
- use(route, func){
115
- expect(typeof route).to.be.equal('string');
116
- expect(typeof func).to.be.equal('function');
117
- }
118
- };
119
- }
120
- };
121
- await new InitStatic().run({master});
122
- });
105
+ describe("run", () => {
106
+ it("generic", async () => {
107
+ const master = {
108
+ getServer() {
109
+ return {
110
+ use(route, func) {
111
+ expect(typeof route).to.be.equal("string");
112
+ expect(typeof func).to.be.equal("function");
113
+ },
114
+ };
115
+ },
116
+ };
117
+ await new InitStatic().run({ master });
118
+ });
119
+ });
123
120
  });
124
-
125
- });
126
121
  };
@@ -1,46 +1,51 @@
1
- const InitTemplate = require('../../src/init/template');
1
+ const InitTemplate = require("../../src/init/lib/template");
2
2
 
3
- module.exports = ({
4
- expect
5
- }) => {
6
- describe('InitTemplate', () => {
7
- describe('run', () => {
8
- it('run, middleware returned and set', async () => {
9
- let setCalled = 0;
10
- const master = {
11
- getAbsolutePath(str){return `${str}_fake_path`;},
12
- getServer() {
13
- return {
14
- set(key, val){
15
- setCalled++;
16
- expect(key).to.be.ok;
17
- expect(val).to.be.ok;
18
- }
19
- };
20
- }
21
- };
22
- const config = {
23
- get(str){
24
- return {
25
- engine: `${str}_fake_config_engine`,
26
- views: `${str}_fake_config_views`
27
- };
28
- }
29
- };
30
- await (new InitTemplate()).run({master, config});
31
- expect(setCalled).to.be.equal(2);
32
- });
33
-
34
- });
3
+ module.exports = ({ expect }) => {
4
+ describe("InitTemplate", () => {
5
+ describe("run", () => {
6
+ it("run, middleware returned and set", async () => {
7
+ let setCalled = 0;
8
+ const master = {
9
+ getAbsolutePath(str) {
10
+ return `${str}_fake_path`;
11
+ },
12
+ getServer() {
13
+ return {
14
+ set(key, val) {
15
+ setCalled++;
16
+ expect(key).to.be.ok;
17
+ expect(val).to.be.ok;
18
+ },
19
+ };
20
+ },
21
+ };
22
+ const config = {
23
+ get(str) {
24
+ return {
25
+ engine: `${str}_fake_config_engine`,
26
+ views: `${str}_fake_config_views`,
27
+ };
28
+ },
29
+ };
30
+ await new InitTemplate().run({ master, config });
31
+ expect(setCalled).to.be.equal(2);
32
+ });
33
+ });
35
34
 
36
- describe('loadConfig', () => {
37
- it('config not set for template', async () => {
38
- const res = InitTemplate.loadConfig({config:{get(){return false;}}});
39
- expect(res).to.be.deep.equal({
40
- views: 'views',
41
- engine: 'pug'
35
+ describe("loadConfig", () => {
36
+ it("config not set for template", async () => {
37
+ const res = InitTemplate.loadConfig({
38
+ config: {
39
+ get() {
40
+ return false;
41
+ },
42
+ },
43
+ });
44
+ expect(res).to.be.deep.equal({
45
+ views: "views",
46
+ engine: "pug",
47
+ });
48
+ });
42
49
  });
43
- });
44
50
  });
45
- });
46
51
  };