forked from geekflyer/gulp-ui5-preload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (46 loc) · 1.97 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
'use strict';
var gutil = require('gulp-util');
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 gutil.File({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new gutil.File({
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 file full of unicorns and zebras :-)', function (done) {
var stream = ui5Preload({base: 'src/conf/ui', namespace: 'sap.pdms.fdn', isLibrary: true});
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 gutil.File({
base: __dirname,
path: __dirname + '/src/conf/ui/app/unicorns.js',
contents: new Buffer('unicorns')
}));
stream.write(new gutil.File({
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();
});