This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { mockFirebase } = require('firestore-jest-mock'); | |
mockFirebase({ | |
database: { | |
users: [ | |
{ id: 'abc123', first: 'Bob', last: 'builder', born: 1998 }, | |
{ id: '123abc', first: 'Blues', last: 'builder', born: 1996 } | |
], | |
cities: [ | |
{ id: 'LA', name: 'Los Angeles', state: 'CA', country: 'USA' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FakeFirestore { | |
collection(name) { | |
this.currentCollection = name; | |
return this; | |
} | |
where() { | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firebase = require('firebase'); | |
function getCurrentEventsByStateForAdmins(state) { | |
const db = firebase.firestore(); | |
db.collection('events') | |
.orderBy('expirationDate', 'asc') | |
.where('expirationDate', '>', new Date().toISOString()) | |
.where('state', '==', state) | |
.where('isAdmin', '==', true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firebase = require('firebase'); | |
const db = firebase.firestore(); | |
db.collection("users").add({ | |
first: "Ada", | |
last: "Lovelace", | |
born: 1815 | |
}) | |
.then(function(docRef) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jest.mock('firebase', () => ({ | |
firestore: jest.fn().mockReturnValue({ | |
collection: jest.fn().mockReturnValue({ | |
add: jest.fn().mockResolvedValue({ | |
id: 'abc123' | |
}) | |
}) | |
}) | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { api, throttle } from '@/utils'; | |
const actions = { | |
setEvents({ commit }, payload) { | |
throttle(function* () { | |
const { zip, radius } = payload; | |
yield api.get('/events/general') | |
.then(response => commit('SET_GENERAL_EVENTS', response.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import store from '@/store'; | |
/** | |
* A simple class we create just for tracking our running functions | |
*/ | |
class Concurrency { | |
get(key) { | |
return this[key] || {}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* genFunction() { | |
yield 'Hi there!'; | |
yield 'Is this working?'; | |
yield 'Bye 👋'; | |
}; | |
const ourMethod = genFunction(); | |
ourMethod.next(); | |
// {value: "Hi there!", done: false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const actions = { | |
setEvents({ commit }, payload) { | |
const { zip, radius } = payload; | |
api.get('/events/general') | |
.then(response => commit('SET_GENERAL_EVENTS', response.data) | |
.catch(catchError); | |
api.get(`/events/zip/${zip}`, { params: { radius } }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace upstatement\jobsboard\migrations; | |
use upstatement\jobsboard\Jobsboard; | |
use Craft; | |
use craft\config\DbConfig; | |
use craft\db\Migration; |