refactor: replace hardcoded error codes with references (#7546)

This commit is contained in:
dblythy
2021-10-19 05:19:47 +11:00
committed by GitHub
parent b5fc0d59db
commit 12eb6c823b
13 changed files with 85 additions and 52 deletions

View File

@@ -75,7 +75,7 @@ describe('Cloud Code', () => {
it('is cleared cleared after the previous test', done => {
Parse.Cloud.run('hello', {}).catch(error => {
expect(error.code).toEqual(141);
expect(error.code).toEqual(Parse.Error.SCRIPT_FAILED);
done();
});
});
@@ -109,7 +109,7 @@ describe('Cloud Code', () => {
Parse.Cloud.run('cloudCodeWithError').then(
() => done.fail('should not succeed'),
e => {
expect(e).toEqual(new Parse.Error(141, 'foo is not defined'));
expect(e).toEqual(new Parse.Error(Parse.Error.SCRIPT_FAILED, 'foo is not defined'));
done();
}
);
@@ -123,7 +123,7 @@ describe('Cloud Code', () => {
Parse.Cloud.run('cloudCodeWithError').then(
() => done.fail('should not succeed'),
e => {
expect(e.code).toEqual(141);
expect(e.code).toEqual(Parse.Error.SCRIPT_FAILED);
expect(e.message).toEqual('Script failed.');
done();
}
@@ -142,7 +142,7 @@ describe('Cloud Code', () => {
const query = new Parse.Query('beforeFind');
await query.first();
} catch (e) {
expect(e.code).toBe(141);
expect(e.code).toBe(Parse.Error.SCRIPT_FAILED);
expect(e.message).toBe('throw beforeFind');
done();
}
@@ -467,7 +467,7 @@ describe('Cloud Code', () => {
});
} catch (e) {
catched = true;
expect(e.code).toBe(101);
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
}
expect(catched).toBe(true);
expect(called).toBe(7);
@@ -479,7 +479,7 @@ describe('Cloud Code', () => {
});
} catch (e) {
catched = true;
expect(e.code).toBe(101);
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
}
expect(catched).toBe(true);
expect(called).toBe(7);
@@ -491,7 +491,7 @@ describe('Cloud Code', () => {
});
} catch (e) {
catched = true;
expect(e.code).toBe(101);
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
}
expect(catched).toBe(true);
expect(called).toBe(7);
@@ -1761,7 +1761,7 @@ describe('Cloud Code', () => {
it('should set the failure message on the job error', async () => {
Parse.Cloud.job('myJobError', () => {
throw new Parse.Error(101, 'Something went wrong');
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Something went wrong');
});
const job = await Parse.Cloud.startJob('myJobError');
let jobStatus, status;
@@ -2038,7 +2038,7 @@ describe('beforeFind hooks', () => {
done();
},
err => {
expect(err.code).toBe(141);
expect(err.code).toBe(Parse.Error.SCRIPT_FAILED);
expect(err.message).toEqual('Do not run that query');
done();
}