Created
June 12, 2011 23:58
-
-
Save Wizek/1022147 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("new Entry()", function() { | |
expect(8) | |
var obj = { | |
"id": 1 | |
, "position": 0 | |
, "headline": "headline " + Math.random() | |
, "body": "body " + Math.random() | |
} | |
, html = '<li>' | |
+ '\r\n <span class="headline">'+obj.headline+'</span>' | |
+ '\r\n <p class="body">'+obj.body+'</p>' | |
+ '\r\n</li>' | |
var entry = new Entry(obj) | |
equal(entry.id, 1 | |
, 'entry returns the supplied id correctly') | |
equal(entry.position, 0 | |
, 'entry returns the supplied position correctly') | |
equal(entry.headline, obj.headline | |
, 'entry returns the supplied headline correctly') | |
equal(entry.body, obj.body | |
, 'entry returns the supplied body correctly') | |
stop() | |
new Entry().get(0, function(err, retrived) { | |
notEqual(err, null | |
, 'Root cannot be retrived, therefore this\'s an error') | |
equal(err, 'Root cannot be retrived') | |
ok(retrived.hasChildren() | |
, 'Yep, there are main titles, children of root') | |
stop() | |
retrived.children(function(children) { | |
ok(Array.isArray(children)) | |
start() | |
}) | |
start() | |
}) | |
stop() | |
new Entry().get(1, function(err, retrived) { | |
equal(err, null, 'first element') | |
equal(err, 'Root cannot be retrived') | |
equal(retrived.headline, 'First headline!') | |
ok(Array.isArray(retrived.parents), 'returns array') | |
ok(0 in retrived.parents, 'root entry (0) is in there') | |
start() | |
}) | |
entry.appendTo(0) | |
var e2 = new Entry() | |
e2.headline = "E-2!" | |
e2.appendTo(entry) | |
//stop() | |
//entry.getHtml(function(str) { | |
// equal(str, html | |
// , 'entry returns the supplied data correctly wrapped in html') | |
// start() | |
//}) | |
//equal(entry.isNew(), true | |
// , 'entry is new because it has not yet been attached to any other entry') | |
//equal(entry.attachTo(0), true | |
// , 'entry reports attachment worked') | |
//equal(entry.isNew(), false | |
// , 'entry is not new because it has been attached to an other entry') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment