diff --git a/test/common/cloudfunc.js b/test/common/cloudfunc.js
index d9e01d9b..7a00e1e6 100644
--- a/test/common/cloudfunc.js
+++ b/test/common/cloudfunc.js
@@ -1,13 +1,12 @@
'use strict';
-var DIR = __dirname + '/../../',
+const DIR = __dirname + '/../../',
COMMONDIR = DIR + 'common/',
TMPLDIR = DIR + 'tmpl/',
Util = require(COMMONDIR + 'util'),
CloudFunc = require(COMMONDIR + 'cloudfunc'),
files = require('files-io'),
- rendy = require('rendy'),
test = require('tape'),
@@ -36,28 +35,28 @@ var DIR = __dirname + '/../../',
uid : 0,
mode: 'rwx r-x r-x'
}]
- },
-
- Expect =
- '
' +
- '
' +
- '' +
- '
' +
- '
' +
- '/' +
- '' +
- 'etc' +
- '/X11/' +
- '' +
- '
';
+ };
-test(function(t) {
- var paths = {},
-
- filesList = TMPL_PATH.map(function(name) {
- var path = FS_DIR + name + '.hbs';
+let Expect =
+ '' +
+ '
' +
+ '' +
+ '
' +
+ '
' +
+ '/' +
+ '' +
+ 'etc' +
+ '/X11/' +
+ '' +
+ '
';
+
+test('render', (t) => {
+ const paths = {};
+ const filesList = TMPL_PATH
+ .map((name) => {
+ const path = FS_DIR + name + '.hbs';
paths[path] = name;
@@ -65,62 +64,57 @@ test(function(t) {
})
.concat(EXPECT_PATH);
- files.read(filesList, 'utf8', function(error, files) {
- var isNotOk, expect, result,
- i = 0,
- template = {};
+ files.read(filesList, 'utf8', (error, files) => {
+ const template = {};
- if (error) {
- throw(new Error(error));
- } else {
- Util.time('CloudFunc.buildFromJSON');
+ if (error)
+ throw(Error(error));
- Object.keys(files).forEach(function(path) {
- var name = paths[path];
+ Util.time('CloudFunc.buildFromJSON');
+
+ Object.keys(files).forEach((path) => {
+ const name = paths[path];
+
+ if (path !== EXPECT_PATH)
+ template[name] = files[path];
+ });
+
+ const expect = files[EXPECT_PATH];
+ const result = CloudFunc.buildFromJSON({
+ prefix : '',
+ data : JSON_FILES,
+ template: template
+ });
+
+ Expect += expect;
+
+ let i;
+ const isNotOk = Expect
+ .split('')
+ .some((item, number) => {
+ const ret = result[number] !== item;
- if (path !== EXPECT_PATH)
- template[name] = files[path];
- });
-
- expect = files[EXPECT_PATH];
-
- result = CloudFunc.buildFromJSON({
- prefix : '',
- data : JSON_FILES,
- template: template
- });
-
- Expect += expect;
-
- isNotOk = Expect.split('').some(function(item, number) {
- var ret = result[number] !== item;
-
- if (ret)
+ if (ret) {
i = number;
+ }
return ret;
});
+
+ Util.timeEnd('CloudFunc.buildFromJSON');
+
+ if (isNotOk) {
+ console.log(
+ `Error in char number: ${i}\n`,
+ `Expect: ${Expect.substr(i)}\n`,
+ `Result: ${result.substr(i)}`
+ );
- Util.timeEnd('CloudFunc.buildFromJSON');
-
- if (isNotOk) {
- console.log(rendy([
- 'Error in char number: {{ number }}',
- 'Expect: {{ expect }}',
- 'Result: {{ result }}'
- ].join('\n'), {
- number: i,
- expect: Expect.substr(i),
- result: result.substr(i)
- }));
-
- console.log('buildFromJSON: Not OK');
- }
-
- t.equal(Expect, result, 'should be equal rendered json data');
-
- t.end();
+ console.log('buildFromJSON: Not OK');
}
+
+ t.equal(Expect, result, 'should be equal rendered json data');
+ t.end();
});
});