-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path:w
130 lines (95 loc) · 3.55 KB
/
:w
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//=require people.js
//=require listener.js
//=require model.js
//=require view.js
//=require jquery
//=require jquery_ujs
describe('the view functions', function() {
var $person1,$showButton, editForm;
beforeEach( function () {
loadFixtures('index');
jasmine.Clock.useMock();
//Deals with Mock and animation incompatibilities
jQuery.fx.off = true;
$person1 = $('tr.person#1');
$showButton = $('tr.person#1 td.drop_down'); //for person 1
editForm = "<form> \
<label>First Name</label> \
<input class='edit_form' id='f_name' type='text' value=''></input> <br><br> \
<label>Last Name</label> \
<input class='edit_form' id='l_name' type='text' value=''></input> <br><br> \
<label>Address</label> \
<input class='edit_form' id='address' type='text' value=''></input> <br><br> \
<label>Phone Number</label> \
<input class='edit_form' id='phone_num' type='text' value=''></input> <br><br> \
<input type='submit'></input> \
</form> ";
});
describe('the first person', function() {
it('should be tr.person#1. The name is Christopher.', function() {
var $firstName = $person1.children().first().text();
expect($firstName).toBe('Christopher');
});
it('should contain td.drop_down', function () {
expect($person1).toContain($showButton);
});
});
describe('the slideNewForm function', function() {
});
describe('the insertPersonRow function', function() {
});
describe('the insertEditForm function', function() {
var searchForEditForm, $editForm, $dropDownBox, $formContainer;
beforeEach(function() {
$editForm = $(editForm);
viewMethods.insertEditForm($person1, $editForm);
jasmine.Clock.tick(1000);
$dropDownBox = $('tr.person#1n');
$formContainer = $('div.form_box');
searchForEditForm = function() {return $editForm;}
});
it('should insert new row', function() {
expect(searchForEditForm()).toBeVisible();
});
it('should have an edit form inside the div.form_box', function () {
expect($dropDownBox).toContain($editForm);
});
it('should have div.form_box inside the new tr', function() {
expect($dropDownBox).toContain($formContainer);
});
});
describe('the insertNewForm function', function() {
var findNewForm, $form;
beforeEach(function() {
viewMethods.insertNewForm();
findNewForm = function() { return $('center#new_person form');}
$form = findNewForm();
});
it('should insert a form below the New Person link', function() {
expect($form).toExist();
});
it('should listen for a submit', function() {
var submit = $form.data('events').submit[0].type;
expect(submit).toBe('submit');
});
});
describe('the updateEditForm function', function() {
var $editForm, fakePerson;
beforeEach(function() {
$editForm = $(editForm);
fakePerson = {
f_name:'Chris' ,
l_name:'Kim',
address:'Somewhere Wonderful' ,
phone_num:'(234) 242-1234'
};
viewMethods.updateEditForm($editForm, fakePerson);
});
it('should update the values of the edit form', function() {
var f_name = $editForm.find('#f_name').attr('value');
expect(f_name).toBe(fakePerson.f_name);
});
});
describe('the updatePersonRow function', function() {
});
});