Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Start some unit tests for catalog controls.

  • Loading branch information...
commit 2b90aa7020407bbc1e2ef205103e9db17bbdc221 1 parent d140e5e
@JanMiksovsky authored
View
3  .gitignore
@@ -6,4 +6,5 @@ quickui.catalog.*
controlDocumentation.js
docs.js
docs.css
-tests/common/common.*
+test/unittests.js
+test/common/common.*
View
28 grunt.js
@@ -0,0 +1,28 @@
+/*
+ * Build catalog with Grunt.js.
+ * For now, this just builds unit tests.
+ */
+module.exports = function(grunt) {
+
+ grunt.loadTasks( "../quickui/grunt" );
+
+ // Project configuration.
+ grunt.initConfig({
+ coffee: {
+ test: {
+ src: "test/*.coffee",
+ dest: "test/unittests.js"
+ }
+ },
+ watch: {
+ test: {
+ files: "<config:coffee.test.src>",
+ tasks: "coffee:test"
+ }
+ }
+ });
+
+ // Default task.
+ grunt.registerTask( "default", "coffee watch" );
+
+};
View
63 test/List.coffee
@@ -0,0 +1,63 @@
+###
+List tests
+###
+
+$ ->
+
+ class SimpleItem extends Control
+ constructor: -> return Control.coffee()
+ foo: Control.property()
+ bar: Control.property()
+
+
+ test "List: map string items to content", ->
+ $list = List.create
+ items: [
+ "One"
+ "Two"
+ "Three"
+ ]
+ equal $list.items().length, 3
+ equal $list.children().length, 3
+ equal $list.children().eq(0).text(), "One"
+ equal $list.text(), "OneTwoThree"
+
+
+ test "List: mapFunction specifies string name of property getter/setter", ->
+ $list = List.create
+ itemClass: SimpleItem
+ mapFunction: "foo"
+ items: [
+ "One"
+ "Two"
+ "Three"
+ ]
+ $controls = $list.children().control()
+ equal $controls.length, 3
+ equal $controls.eq(0).foo(), "One"
+
+
+ test "List: custom mapFunction getter/setter", ->
+ $list = List.create
+ itemClass: SimpleItem
+ mapFunction: ( item ) ->
+ if item is undefined
+ {
+ foo: @foo()
+ bar: @bar()
+ }
+ else
+ @properties item
+ items: [
+ { foo: "One", bar: 1 }
+ { foo: "Two", bar: 2 }
+ { foo: "Three", bar: 3 }
+ ]
+ $controls = $list.children().control()
+ $c = $controls.eq(0)
+ equal $c.foo(), "One"
+ equal $c.bar(), 1
+ $list.isDirty true # Clear list's cache of items
+ item = $list.items()[0]
+ equal item.foo, "One"
+ equal item.bar, 1
View
0  tests/common/LoremIpsum.qui → test/common/LoremIpsum.qui
File renamed without changes
View
0  tests/common/Sandbox.qui → test/common/Sandbox.qui
File renamed without changes
View
0  tests/common/TestControl.qui → test/common/TestControl.qui
File renamed without changes
View
0  tests/common/TestDialog.qui → test/common/TestDialog.qui
File renamed without changes
View
0  tests/common/TestPage.qui → test/common/TestPage.qui
File renamed without changes
View
0  tests/common/index.html → test/common/index.html
File renamed without changes
View
0  tests/common/sandbox.html → test/common/sandbox.html
File renamed without changes
View
0  tests/popupSource.html → test/popupSource.html
File renamed without changes
View
0  tests/simpleFlexBox.html → test/simpleFlexBox.html
File renamed without changes
View
29 test/unittests.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<title>QuickUI Unit Tests</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+
+<link rel="stylesheet" type="text/css" href="http://code.jquery.com/qunit/git/qunit.css" />
+<link rel="stylesheet" type="text/css" href="../quickui.catalog/quickui.catalog.css"></script>
+
+<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
+<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
+<script type="text/javascript" src="http://quickui/release/quickui.js"></script>
+<script type="text/javascript" src="../quickui.catalog/quickui.catalog.js"></script>
+<script type="text/javascript" src="unittests.js"></script>
+
+</head>
+
+<body data-create-controls="true">
+ <h1 id="qunit-header">QuickUI Catalog Unit Tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-fixture">test markup, will be hidden</div>
+</body>
+
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.