Skip to content

Instantly share code, notes, and snippets.

/* CameraTester.js */
import { RNCamera } from 'react-native-camera';
function CameraTester({ type }) {
const handleDetectedFaces = ({ faces }) => {
return /* test succeeded */;
};
const handleDetectionError = error => {
@NilsonLima
NilsonLima / Circle.js
Last active May 7, 2021 14:54
TouchTester
/* Circle.js */
import { View } from 'react-native';
function Circle({ style, radius, color }) {
return (
<View
style={[
{
width: radius * 2,
@NilsonLima
NilsonLima / BatteryManager.js
Last active May 7, 2021 12:59
BatteryTester (getting battery health using native modules and DeviceInfo)
/* BatteryManager.js */
import { NativeModules } from 'react-native';
const { BatteryManagerModule } = NativeModules;
const BatteryManager = {
getHealth: BatteryManagerModule.getHealth,
}
class Smartphone::Contract::Cancel < BaseInteraction
def call
return unless valid_interaction?
if can_cancel_certificate?
return if local_certificate_canceled.success?
enqueue_cancel_remote_job
end
persist_model!
nofity_user
end
class Smartphone::Contract::ChangeDevice < BaseInteraction
def call
return unless valid_interaction?
persist_models!
return unless changed_certificate.success?
check_imei_async
notify_user
end
def valid_interaction?
class Smartphone::Contract::Change < BaseInteraction
def call
return unless valid_interaction?
persist_models!
change_certificate
end
def valid_interaction?
not_suspended?
&& invoices_settled?
require "test_helper"
class Smartphone::Contract::CancelTest < ActiveSupport::TestCase
setup do
@smartphone_contract = smartphone_contracts(:base_contract)
@params = { id: @smartphone_contract[:id], ... }
end
subject { Smartphone::Contract::Cancel }
require "test_helper"
class Smartphone::Contract::ChangeDeviceTest < ActiveSupport::TestCase
setup do
@smartphone_contract = smartphone_contracts(:base_contract)
@params = { id: @smartphone_contract[:id], imei: '...', imei_secondary: '...', ... }
end
subject { Smartphone::Contract::ChangeDevice }
require "test_helper"
class Smartphone::Contract::ChangeTest < ActiveSupport::TestCase
setup do
@smartphone_contract = smartphone_contracts(:base_contract)
@params = { id: @smartphone_contract[:id], ... }
end
subject { Smartphone::Contract::Change }