Permalink
Browse files

test suite working

  • Loading branch information...
1 parent 6dec5ec commit 211c886591ab71db43989ce957738a1a0c405afa @amccollum committed Sep 17, 2011
Showing with 3,043 additions and 5,553 deletions.
  1. +5 −0 .npmignore
  2. +4 −1 Cakefile
  3. +2 −4 package.json
  4. +0 −2 src/test/_post.html
  5. +2 −2 src/test/{_pre.html → index.html}
  6. +1 −1 src/test/package.json
  7. +61 −17 src/test/selectors.coffee
  8. +2,902 −2,618 src/test/template.html
  9. +66 −0 src/test/vows.css
  10. +0 −2,884 test/index.html
  11. +0 −4 test/package.json
  12. +0 −20 test/selectors.js
View
@@ -0,0 +1,5 @@
+.git*
+node_modules/
+examples/
+src/
+test/
View
@@ -21,9 +21,12 @@ task 'build', 'Build the library', ->
task 'test', 'Build the test suite', ->
execCmds [
+ 'rm -rf test',
'coffee --compile --bare --output test src/test/*.coffee',
- 'cat src/test/_pre.html src/test/template.html src/test/_post.html > test/index.html',
+ 'cp src/test/index.html test',
+ 'cp src/test/template.html test',
+ 'cp src/test/vows.css test',
'cp src/test/package.json test',
'pushd test',
View
@@ -1,6 +1,6 @@
{
"name": "sel",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Tiny, but full-featured selector library",
"keywords": ["ender", "css", "selector", "jquery"],
"author": "Andrew McCollum <amccollum@gmail.com>",
@@ -11,9 +11,7 @@
"main": "lib/sel.js",
"ender": "lib/ender.js",
"directories": {
- "lib": "lib",
- "src": "src",
- "test": "test"
+ "lib": "lib"
},
"dependencies": {
View
@@ -1,2 +0,0 @@
-</body>
-</html>
@@ -4,7 +4,7 @@
<meta charset="utf-8" />
<!-- Stylesheet -->
- <link rel="stylesheet" href="css/vows.css" />
+ <link rel="stylesheet" href="vows.css" />
<!-- Ender -->
<script src="ender.js" type="text/javascript" charset="utf-8"></script>
@@ -15,4 +15,4 @@
</head>
<body>
<!-- Test Results -->
- <pre class="results"></pre>
+ <pre id="vows-results"></pre>
View
@@ -1,4 +1,4 @@
{
"private": true,
- "name": "sel-test",
+ "name": "sel-test"
}
View
@@ -2,24 +2,68 @@ assert = require('assert')
vows = require('vows')
sel = require('sel')
-selectors = [
- 'body', 'div', 'body div', 'div p', 'div > p', 'div + p', 'div ~ p',
- 'div[class^=exa][class$=mple]', 'div p a', 'div, p, a', '.note',
- 'div.example', 'ul .tocline2', 'div.example, div.note', '#title',
- 'h1#title', 'div #title', 'ul.toc li.tocline2', 'ul.toc > li.tocline2',
- 'h1#title + div > p', 'h1[id]:contains(Selectors)', 'a[href][lang][class]',
- 'div[class]', 'div[class=example]', 'div[class^=exa]', 'div[class$=mple]',
- 'div[class*=e]', 'div[class|=dialog]', 'div[class!=made_up]',
- 'div[class~=example]', 'div:not(.example)', 'p:contains(selectors)',
- 'p:nth-child(even)', 'p:nth-child(2n)', 'p:nth-child(odd)', 'p:nth-child(2n+1)',
- 'p:nth-child(n)', 'p:only-child', 'p:last-child', 'p:first-child'
-]
+selectors = {
+ 'body': 1,
+ 'body div': 51,
+ 'div': 51,
+ 'div p': 140,
+ 'div > p': 134,
+ 'div + p': 22,
+ 'div ~ p': 183,
+ 'div p a': 12,
+ 'div, p, a': 671,
+ '.note': 14,
+ 'div.example': 43,
+ 'div.example, div.note': 44,
+ 'div #title': 1,
+ 'h1#title': 1,
+ 'h1#title + div > p': 0,
+ '#title': 1,
+ 'ul .tocline2': 12,
+ 'ul.toc > li.tocline2': 12,
+ 'ul.toc li.tocline2': 12,
+ 'a[href][lang][class]': 1,
+ 'div[class!=made_up]': 51,
+ 'div[class$=mple]': 43,
+ 'div[class*=e]': 50,
+ 'div[class=example]': 43,
+ 'div[class]': 51,
+ 'div[class^=exa]': 43,
+ 'div[class^=exa][class$=mple]': 43,
+ 'div[class|=dialog]': 0,
+ 'div[class~=example]': 43,
+ 'div:not(.example)': 8,
+ 'h1[id]:contains(Selectors)': 1,
+ 'p:contains(selectors)': 54,
+ 'p:first-child': 54,
+ 'p:last-child': 19,
+ 'p:nth-child(2n)': 158,
+ 'p:nth-child(2n+1)': 166,
+ 'p:nth-child(even)': 158,
+ 'p:nth-child(n)': 324,
+ 'p:nth-child(odd)': 166,
+ 'p:only-child': 3,
+}
tests = {}
-for selector in selectors
- tests[selector] = ($) -> $(selector)
+for s, num of selectors
+ do (s, num) ->
+ tests[s] = ($, root) -> assert.equal $(s, root).length, num
vows.add 'Slickspeed Selectors',
- 'sel:':
- topic: () -> sel.sel
- '': tests
+
+ 'sel:':
+ topic: () ->
+ el = document.createElement('iframe')
+ el.src = 'template.html'
+ el.style.width = 0
+ el.style.height = 0
+ el.style.display = 'none'
+ el.style.visibility = 'hidden'
+ el.onload = () =>
+ @success(sel.sel, el.contentDocument)
+
+ document.body.appendChild(el)
+ return
+
+ '': tests
Oops, something went wrong.

0 comments on commit 211c886

Please sign in to comment.