From 08cfc12fc39d6a0f4a73aa42852c2851be1590dd Mon Sep 17 00:00:00 2001 From: Manuel Mujica Date: Thu, 11 Jan 2018 12:49:58 -0700 Subject: [PATCH] Test steal-bundler does not move assets below dest Closes #882 --- package.json | 4 +- test/bundle_assets/prod-custom-dest.html | 10 +++++ test/bundle_assets_test.js | 55 +++++++++++++++++++++--- 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 test/bundle_assets/prod-custom-dest.html diff --git a/package.json b/package.json index ade5abf3..91de742c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "pdenodeify": "^0.1.0", "prettier": "1.9.2", "pump": "^1.0.2", - "steal-bundler": "^0.3.5", + "steal": "^1.6.4", + "steal-bundler": "^0.3.6", "steal-parse-amd": "^1.0.0", "through2": "^2.0.0", "tmp": "0.0.33", @@ -56,7 +57,6 @@ "mockery": "^2.0.0", "rimraf": "^2.6.2", "serve-static": "^1.12.6", - "steal": "^1.6.4", "steal-conditional": "^0.4.0", "steal-css": "^1.3.1", "steal-less": "^1.2.2", diff --git a/test/bundle_assets/prod-custom-dest.html b/test/bundle_assets/prod-custom-dest.html new file mode 100644 index 00000000..57df3546 --- /dev/null +++ b/test/bundle_assets/prod-custom-dest.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/test/bundle_assets_test.js b/test/bundle_assets_test.js index 831ba357..808e84cf 100644 --- a/test/bundle_assets_test.js +++ b/test/bundle_assets_test.js @@ -1,6 +1,5 @@ var asap = require("pdenodeify"), assert = require("assert"), - comparify = require("comparify"), fs = require("fs-extra"), multiBuild = require("../index").build, optimize = require("../index").optimize, @@ -36,7 +35,7 @@ describe("bundleAssets", function(){ } }).then(function(){ open("test/bundle_assets/prod.html", function(browser, close){ - find(browser, "MODULE", function(module){ + find(browser, "MODULE", function(){ const logo = path.join(__dirname, "bundle_assets", "dist", "images", "logo.png"); assert(fs.pathExistsSync(logo), "image was copied"); @@ -50,6 +49,52 @@ describe("bundleAssets", function(){ }); }); + it("assets should be put in [BuildOptions.dest] folder", function() { + var dest = "foo/bar"; + var root = path.join(__dirname, "bundle_assets"); + + var config = { + main: "main", + config: path.join(root, "stealconfig.js") + }; + + var options = { + quiet: true, + minify: false, + dest: dest, + bundleAssets: { + infer: true, + glob: [path.join(root, "assets", "*")] + } + }; + + return multiBuild(config, options) + .then(function() { + var logo = path.join(root, dest, "images", "logo.png"); + assert(fs.pathExistsSync(logo), "should bundle image"); + + var json = path.join(root, dest, "assets", "some.json"); + assert(fs.pathExistsSync(json), "should bundle json file"); + }) + .then(function() { + return asap(fs.readFile)( + path.join(root, dest, "bundles", "main.css") + ) + .then(function(buff) { + return buff.toString(); + }); + }) + .then(function(cssBundle) { + //url(../images/logo.png) + assert( + /url\(\.\.\/images\/logo\.png\)/.test(cssBundle), + "rewrites paths properly" + + ); + return asap(rmdir)(path.join(root, "foo")); + }); + }); + it("works with steal-tools optimize", function (done) { optimize({ main: "main", @@ -65,7 +110,7 @@ describe("bundleAssets", function(){ } }).then(function() { open("test/bundle_assets/prod-slim.html", function(browser, close){ - find(browser, "MODULE", function(module){ + find(browser, "MODULE", function(){ const logo = path.join(__dirname, "bundle_assets", "dist", "images", "logo.png"); assert(fs.pathExistsSync(logo), "image was copied"); @@ -77,5 +122,5 @@ describe("bundleAssets", function(){ }, close); }, done); }); - }) -}); \ No newline at end of file + }); +});