Skip to content

Commit

Permalink
Add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bchiang7 committed Jan 24, 2020
1 parent 08c79a1 commit 58c92fe
Show file tree
Hide file tree
Showing 9 changed files with 1,766 additions and 61 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
13 changes: 13 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": ["@upstatement", "plugin:jest/recommended"],
"plugins": ["jest"],
"parserOptions": {
"sourceType": "module"
},
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
}
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const { mockFirebase } = require('./mocks/firebase');
module.exports = {
mockFirebase,
FakeFirestore,
FakeAuth
};
FakeAuth,
};
4 changes: 2 additions & 2 deletions mocks/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FakeAuth {
const { uid, ...data } = this.currentUser;
return { uid, data };
}
};
}

module.exports = {
FakeAuth,
Expand All @@ -49,4 +49,4 @@ module.exports = {
mockSendVerificationEmail,
mockSignInWithEmailAndPassword,
mockVerifyIdToken,
};
};
21 changes: 11 additions & 10 deletions mocks/firebase.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
const mockInitializeApp = jest.fn();
const mockCert = jest.fn();

const firebaseStub = (overrides) => {
const firebaseStub = overrides => {
const { FakeFirestore, FakeAuth } = require('firestore-jest-mock');
return {
initializeApp: mockInitializeApp,

credential: {
cert: mockCert,
},

auth() {
return new FakeAuth(overrides.currentUser);
},

firestore() {
return new FakeFirestore(overrides.database);
}
}
},
};
};

const mockFirebase = (overrides= {}) => {
jest.mock('firebase', () => firebaseStub(overrides)) && jest.mock('firebase-admin', () => firebaseStub(overrides));
const mockFirebase = (overrides = {}) => {
jest.mock('firebase', () => firebaseStub(overrides)) &&
jest.mock('firebase-admin', () => firebaseStub(overrides));
};

module.exports = {
firebaseStub,
mockFirebase,
mockInitializeApp,
mockCert
};
mockCert,
};
6 changes: 3 additions & 3 deletions mocks/firestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function buildQuerySnapShot(requestedRecords) {
docs,
forEach(callback) {
return docs.forEach(callback);
}
},
};
}

Expand Down Expand Up @@ -161,7 +161,7 @@ class FakeFirestore {
mockLimit(...arguments);
return this;
}
};
}

module.exports = {
FakeFirestore,
Expand All @@ -180,5 +180,5 @@ module.exports = {
mockBatchDelete,
mockBatchCommit,
mockBatchUpdate,
mockBatchSet
mockBatchSet,
};
Loading

0 comments on commit 58c92fe

Please sign in to comment.