forked from jomaguma/gulp-ui5-preload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
131 lines (106 loc) · 4.66 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';
var Vinyl = require('vinyl');
var path = require('path');
var ui5Preload = require('./');
var expect = require('code').expect;
var lab = exports.lab = require('lab').script();
lab.test('creates a preload file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn'});
var expectedFile = 'jQuery.sap.registerPreloadedModules({\n\t"name": "sap.pdms.fdn.Component-preload",\n\t"version": "2.0",\n\t"modules": {\n\t\t"sap/pdms/fdn/app/unicorns.js": "unicorns",\n\t\t\"sap/pdms/fdn/app/zebras.xml": "zebras"\n\t}\n});';
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/zebras.xml',
contents: new Buffer('zebras')
}));
stream.on('data', function (file) {
expect(file.contents.toString()).to.equal(expectedFile);
expect(file.path.split(path.sep).pop()).to.equal('Component-preload.js');
});
stream.on('end', done);
stream.end();
});
lab.test('creates a library-preload.js file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn', isLibrary: true});
var expectedFile = 'jQuery.sap.registerPreloadedModules({\n\t"name": "sap.pdms.fdn.library-preload",\n\t"version": "2.0",\n\t"modules": {\n\t\t"sap/pdms/fdn/app/unicorns.js": "unicorns",\n\t\t\"sap/pdms/fdn/app/zebras.xml": "zebras"\n\t}\n});';
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/zebras.xml',
contents: new Buffer('zebras')
}));
stream.on('data', function (file) {
expect(file.contents.toString()).to.equal(expectedFile);
expect(file.path.split(path.sep).pop()).to.equal('library-preload.js');
});
stream.on('end', done);
stream.end();
});
lab.test('creates a library-preload.json file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn', isLibrary: true, format: 'json'});
var expectedFile = '{\n\t"name": "sap.pdms.fdn.library-preload",\n\t"version": "2.0",\n\t"modules": {\n\t\t"sap/pdms/fdn/app/unicorns.js": "unicorns",\n\t\t\"sap/pdms/fdn/app/zebras.xml": "zebras"\n\t}\n}';
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/zebras.xml',
contents: new Buffer('zebras')
}));
stream.on('data', function (file) {
expect(file.contents.toString()).to.equal(expectedFile);
expect(file.path.split(path.sep).pop()).to.equal('library-preload.json');
});
stream.on('end', done);
stream.end();
});
lab.test('creates a foo.js file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn', isLibrary: true, fileName: 'foo.js'});
var expectedFile = 'jQuery.sap.registerPreloadedModules({\n\t"name": "sap.pdms.fdn.library-preload",\n\t"version": "2.0",\n\t"modules": {\n\t\t"sap/pdms/fdn/app/unicorns.js": "unicorns",\n\t\t\"sap/pdms/fdn/app/zebras.xml": "zebras"\n\t}\n});';
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/zebras.xml',
contents: new Buffer('zebras')
}));
stream.on('data', function (file) {
expect(file.contents.toString()).to.equal(expectedFile);
expect(file.path.split(path.sep).pop()).to.equal('foo.js');
});
stream.on('end', done);
stream.end();
});
lab.test('creates a foo.json file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn', isLibrary: true, fileName: 'foo.json'});
var expectedFile = '{\n\t"name": "sap.pdms.fdn.library-preload",\n\t"version": "2.0",\n\t"modules": {\n\t\t"sap/pdms/fdn/app/unicorns.js": "unicorns",\n\t\t\"sap/pdms/fdn/app/zebras.xml": "zebras"\n\t}\n}';
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new Vinyl({
base: __dirname,
path: __dirname + '/src/conf/ui/app/zebras.xml',
contents: new Buffer('zebras')
}));
stream.on('data', function (file) {
expect(file.contents.toString()).to.equal(expectedFile);
expect(file.path.split(path.sep).pop()).to.equal('foo.json');
});
stream.on('end', done);
stream.end();
});