You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/update.test.js
+93-16Lines changed: 93 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,10 @@ describe('loopback json api component update method', function () {
11
11
app.set('legacyExplorer',false);
12
12
vards=loopback.createDataSource('memory');
13
13
Post=ds.createModel('post',{
14
-
id: {type: Number,id: true},
14
+
id: {
15
+
type: Number,
16
+
id: true
17
+
},
15
18
title: String,
16
19
content: String
17
20
});
@@ -24,7 +27,7 @@ describe('loopback json api component update method', function () {
24
27
},done);
25
28
});
26
29
27
-
describe('headers',function(){
30
+
describe('Headers',function(){
28
31
it('PATCH /models/:id should have the JSON API Content-Type header set on response',function(done){
29
32
//TODO: superagent/supertest breaks when trying to use JSON API Content-Type header
30
33
//waiting on a fix
@@ -48,9 +51,10 @@ describe('loopback json api component update method', function () {
48
51
});
49
52
});
50
53
51
-
describe('status codes',function(){
54
+
describe('Status codes',function(){
52
55
it('PATCH /models/:id should return a 200 status code',function(done){
53
-
request(app).patch('/posts/1')
56
+
request(app)
57
+
.patch('/posts/1')
54
58
.send({
55
59
data: {
56
60
type: 'posts',
@@ -83,7 +87,7 @@ describe('loopback json api component update method', function () {
83
87
});
84
88
});
85
89
86
-
describe('self links',function(){
90
+
describe('Links',function(){
87
91
it('should produce resource level self links',function(done){
88
92
request(app).patch('/posts/1')
89
93
.send({
@@ -106,9 +110,10 @@ describe('loopback json api component update method', function () {
106
110
});
107
111
});
108
112
109
-
describe('Creating a resource using PATCH /models/:id',function(){
113
+
describe('Updating a resource using PATCH',function(){
110
114
it('PATCH /models/:id should return a correct JSON API response',function(done){
111
-
request(app).patch('/posts/1')
115
+
request(app)
116
+
.patch('/posts/1')
112
117
.send({
113
118
data: {
114
119
type: 'posts',
@@ -133,26 +138,80 @@ describe('loopback json api component update method', function () {
133
138
done();
134
139
});
135
140
});
141
+
142
+
it('PATCH /models/:id if property in `attributes` is not present, it should not be considered null or change from it\'s original value',function(done){
0 commit comments