| Server IP : 46.62.235.243 / Your IP : 216.73.216.217 Web Server : Apache/2.4.58 (Ubuntu) System : Linux Linkabili3Dicembre 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/linkabili/node_modules/cssify/test/ |
Upload File : |
"use strict";
var fs = require("fs");
var path = require("path")
var assert = require("assert");
var concatStream = require("concat-stream");
var browserify = require("browserify");
var jsdom = require("jsdom").jsdom;
var cssify = require("..");
var pageHtml = fs.readFileSync(fixturePath("index.html"), "utf8");
var bundleStream = browserify()
.transform(cssify)
.add(fixturePath("entry.js"))
.require('..', {expose: 'cssify'})
.bundle();
specify("It gives the desired output", function (done) {
bundleStream.pipe(concatStream(function (bundleJs) {
var window = jsdom(pageHtml).createWindow();
var c1 = colors(window);
assert.equal(c1.bg, '')
assert.equal(c1.fg, '')
var scriptEl = window.document.createElement("script");
scriptEl.textContent = bundleJs;
window.document.head.appendChild(scriptEl);
var c2 = colors(window);
assert.equal(c2.bg, 'purple')
assert.equal(c2.fg, 'yellow')
done();
}));
});
function fixturePath(fileName) {
return path.resolve(__dirname, "fixtures/basic", fileName);
}
function colors (win) {
var style = win.getComputedStyle(win.document.body);
return {
bg: style.backgroundColor.replace(/\s+/g, ''),
fg: style.color.replace(/\s+/g, '')
};
}