Skip to content

Instantly share code, notes, and snippets.

View kianaditya's full-sized avatar

Aditya Naik kianaditya

View GitHub Profile
require 'googleauth'
require 'google/apis'
require 'google/apis/calendar_v3'
module GoogleMeetService
def self.create_google_event(event)
authorize_client
google_event = create_calendar_event(event)
updated_google_event = update_calendar_event(event,google_event)
event.update_attribute(:conference_link,updated_google_event.hangout_link)
@kianaditya
kianaditya / main.tour
Created March 28, 2023 07:47
Test scopes using jest tests
{
"$schema": "https://aka.ms/codetour-schema",
"title": "Testing scopes using jest",
"steps": [
{
"file": "src/components/MaterialStandard/materialStandard.scope.js",
"description": "We first build an array of objects, where each object contains information about setting up the test, and an assertion. \n\nAssertions included in this structure are - `inDocument`, `notInDocument`, and `calls` ( that tracks no of calls to an api)\n\nA standard structure for a \"test object\" is as follows:\n```js\n{\nname: \"<denotes name of the test that shows up when we run it>\"\ncomponent:<component under test>\nscope:<scope array takes in all the applicable scopes for testing>\nroute:<which route we should render the component with>\nassertion: <one of three assertions writtern as screen => screen ...>\nmockedRoute: <if we are asserting no of calls made to particular endpoint>\ncalls: <asserting no of calls>\n}\n```",
"line": 22,
"contents": "import React from 'react'\nimport * as materialS
{{% block normal %}}
This is a normal styled text block.
{{% /block %}}
{{% block info %}}
This is an info styled text block.
{{% /block %}}
{{% block warning %}}
This is an warning styled text block.
@kianaditya
kianaditya / websocket-testing.js
Created May 19, 2020 12:52
cypress test for websocket testing article
/// <reference types="Cypress" />
const manualWebSocket = require('manual-web-socket') // import the package
describe('Tests websocket', () => {
it('Successfully processes websocket message from server', () => {
cy.visit('/')
.get('[id=websocket]')
.should('have.text', 'websocket is closed')
cy.visit('/', {
onBeforeLoad(win) {
var script = win.document.createElement('script')
import {
Card,
Typography,
CardHeader,
Button,
Avatar,
} from '@material-ui/core'
import { makeStyles } from '@material-ui/core/styles'
const useStyles = makeStyles((theme) => ({
[
{
"userId": 1,
"id": 1,
"title": "Mocked Todo",
"completed": false
}
]
/// <reference types="Cypress" />
describe('Tests todo list', () => {
it('Checks todo render', () => {
cy.customRoute(
{
method: 'GET',
url: 'https://jsonplaceholder.typicode.com/todos',
response: 'fixture:todo.json',
},
Cypress.Commands.add('customRoute', (args, alias = 'mock') => {
cy.server()
if (Cypress.env('mock')) {
cy.route(args).as(alias)
}
})
/// <reference types="Cypress" />
describe('Tests todo list', () => {
it('Checks todo render', () => {
cy.visit('/')
cy.get('h3')
.should('have.length', 200)
.first()
.should('have.text', 'delectus aut autem')
})
@kianaditya
kianaditya / app.js
Created September 4, 2020 12:41
cypress toggle mocked routes
import React, { useState, useEffect } from 'react'
import Axios from 'axios'
const URL = 'https://jsonplaceholder.typicode.com/todos'
const App = () => {
const [todos, setTodos] = useState([])
useEffect(() => {
fetchTodos()
}, [])