Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Increase coverage #7654

Open
wants to merge 25 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9ef1968
ci: fix node engine check (#7891)
mtrezza Mar 25, 2022
f63fb2b
fix: return correct response when revert is used in beforeSave (#7839)
dblythy Mar 26, 2022
b3199d7
chore(release): 5.2.1-alpha.1 [skip ci]
semantic-release-bot Mar 26, 2022
48bd512
perf: reduce database operations when using the constant parameter in…
dblythy Mar 26, 2022
e0cca58
chore(release): 5.2.1-alpha.2 [skip ci]
semantic-release-bot Mar 26, 2022
90155cf
feat: add MongoDB 5.1 compatibility (#7682)
github-actions[bot] Mar 27, 2022
499cead
chore(release): 5.3.0-alpha.1 [skip ci]
semantic-release-bot Mar 27, 2022
ef56e98
fix: security upgrade parse push adapter from 4.1.0 to 4.1.2 (#7893)
mtrezza Mar 27, 2022
119dbe0
chore(release): 5.3.0-alpha.2 [skip ci]
semantic-release-bot Mar 27, 2022
6b4b358
feat: add MongoDB 5.2 support (#7894)
mtrezza Mar 27, 2022
75eca2d
chore(release): 5.3.0-alpha.3 [skip ci]
semantic-release-bot Mar 27, 2022
61ef23f
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy May 3, 2022
606ed96
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy May 5, 2022
1e89817
Merge branch 'alpha' of https://github.com/dblythy/parse-server into …
dblythy Jun 7, 2022
9720e8e
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Jun 7, 2022
7bc5c36
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Jun 17, 2022
7b2ab38
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Jun 18, 2022
3c8f5cc
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Sep 18, 2022
5814437
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Sep 29, 2022
986c6c2
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Nov 3, 2022
6a40dc4
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Nov 10, 2022
a9fb355
Merge remote-tracking branch 'upstream/alpha' into alpha
dblythy Dec 20, 2022
acccf2d
increase coverage
dblythy Oct 26, 2021
b40585a
Update CloudCode.spec.js
dblythy Oct 26, 2021
4d3bf0f
revert
dblythy Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions spec/CLI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('execution', () => {
}
});

it('shoud start Parse Server', done => {
it('should start Parse Server', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
Expand All @@ -241,7 +241,16 @@ describe('execution', () => {
});
});

it('shoud start Parse Server with GraphQL', done => {
it('should throw without masterKey and appId', done => {
childProcess = spawn(binPath, []);
childProcess.stderr.on('data', data => {
if (data.toString().includes('ERROR: appId and masterKey are required')) {
done();
}
});
});

it('should start Parse Server with GraphQL', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
Expand All @@ -267,7 +276,7 @@ describe('execution', () => {
});
});

it('shoud start Parse Server with GraphQL and Playground', done => {
it('should start Parse Server with GraphQL and Playground', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
Expand All @@ -294,4 +303,28 @@ describe('execution', () => {
done.fail(data.toString());
});
});

it('should redact push keys', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
'--masterKey',
'test',
'--databaseURI',
'mongodb://localhost/test',
'--port',
'1341',
'--push',
'123',
]);
childProcess.stdout.on('data', data => {
data = data.toString();
if (data.includes('**REDACTED**')) {
done();
}
});
childProcess.stderr.on('data', data => {
done.fail(data.toString());
});
});
});
20 changes: 20 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const mockAdapter = {
};

describe('Cloud Code', () => {
it('can cannot load invalid cloud code', async () => {
await expectAsync(
reconfigureServer({
cloud: true,
})
).toBeRejectedWith("argument 'cloud' must either be a string or a function");
});

it('can load absolute cloud code file', done => {
reconfigureServer({
cloud: __dirname + '/cloud/cloudCodeRelativeFile.js',
Expand All @@ -39,6 +47,18 @@ describe('Cloud Code', () => {
});
});

it('can load cloud code as a function', async () => {
await reconfigureServer({
cloud: () => {
Parse.Cloud.define('hellofunction', () => {
return 'Hello world function!';
});
},
});
const result = await Parse.Cloud.run('hellofunction');
expect(result).toBe('Hello world function!');
});

it('can create functions', done => {
Parse.Cloud.define('hello', () => {
return 'Hello world!';
Expand Down
22 changes: 22 additions & 0 deletions spec/MessageQueue.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const ParseMessageQueue = require('../lib/ParseMessageQueue').ParseMessageQueue;
describe('message queue', () => {
it('cannot create message quue with an invalid adapter', function () {
expect(() =>
ParseMessageQueue.createPublisher({
messageQueueAdapter: {
createPublisher: 'a',
createSubscriber: () => {},
},
})
).toThrow('pubSubAdapter should have createPublisher()');

expect(() =>
ParseMessageQueue.createSubscriber({
messageQueueAdapter: {
createPublisher: () => {},
createSubscriber: 'a',
},
})
).toThrow('messageQueueAdapter should have createSubscriber()');
});
});
8 changes: 8 additions & 0 deletions spec/PagesRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ describe('Pages Router', () => {
expect(response.status).toBe(403);
}
});

it('can create new page', () => {
const page = new Page({ id: 'testId', defaultFile: './defaultFile' });
page.id = 'newId';
page.defaultFile = 'newDefaultFile';
expect(page._id).toBe('newId');
expect(page._defaultFile).toBe('newDefaultFile');
});
});

describe('AJAX requests', () => {
Expand Down
7 changes: 7 additions & 0 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,13 @@ describe('miscellaneous', function () {
}
);
});
it('test TestUtils', () => {
delete process.env.TESTING;
expect(() => TestUtils.destroyAllDataPermanently()).toThrow(
'Only supported in test environment'
);
process.env.TESTING = true;
});
});

describe_only_db('mongo')('legacy _acl', () => {
Expand Down
19 changes: 19 additions & 0 deletions spec/ParsePubSub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ describe('ParsePubSub', function () {
expect(EventEmitterPubSub.createPublisher).not.toHaveBeenCalled();
});

it('cannot create publisher/sub with an invalid adapter', function () {
expect(() =>
ParsePubSub.createPublisher({
pubSubAdapter: {
createPublisher: 'a',
createSubscriber: () => {},
},
})
).toThrow('pubSubAdapter should have createPublisher()');
expect(() =>
ParsePubSub.createSubscriber({
pubSubAdapter: {
createPublisher: () => {},
createSubscriber: 'a',
},
})
).toThrow('pubSubAdapter should have createSubscriber()');
});

it('can create publisher/sub with custom function adapter', function () {
const adapter = {
createPublisher: jasmine.createSpy('createPublisher'),
Expand Down
2 changes: 0 additions & 2 deletions src/cli/parse-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ runner({
console.error('');
process.exit(1);
}

if (options['liveQuery.classNames']) {
options.liveQuery = options.liveQuery || {};
options.liveQuery.classNames = options['liveQuery.classNames'];
Expand All @@ -55,7 +54,6 @@ runner({
options.liveQuery.redisOptions = options['liveQuery.redisOptions'];
delete options['liveQuery.redisOptions'];
}

if (options.cluster) {
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
if (cluster.isMaster) {
Expand Down
8 changes: 1 addition & 7 deletions src/cli/utils/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ function logStartupOptions(options) {
value = '***REDACTED***';
}
if (typeof value === 'object') {
try {
value = JSON.stringify(value);
} catch (e) {
if (value && value.constructor && value.constructor.name) {
value = value.constructor.name;
}
}
value = JSON.stringify(value);
}
/* eslint-disable no-console */
console.log(`${key}: ${value}`);
Expand Down