Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end-to-end-tests #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module.exports = ->
mocha_phantomjs:
all:
options:
reporter: 'node_modules/mocha/lib/reporters/spec.js'
reporter: 'spec'
urls: ['http://127.0.0.1:9999/spec/runner.html']

'saucelabs-mocha':
Expand Down
13 changes: 9 additions & 4 deletions dist/gss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* gss-engine - version 1.0.4-beta (2014-06-11) - http://gridstylesheets.org */
;(function(){

/**
Expand Down Expand Up @@ -20048,7 +20049,7 @@ GSS.Getter.prototype['readAST:text/gss'] = function(node) {

});
require.register("gss/lib/GSS.js", function(exports, require, module){
var GSS, LOG_PASS, TIME, TIME_END, key, val, _ref;
var GSS, LOG_PASS, TIME, TIME_END, key, val, _ref, _ref1;

require("customevent-polyfill");

Expand Down Expand Up @@ -20117,6 +20118,10 @@ if (typeof GSS_CONFIG !== "undefined" && GSS_CONFIG !== null) {
}
}

if (((_ref = location.search) != null ? _ref.substring(1) : void 0) === 'noworker') {
GSS.config.useWorker = false;
}

GSS.deblog = function() {
if (GSS.config.debug) {
return console.log.apply(console, arguments);
Expand Down Expand Up @@ -20178,9 +20183,9 @@ GSS.Rule = require("./gssom/Rule.js");

require("./gssom/StyleSheet.js");

_ref = require("./dom/IdMixin.js");
for (key in _ref) {
val = _ref[key];
_ref1 = require("./dom/IdMixin.js");
for (key in _ref1) {
val = _ref1[key];
if (GSS[key]) {
throw new Error("IdMixin key clash: " + key);
}
Expand Down
6 changes: 3 additions & 3 deletions dist/gss.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/worker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* gss-engine - version 1.0.4-beta (2014-06-11) - http://gridstylesheets.org */
/**
* Parts Copyright (C) 2011-2012, Alex Russell ([email protected])
* Parts Copyright (C) Copyright (C) 1998-2000 Greg J. Badros
Expand Down
2 changes: 1 addition & 1 deletion dist/worker.min.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions lib/GSS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var GSS, LOG_PASS, TIME, TIME_END, key, val, _ref;
var GSS, LOG_PASS, TIME, TIME_END, key, val, _ref, _ref1;

require("customevent-polyfill");

Expand Down Expand Up @@ -67,6 +67,10 @@ if (typeof GSS_CONFIG !== "undefined" && GSS_CONFIG !== null) {
}
}

if (((_ref = location.search) != null ? _ref.substring(1) : void 0) === 'noworker') {
GSS.config.useWorker = false;
}

GSS.deblog = function() {
if (GSS.config.debug) {
return console.log.apply(console, arguments);
Expand Down Expand Up @@ -128,9 +132,9 @@ GSS.Rule = require("./gssom/Rule.js");

require("./gssom/StyleSheet.js");

_ref = require("./dom/IdMixin.js");
for (key in _ref) {
val = _ref[key];
_ref1 = require("./dom/IdMixin.js");
for (key in _ref1) {
val = _ref1[key];
if (GSS[key]) {
throw new Error("IdMixin key clash: " + key);
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
],
"devDependencies": {
"grunt": "~0.4.1",
"chai": "~1.9.0",
"mocha": "~1.17.0",
"chai": "~1.9.1",
"mocha": "~1.20.1",
"grunt-contrib-watch": "~0.3.1",
"grunt-mocha-phantomjs": "~0.4.0",
"grunt-mocha-phantomjs": "~0.5.0",
"grunt-contrib-uglify": "~0.2.1",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-concat": "~0.3.0",
Expand Down
160 changes: 159 additions & 1 deletion spec/end-to-end.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,31 @@ describe 'End - to - End', ->
"$async1[height]": 100
"$async1[-test]": 0
done()


describe 'variable math', ->

it 'should compute values', (done) ->
container.innerHTML = """
<style type="text/gss">
[message-height] == 230;
[message-width] == 240;

[large-message-height] == [message-height] * 2;
[large-message-width] == [message-width] * 2;
</style>
"""

engine.once 'display', (e) ->
try
expect(engine.vars).to.deep.equal
"[message-height]": 230
"[message-width]": 240
"[large-message-height]": 460
"[large-message-width]": 480
done()
catch error
done error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my new branch, this one times out after 2000ms.




Expand Down Expand Up @@ -1442,4 +1467,137 @@ describe 'End - to - End', ->
margin-right: 9px;
}

###
###


describe 'implied property values', ->

it 'should compute values', (done) ->
container.innerHTML = """
<div id="header"></div>

<style type="text/gss">
@h |[#header]| in(::window);
[header-center-x] == #header[center-x];
</style>
"""

windowWidth = window.innerWidth - GSS.get.scrollbarWidth()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my new branch these all fail because GSS.get.scrollbarWidth() is undefined.


engine.once 'display', (e) ->
try
expect(engine.vars).to.deep.equal
"::window[x]": 0
"::window[width]": windowWidth
"$header[x]": 0
"$header[width]": windowWidth
"[header-center-x]": windowWidth / 2
done()
catch error
done error


describe 'chain-width', ->

it 'should compute values', (done) ->
container.innerHTML = """
<div id="platform">
<p id="platform-first-p"></p>
<p id="platform-second-p"></p>
</div>

<style type="text/gss">
[margin] == 20 !require;
[padding] == 25 !require;

[p-top] == 0 !require;
[p-width] == (#platform[width] - (([margin] + [padding]) * 2)) / 3 !require;

@h |[#platform]| in(::window);

@h [#platform-first-p]-[#platform-second-p]-|
gap([margin])
outer-gap([padding])
in(#platform)
chain-top([p-top])
chain-width([p-width]);
</style>
"""

margin = 20
padding = 25

windowLeft = 0
windowWidth = window.innerWidth - GSS.get.scrollbarWidth()

pWidth = (windowWidth - ((margin + padding) * 2)) / 3
pTop = 0
firstPLeft = windowLeft + padding + pWidth + margin
secondPLeft = firstPLeft + pWidth + margin

engine.once 'display', (e) ->
try
delta = 0.0000000000001

expect(engine.vars["[p-width]"]).to.be.closeTo pWidth, delta
expect(engine.vars["$platform-first-p[width]"]).to.be.closeTo pWidth, delta
expect(engine.vars["$platform-first-p[x]"]).to.be.closeTo firstPLeft, delta
expect(engine.vars["$platform-second-p[width]"]).to.be.closeTo pWidth, delta
expect(engine.vars["$platform-second-p[x]"]).to.be.closeTo secondPLeft, delta

delete engine.vars["[p-width]"]
delete engine.vars["$platform-first-p[width]"]
delete engine.vars["$platform-first-p[x]"]
delete engine.vars["$platform-second-p[width]"]
delete engine.vars["$platform-second-p[x]"]

expect(engine.vars).to.deep.equal
"[margin]": margin
"[padding]": padding
"[p-top]": pTop
"::window[x]": windowLeft
"::window[width]": windowWidth
"$platform[x]": windowLeft
"$platform[width]": windowWidth
"$platform-first-p[y]": pTop
"$platform-second-p[y]": pTop

done()
catch error
done error


describe 'virtuals', ->

it 'should compute values', (done) ->
container.innerHTML = """
<div id="platform"></div>

<style type="text/gss">
[padding] == 25 !require;
@h |[#platform]| in(::window);

#platform {
@virtual "platform";
@h |-["platform"]-| outer-gap([padding]) in(::);
}
</style>
"""

windowWidth = window.innerWidth - GSS.get.scrollbarWidth()
padding = 25

engine.once 'display', (e) ->
try
expect(engine.vars).to.deep.equal
"[padding]": padding
"::window[x]": 0
"::window[width]": windowWidth
"$platform[x]": 0
"$platform[width]": windowWidth
"$platform\"platform\"[x]": padding
"$platform\"platform\"[width]": windowWidth - (padding * 2)

done()
catch error
done error