A self-test for testing stylus

This commit is contained in:
Slava Kim
2015-06-24 20:27:57 -07:00
parent 120209e0af
commit a2a8013032
15 changed files with 166 additions and 0 deletions

View File

@@ -0,0 +1 @@
local

View File

@@ -0,0 +1 @@
1da9lx3m24vwv1kt1w0a

View File

@@ -0,0 +1,8 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-platform
my-package
stylus

View File

@@ -0,0 +1,2 @@
browser
server

View File

@@ -0,0 +1 @@
none

View File

@@ -0,0 +1,53 @@
autoupdate@1.2.2
base64@1.0.3
binary-heap@1.0.3
blaze@2.1.2
blaze-tools@1.0.3
boilerplate-generator@1.0.3
callback-hook@1.0.3
check@1.0.5
compiler-plugin@1.0.0
ddp@1.2.0
ddp-client@1.2.0
ddp-common@1.2.0
ddp-server@1.2.0
deps@1.0.7
ejson@1.0.6
fastclick@1.0.6
geojson-utils@1.0.3
html-tools@1.0.4
htmljs@1.0.4
http@1.1.0
id-map@1.0.3
jquery@1.11.3_2
json@1.0.3
launch-screen@1.0.3
livedata@1.0.13
logging@1.0.8
meteor@1.1.6
meteor-platform@1.2.2
minifiers@1.1.5
minimongo@1.0.8
mobile-status-bar@1.0.4
mongo@1.1.0
my-package@0.0.0
npm-mongo@1.4.32_1
observe-sequence@1.0.6
ordered-dict@1.0.3
random@1.0.3
reactive-dict@1.1.0
reactive-var@1.0.5
reload@1.1.3
retry@1.0.3
routepolicy@1.0.5
session@1.1.0
spacebars@1.0.6
spacebars-compiler@1.0.6
stylus@2.0.0_511
templating@1.1.1
tracker@1.0.7
ui@1.0.6
underscore@1.0.3
url@1.0.4
webapp@1.2.1
webapp-hashing@1.0.3

View File

@@ -0,0 +1,8 @@
<body>
<div class="package-level">package-level</div>
<div class="package-level-local-export">package-level-local-export</div>
<div class="package-level-imported-to-app">package-level-imported-to-app</div>
<div class="app-level">app-level</div>
<div class="app-level-export">app-level-export</div>
</body>

View File

@@ -0,0 +1,4 @@
.app-level-export {
background-color: aqua
}

View File

@@ -0,0 +1,7 @@
@import '{my-package}/package-export.styl'
@import '{}/client/app-export.styl'
.app-level {
background-color: chocolate
}

View File

@@ -0,0 +1,26 @@
if (Meteor.isClient) {
Meteor.startup(function () {
var classes = ['app-level', 'app-level-export', 'package-level', 'package-level-local-export', 'package-level-imported-to-app'];
var colors = ['chocolate', 'cyan', 'salmon', 'red', 'blue'];
for (var i in classes) {
var selector = '.' + classes[i];
Meteor.call('print', getComputedStyle(document.querySelector(selector))['background-color'] === colorToRGBString(colors[i]));
}
});
function colorToRGBString(color) {
d = document.createElement("div");
d.style.color = color;
document.body.appendChild(d);
var str = getComputedStyle(d).color;
document.body.removeChild(d);
return str;
}
} else {
Meteor.methods({
print: function (str) {
console.log(str);
}
});
}

View File

@@ -0,0 +1,4 @@
.package-level-imported-to-app {
background-color: blue
}

View File

@@ -0,0 +1,6 @@
.package-level {
background-color: salmon
}
@import 'package-local-export.styl'

View File

@@ -0,0 +1,4 @@
.package-level-local-export {
background-color: red
}

View File

@@ -0,0 +1,11 @@
Package.describe({
summary: "test local package for using stylus"
});
Package.onUse(function (api) {
api.addFiles('package-file.main.styl', 'client');
api.addFiles('package-local-export.styl', 'client');
api.addFiles('package-export.styl', 'client');
api.use('stylus');
});

View File

@@ -0,0 +1,30 @@
var selftest = require('../selftest.js');
var Sandbox = selftest.Sandbox;
var utils = require('../utils.js');
selftest.define("can import stylus across packages", function (options) {
var s = new Sandbox({
clients: options.clients
});
s.createApp("myapp", "app-using-stylus");
s.cd("myapp");
s.testWithAllClients(function (run) {
run.match("myapp");
run.match("proxy");
run.match("MongoDB");
run.match("running at");
run.match("localhost");
run.connectClient();
run.waitSecs(40);
run.match("true");
run.match("true");
run.match("true");
run.match("true");
run.match("true");
run.stop();
});
});