Add tests to get to 100% branch coverage
This commit is contained in:
@@ -18,7 +18,7 @@ var hasAllPODobject = () => {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedResponseForHasAllPOD = {
|
var plainOldDataSchema = {
|
||||||
className: 'HasAllPOD',
|
className: 'HasAllPOD',
|
||||||
fields: {
|
fields: {
|
||||||
//Default fields
|
//Default fields
|
||||||
@@ -38,7 +38,7 @@ var expectedResponseForHasAllPOD = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedResponseforHasPointersAndRelations = {
|
var pointersAndRelationsSchema = {
|
||||||
className: 'HasPointersAndRelations',
|
className: 'HasPointersAndRelations',
|
||||||
fields: {
|
fields: {
|
||||||
//Default fields
|
//Default fields
|
||||||
@@ -91,10 +91,7 @@ describe('schemas', () => {
|
|||||||
request.get({
|
request.get({
|
||||||
url: 'http://localhost:8378/1/schemas/SomeSchema',
|
url: 'http://localhost:8378/1/schemas/SomeSchema',
|
||||||
json: true,
|
json: true,
|
||||||
headers: {
|
headers: restKeyHeaders,
|
||||||
'X-Parse-Application-Id': 'test',
|
|
||||||
'X-Parse-REST-API-Key': 'rest',
|
|
||||||
},
|
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
expect(response.statusCode).toEqual(401);
|
expect(response.statusCode).toEqual(401);
|
||||||
expect(body.error).toEqual('unauthorized');
|
expect(body.error).toEqual('unauthorized');
|
||||||
@@ -140,7 +137,7 @@ describe('schemas', () => {
|
|||||||
headers: masterKeyHeaders,
|
headers: masterKeyHeaders,
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
var expected = {
|
var expected = {
|
||||||
results: [expectedResponseForHasAllPOD,expectedResponseforHasPointersAndRelations]
|
results: [plainOldDataSchema,pointersAndRelationsSchema]
|
||||||
};
|
};
|
||||||
expect(body).toEqual(expected);
|
expect(body).toEqual(expected);
|
||||||
done();
|
done();
|
||||||
@@ -154,12 +151,9 @@ describe('schemas', () => {
|
|||||||
request.get({
|
request.get({
|
||||||
url: 'http://localhost:8378/1/schemas/HasAllPOD',
|
url: 'http://localhost:8378/1/schemas/HasAllPOD',
|
||||||
json: true,
|
json: true,
|
||||||
headers: {
|
headers: masterKeyHeaders,
|
||||||
'X-Parse-Application-Id': 'test',
|
|
||||||
'X-Parse-Master-Key': 'test',
|
|
||||||
},
|
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
expect(body).toEqual(expectedResponseForHasAllPOD);
|
expect(body).toEqual(plainOldDataSchema);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -171,10 +165,7 @@ describe('schemas', () => {
|
|||||||
request.get({
|
request.get({
|
||||||
url: 'http://localhost:8378/1/schemas/HASALLPOD',
|
url: 'http://localhost:8378/1/schemas/HASALLPOD',
|
||||||
json: true,
|
json: true,
|
||||||
headers: {
|
headers: masterKeyHeaders,
|
||||||
'X-Parse-Application-Id': 'test',
|
|
||||||
'X-Parse-Master-Key': 'test',
|
|
||||||
},
|
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
expect(response.statusCode).toEqual(400);
|
expect(response.statusCode).toEqual(400);
|
||||||
expect(body).toEqual({
|
expect(body).toEqual({
|
||||||
@@ -283,6 +274,34 @@ describe('schemas', () => {
|
|||||||
url: 'http://localhost:8378/1/schemas',
|
url: 'http://localhost:8378/1/schemas',
|
||||||
headers: masterKeyHeaders,
|
headers: masterKeyHeaders,
|
||||||
json: true,
|
json: true,
|
||||||
|
body: {
|
||||||
|
className: "NewClass",
|
||||||
|
fields: {
|
||||||
|
foo: {type: 'Number'},
|
||||||
|
ptr: {type: 'Pointer', targetClass: 'SomeClass'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, (error, response, body) => {
|
||||||
|
expect(body).toEqual({
|
||||||
|
className: 'NewClass',
|
||||||
|
fields: {
|
||||||
|
ACL: {type: 'ACL'},
|
||||||
|
createdAt: {type: 'Date'},
|
||||||
|
updatedAt: {type: 'Date'},
|
||||||
|
objectId: {type: 'String'},
|
||||||
|
foo: {type: 'Number'},
|
||||||
|
ptr: {type: 'Pointer', targetClass: 'SomeClass'},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets you specify class name in both places', done => {
|
||||||
|
request.post({
|
||||||
|
url: 'http://localhost:8378/1/schemas/NewClass',
|
||||||
|
headers: masterKeyHeaders,
|
||||||
|
json: true,
|
||||||
body: {
|
body: {
|
||||||
className: "NewClass",
|
className: "NewClass",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user