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
#include <napi.h> | |
Napi::String SayHi(const Napi::CallbackInfo& info) { | |
Napi::Env env = info.Env(); | |
return Napi::String::New(env, "Hi!"); | |
} | |
Napi::Object init(Napi::Env env, Napi::Object exports) { | |
exports.Set(Napi::String::New(env, "sayHi"), Napi::Function::New(env, SayHi)); |
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
{ | |
pages { | |
edges { | |
node { | |
id | |
title | |
date | |
author { | |
username | |
} |
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 React, { Component } from 'react'; | |
import { bindActionCreators } from 'redux'; | |
import { connect } from 'react-redux'; | |
import { fetchPeople } from './peopleActions'; | |
import PeopleList from './components/PeopleList'; | |
import Loader from '../common/loader'; | |
class People extends Component { |
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 loadingReducer = (state = false, action) => { | |
switch (action.type) { | |
case 'FETCH_PEOPLE_HAS_STARTED': | |
return true; | |
case 'FETCH_PEOPLE_HAS_FINISHED': | |
return false; | |
default: | |
return state; | |
} | |
} |
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 { | |
FETCH_PEOPLE_HAS_FINISHED, | |
} from './peopleActions'; | |
const peopleReducer = (state = [], action) => { | |
switch (action.type) { | |
case FETCH_PEOPLE_HAS_FINISHED: | |
return action.data; | |
default: | |
return state; |
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
export const FETCH_PEOPLE_HAS_STARTED = 'FETCH_PEOPLE_HAS_STARTED'; | |
export const FETCH_PEOPLE_HAS_FINISHED = 'FETCH_PEOPLE_HAS_FINISHED'; | |
const listOfPeople = [ | |
{ | |
id: 1, | |
name: 'Max', | |
age: 21, | |
}, { | |
id: 2, |
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 { createStore, applyMiddleware, combineReducers } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import peopleReducer from '../people/peopleReducer'; | |
import loadingReducer from './loadingReducer'; | |
const reducers = combineReducers({ | |
people: peopleReducer, | |
loading: loadingReducer, | |
}); |
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
// ... | |
"when user is not authenticated get sign in intent" { | |
val authenticator = Mockito.mock(Authenticator::class.java) | |
`when`(authenticator.isAuthenticated()).thenReturn(false) | |
val context = Mockito.mock(Context::class.java) | |
val authUI = Mockito.mock(AuthUIWrapper::class.java) | |
val generator = ActionIntentGenerator(context, authUI) | |
val generatorSpy = Mockito.spy(generator) |
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
// ... | |
"ItemViewModel should insert data in the item repository" { | |
val repository = Mockito.mock(ItemRepository::class.java) | |
val item = Item(...properties...) // replace by actual properties | |
val itemFactory = Mockito.mock(ItemFactory::class.java) | |
`when`(itemFactory.build(...properties..)).thenReturn(item) // replace by actual properties | |
val transformedItem = // do whatever transformation you expect the test subject to do | |
// the test subject is the itemViewModel |
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 MainActivity : AppCompatActivity(), KoinComponent { | |
private val itemViewModel by inject<ItemViewModel>() | |
private val itemAdapter by inject<ItemAdapter>() | |
private val authViewModel by inject<AuthViewModel>() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setUpAddButtonBehavior() |