2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-17 01:55:09 +00:00
iconify/tests/browser/loader_test.build.js

34 lines
1.3 KiB
JavaScript

/**
* Build test
*/
"use strict";
const fs = require('fs');
module.exports = (Helper, codeDir, testFile) => {
let code = fs.readFileSync(testFile, 'utf8'),
modules = [
'(function (SimpleSVG) {\n' +
fs.readFileSync(codeDir + '/common/storage.js', 'utf8')
.replace('module.exports = Storage;', 'SimpleSVG._Storage = Storage;') +
'\n})(self.SimpleSVG);\n',
fs.readFileSync(codeDir + '/browser/storage.js', 'utf8'),
fs.readFileSync(codeDir + '/browser/defaults.js', 'utf8'),
fs.readFileSync(codeDir + '/browser/with-cdn/defaults.js', 'utf8'),
fs.readFileSync(codeDir + '/browser/config.js', 'utf8'),
fs.readFileSync(codeDir + '/browser/image.js', 'utf8'),
'(function (SimpleSVG) {\n' +
'SimpleSVG.testLoaderURL = function() { return true; }' +
'\n})(self.SimpleSVG);\n',
fs.readFileSync(codeDir + '/browser/with-cdn/loader.js', 'utf8').replace('// Create script', 'if (!SimpleSVG.testLoaderURL(url)) return;')
];
// Replace code
modules = modules.map(item => item.replace('self.SimpleSVG', 'SimpleSVG')).join('');
// Merge modules and test
code = code.replace('/* Modules() */', modules);
return code;
};