Skip to content

Commit

Permalink
Updated and added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jul 23, 2013
1 parent 6ca618f commit c601dc2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
popup-message = {
label = var: 'More information';
content: Here is more information;

popup-model = module('xstyle/test/popup-model');
=>
button (label) {
on-click: popup-model/toggle();
},
div (content) {
position: absolute;
background-color: #aaa;
};
}

body {
=>
popup-message {
label: Another Popup;
content: Contents of another popup;
}
popup-message
span 'Contents with a '
a[href=somepage] 'link';
}
7 changes: 7 additions & 0 deletions test/contacts.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
define(['dojo/store/Memory', 'dojo/store/Observable', 'dbind/bind', 'dbind/navigation'], function(Memory, Observable, bind, navigation){
// create an observable memory store with our test data
contactStore = new Observable(new Memory({data:[
{id:1, firstName: 'Jimi', lastName:'Hendrix', email:'[email protected]'},
{id:2, firstName: 'Janis', lastName:'Joplin', email:'[email protected]'},
{id:3, firstName: 'Jim', lastName:'Morrison', email:'[email protected]'},
{id:4, firstName: 'Kurt', lastName:'Cobain', email:'[email protected]'},
{id:5, firstName: 'Amy', lastName:'Winehouse', email:'[email protected]'},
]}));
// create a base binding, that we can set properties on
contacts = bind({});
contacts.set('list', contactStore.query({}));
contacts.set('select', function(item){
contacts.set('selected', item);
});
contacts.set('selected', {firstName: '', lastName: '', id:''});
var firstName = contacts.get('selected').get('firstName');
firstName.receive(function(value){
firstName.set('error', value && value.length < 3 ? 'Name must be at least three characters' : '');
});
contacts.set('save', function(selected){
contactStore.put(selected);
});
var nextId = 3;
contacts.set('create', function(selected){
contacts.set('selected', {firstName:'', lastName: '', email: '', id: nextId++});
});
// add navigation support
navigation(contacts.get('selected'), {
store: contactStore
});
Expand Down
16 changes: 16 additions & 0 deletions test/content.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test-component {
=>
h1 'header' { color: red}
p (content)
};
body {
=>
test-component {
=>
div.nested 'nested'
}
test-component div.inline 'inline'
test-component {
content: 'as property';
};
}
14 changes: 14 additions & 0 deletions test/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Test Xstyle Functionality</title>
<script>
document.write('<link rel="stylesheet" href="' + location.search.slice(1) + '.css" />');
</script>
<script src="../../dojo/dojo.js" data-dojo-config="async:true, deps:['xstyle/main']"></script>
</head>
<body>

</body>
</html>
4 changes: 4 additions & 0 deletions test/tutorial.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ body {
h2 (selected/firstName + ' ' + selected/lastName),
label.start-row 'First Name:',
input[type=text] (selected/firstName),
span.error (selected/firstName/error)
label.start-row 'Last Name:',
input[type=text] (selected/lastName),
label.start-row 'Email:',
Expand All @@ -38,3 +39,6 @@ body {
h2 {
margin-top: 0;
}
.error {
color: red;
}

0 comments on commit c601dc2

Please sign in to comment.