Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ const extraMenuOptions = [{

const reportIssue = (deviceInfo) => {
// your code here
}
};

return (
<Shkr
items={extraMenuOptions}
email='example@example.com'
reportIssue={(deviceInfo) => reportIssue(deviceInfo)}
/>
);
```

### Props
Expand Down
34 changes: 34 additions & 0 deletions __tests__/buildOptionsList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { buildOptionsList } from "../src/buildOptionsList";
import Icon from "react-native-vector-icons/AntDesign";

describe("getting the list of options", () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests don't make me confident that when they pass everything works fine. They are quite shallow. You can see some examples here https://github.com/th3rdwave/react-native-safe-area-context/tree/main/src/__tests__ and here https://github.com/th3rdwave/react-native-safe-area-context/tree/main/src/__tests__.

BTW, I don't see tests for the Shkr component.


it("should return default length", () => {
const options = buildOptionsList();

expect(options.length).toBe(2);
});

it("should return correct length", () => {
const handleAction = () => {
console.log("warning");
};

const items = [{
icon: <Icon name="warning" size={24} />,
title: "Report a problem",
action: handleAction,
}];

const options = buildOptionsList(items);

expect(options.length).toBe(3);
});

it("should return a list", () => {
const options = buildOptionsList();

expect(typeof options).toBe("array");
});
});

9 changes: 9 additions & 0 deletions __tests__/getDeviceInfo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import getDeviceInfo from "../src/getDeviceInfo";

describe("getting the device information", () => {
it('should return an object', () => {
const device = getDeviceInfo();

expect(typeof device).toBe('object');
})
})
3 changes: 0 additions & 3 deletions src/getDeviceInfo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import { useRoute } from '@react-navigation/native';
import DeviceInfo from "react-native-device-info";

const getDeviceInfo = () => {
const device = {};
const route = useRoute();

device.uniqueId = DeviceInfo.getUniqueId();
device.deviceId = DeviceInfo.getDeviceId();
Expand All @@ -15,7 +13,6 @@ const getDeviceInfo = () => {
device.systemVersion = DeviceInfo.getSystemVersion();
device.isTablet = DeviceInfo.isTablet();
device.appName = DeviceInfo.getApplicationName();
device.routeName = route.name;

return device;
}
Expand Down