Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
filipenevola committed Dec 7, 2023
1 parent 3468562 commit 6247463
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
22 changes: 11 additions & 11 deletions collections.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';

import { getSettings } from "meteor/quave:settings";
import { getSettings } from 'meteor/quave:settings';

// to load helpers
import "./helpers";
import './helpers';
// to load attachSchema
import "./schema";
import './schema';

const PACKAGE_NAME = "quave:collections";
const PACKAGE_NAME = 'quave:collections';
const settings = getSettings({ packageName: PACKAGE_NAME });

const { isServerOnly, isVerbose } = settings;
Expand All @@ -23,7 +23,7 @@ const compose = (...funcs) =>
(a, b) =>
(...args) =>
a(b(...args)),
(arg) => arg,
(arg) => arg
);

const getDbCollection = ({ name, helpers, instance, options }) => {
Expand Down Expand Up @@ -54,12 +54,12 @@ export const createCollection = ({

if (!name && !instance) {
throw new Error(
"The option 'name' is required, unless you are using the option 'instance' that is not your case :).",
"The option 'name' is required, unless you are using the option 'instance' that is not your case :)."
);
}
if (Meteor.isClient && isServerOnly) {
throw new Error(
"Collections are not allowed in the client, you can disable this changing the setting `isServerOnly`",
'Collections are not allowed in the client, you can disable this changing the setting `isServerOnly`'
);
}
const dbCollection = getDbCollection({
Expand All @@ -82,9 +82,9 @@ export const createCollection = ({
} catch (e) {
console.error(
`An error has happened when your collection${
name ? ` "${name}"` : ""
name ? ` "${name}"` : ''
} was being created.`,
e,
e
);
throw e;
}
Expand Down
30 changes: 15 additions & 15 deletions helpers-test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { Mongo } from "meteor/mongo";
import { Mongo } from 'meteor/mongo';

const options = { _suppressSameNameError: true };
Tinytest.addAsync("works", async function (test) {
Tinytest.addAsync('works', async function (test) {
const Books = new Mongo.Collection(`books`, options);
const Authors = new Mongo.Collection(`authors`, options);

const author1 = await Authors.insertAsync({
firstName: "Charles",
lastName: "Darwin",
firstName: 'Charles',
lastName: 'Darwin',
});

const author2 = await Authors.insertAsync({
firstName: "Carl",
lastName: "Sagan",
firstName: 'Carl',
lastName: 'Sagan',
});

const book1 = await Books.insertAsync({
authorId: author1,
name: "On the Origin of Species",
name: 'On the Origin of Species',
});

const book2 = await Books.insertAsync({
authorId: author2,
name: "Contact",
name: 'Contact',
});

Books.helpers({
Expand All @@ -33,7 +33,7 @@ Tinytest.addAsync("works", async function (test) {

// We should be able to apply more if we wish
Books.helpers({
foo: "bar",
foo: 'bar',
});

Authors.helpers({
Expand All @@ -48,26 +48,26 @@ Tinytest.addAsync("works", async function (test) {
const bookFirst = await Books.findOneAsync(book1);
const authorFirst = await bookFirst?.author();

test.equal(authorFirst?.firstName, "Charles");
test.equal(bookFirst?.foo, "bar");
test.equal(authorFirst?.firstName, 'Charles');
test.equal(bookFirst?.foo, 'bar');

const bookSecond = await Books.findOneAsync(book2);
const authorSecond = await bookSecond?.author();
test.equal(authorSecond?.fullName(), "Carl Sagan");
test.equal(authorSecond?.fullName(), 'Carl Sagan');

const authorThird = await Authors.findOneAsync(author1);
const booksThird = await authorThird?.books();
test.equal(await booksThird?.countAsync(), 1);
});

Tinytest.addAsync(
"throw error if transform function already exists",
'throw error if transform function already exists',
async function (test) {
const Author = function (doc) {
return Object.assign(this, doc);
};

Author.prototype.fullName = "Charles Darwin";
Author.prototype.fullName = 'Charles Darwin';

const Authors = new Mongo.Collection(`authors`, {
...options,
Expand All @@ -83,5 +83,5 @@ Tinytest.addAsync(
},
});
});
},
}
);
2 changes: 1 addition & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Mongo.Collection.prototype.helpers = function (helpers) {

if (self._transform && !self._helpers) {
throw new Meteor.Error(
`Can't apply helpers to '${self._name}' a transform function already exists!`,
`Can't apply helpers to '${self._name}' a transform function already exists!`
);
}

Expand Down
13 changes: 4 additions & 9 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Npm.depends({
'lodash.isobject': '3.0.2',
});

Package.onUse(function(api) {
Package.onUse(function (api) {
api.versionsFrom('[email protected]');

api.use([
'[email protected]||0.16.8-alpha300.18',
'[email protected]||2.0.0||2.0.0-alpha300.17',
'[email protected]||2.0.0-alpha300.18',
'[email protected]||1.1.4-alpha300.18'
'[email protected]||1.1.4-alpha300.18',
]);
api.imply('mongo');

Expand All @@ -30,13 +30,8 @@ Package.onUse(function(api) {
api.mainModule('collections.js');
});

Package.onTest(function(api) {
api.use([
'ecmascript',
'tinytest',
'insecure',
'autopublish',
'mongo']);
Package.onTest(function (api) {
api.use(['ecmascript', 'tinytest', 'insecure', 'autopublish', 'mongo']);

api.addFiles(['helpers.js', 'helpers-test.js']);
});

0 comments on commit 6247463

Please sign in to comment.