Skip to content

Commit c601dc2

Browse files
committed
Updated and added more tests
1 parent 6ca618f commit c601dc2

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

test/component.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
popup-message = {
2+
label = var: 'More information';
3+
content: Here is more information;
4+
5+
popup-model = module('xstyle/test/popup-model');
6+
=>
7+
button (label) {
8+
on-click: popup-model/toggle();
9+
},
10+
div (content) {
11+
position: absolute;
12+
background-color: #aaa;
13+
};
14+
}
15+
16+
body {
17+
=>
18+
popup-message {
19+
label: Another Popup;
20+
content: Contents of another popup;
21+
}
22+
popup-message
23+
span 'Contents with a '
24+
a[href=somepage] 'link';
25+
}

test/contacts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
define(['dojo/store/Memory', 'dojo/store/Observable', 'dbind/bind', 'dbind/navigation'], function(Memory, Observable, bind, navigation){
2+
// create an observable memory store with our test data
23
contactStore = new Observable(new Memory({data:[
34
{id:1, firstName: 'Jimi', lastName:'Hendrix', email:'[email protected]'},
45
{id:2, firstName: 'Janis', lastName:'Joplin', email:'[email protected]'},
56
{id:3, firstName: 'Jim', lastName:'Morrison', email:'[email protected]'},
67
{id:4, firstName: 'Kurt', lastName:'Cobain', email:'[email protected]'},
78
{id:5, firstName: 'Amy', lastName:'Winehouse', email:'[email protected]'},
89
]}));
10+
// create a base binding, that we can set properties on
911
contacts = bind({});
1012
contacts.set('list', contactStore.query({}));
1113
contacts.set('select', function(item){
1214
contacts.set('selected', item);
1315
});
1416
contacts.set('selected', {firstName: '', lastName: '', id:''});
17+
var firstName = contacts.get('selected').get('firstName');
18+
firstName.receive(function(value){
19+
firstName.set('error', value && value.length < 3 ? 'Name must be at least three characters' : '');
20+
});
1521
contacts.set('save', function(selected){
1622
contactStore.put(selected);
1723
});
1824
var nextId = 3;
1925
contacts.set('create', function(selected){
2026
contacts.set('selected', {firstName:'', lastName: '', email: '', id: nextId++});
2127
});
28+
// add navigation support
2229
navigation(contacts.get('selected'), {
2330
store: contactStore
2431
});

test/content.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test-component {
2+
=>
3+
h1 'header' { color: red}
4+
p (content)
5+
};
6+
body {
7+
=>
8+
test-component {
9+
=>
10+
div.nested 'nested'
11+
}
12+
test-component div.inline 'inline'
13+
test-component {
14+
content: 'as property';
15+
};
16+
}

test/test.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE HTML>
2+
<html lang="en-US">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Test Xstyle Functionality</title>
6+
<script>
7+
document.write('<link rel="stylesheet" href="' + location.search.slice(1) + '.css" />');
8+
</script>
9+
<script src="../../dojo/dojo.js" data-dojo-config="async:true, deps:['xstyle/main']"></script>
10+
</head>
11+
<body>
12+
13+
</body>
14+
</html>

test/tutorial.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ body {
1717
h2 (selected/firstName + ' ' + selected/lastName),
1818
label.start-row 'First Name:',
1919
input[type=text] (selected/firstName),
20+
span.error (selected/firstName/error)
2021
label.start-row 'Last Name:',
2122
input[type=text] (selected/lastName),
2223
label.start-row 'Email:',
@@ -38,3 +39,6 @@ body {
3839
h2 {
3940
margin-top: 0;
4041
}
42+
.error {
43+
color: red;
44+
}

0 commit comments

Comments
 (0)