Skip to content

Instantly share code, notes, and snippets.

View surajtruckx's full-sized avatar

Suraj Air surajtruckx

View GitHub Profile
@surajtruckx
surajtruckx / sql.ts
Last active May 8, 2021 12:03
Sql Provider
import { Injectable } from '@angular/core';
import { SQLite } from '@ionic-native/sqlite';
import { Platform } from 'ionic-angular';
import { isEmpty, isNull, keys, sortBy, get, parseInt } from 'lodash';
import { browserDBInstance } from './browser';
declare var window: any;
const SQL_DB_NAME = process.env.IONIC_ENV === 'dev' ? '__broswer.db' : '__native.db';
@Injectable()
export const browserDBInstance = (db) => {
return {
executeSql: (sql) => {
return new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(sql, [], (tx, rs) => {
resolve(rs)
});
});
import { IonicPage } from 'ionic-angular';
import { SqlProvider } from '../path/to/sql-provider';
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
@surajtruckx
surajtruckx / expectsaga-integration-test.js
Created February 22, 2021 09:03
Integration Test Format with expectSaga()
describe(`functionName()`, () => {
afterEach(() => {
//clean up after every `it` block
});
describe(`When …. specify the external state you want to test against`, () => {
beforeEach(() => {
// setup the external state, ex: populate db, async storage etc
});