forked from bitovi/jquerypp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqunit.js
More file actions
107 lines (67 loc) · 2.07 KB
/
qunit.js
File metadata and controls
107 lines (67 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
steal('funcunit/qunit')
.then("jquerypp/model/backup").then(function(){
module("jquerypp/model/backup",{
setup : function(){
$.Model.extend("Recipe")
}
})
test("backing up", function(){
var recipe = new Recipe({name: "cheese"});
ok(!recipe.isDirty(), "not backedup, but clean")
recipe.backup();
ok(!recipe.isDirty(), "backedup, but clean");
recipe.attr('name', 'blah')
ok(recipe.isDirty(), "dirty");
recipe.restore();
ok(!recipe.isDirty(), "restored, clean");
equals(recipe.name, "cheese" ,"name back");
});
test("backup / restore with associations", function(){
$.Model("Instruction");
$.Model("Cookbook");
$.Model("Recipe",{
attributes : {
instructions : "Instruction.models",
cookbook: "Cookbook.model"
}
},{});
var recipe = new Recipe({
name: "cheese burger",
instructions : [
{
description: "heat meat"
},
{
description: "add cheese"
}
],
cookbook: {
title : "Justin's Grillin Times"
}
});
//test basic is dirty
ok(!recipe.isDirty(), "not backedup, but clean")
recipe.backup();
ok(!recipe.isDirty(), "backedup, but clean");
recipe.attr('name','blah')
ok(recipe.isDirty(), "dirty");
recipe.restore();
ok(!recipe.isDirty(), "restored, clean");
equals(recipe.name, "cheese burger" ,"name back");
// test belongs too
ok(!recipe.cookbook.isDirty(), "cookbook not backedup, but clean");
recipe.cookbook.backup();
recipe.cookbook.attr("title","Brian's Burgers");
ok(!recipe.isDirty(), "recipe itself is clean");
ok(recipe.isDirty(true), "recipe is dirty if checking associations");
recipe.cookbook.restore()
ok(!recipe.isDirty(true), "recipe is now clean with checking associations");
equals(recipe.cookbook.title, "Justin's Grillin Times" ,"cookbook title back");
//try belongs to recursive restore
recipe.cookbook.attr("title","Brian's Burgers");
recipe.restore();
ok(recipe.isDirty(true), "recipe is dirty if checking associations, after a restore");
recipe.restore(true);
ok(!recipe.isDirty(true), "cleaned all of recipe and its associations");
})
})