diff --git a/__tests__/__snapshots__/topicCreate.test.native.js.snap.android b/__tests__/__snapshots__/topicCreate.test.native.js.snap.android
index 61b2838..77744a5 100644
--- a/__tests__/__snapshots__/topicCreate.test.native.js.snap.android
+++ b/__tests__/__snapshots__/topicCreate.test.native.js.snap.android
@@ -27,35 +27,15 @@ exports[` renders everything 1`] = `
}
}
>
-
+
-
-
-
+ />
renders everything 1`] = `
}
}
>
-
+
-
-
-
+ />
renders everything 1`] = `
+exports[` renders everything 1`] = `
renders everything 1`] = `
}
>
+
+
renders everything 1`] = `
}
/>
-
renders everything 1`] = `
}
}
>
- 1116717
- dias atrás
+ NaN
+ minutos atrás
@@ -171,6 +160,7 @@ exports[` renders everything 1`] = `
/>
+
renders everything 1`] = `
+
+
+
renders everything 1`] = `
+exports[` renders everything 1`] = `
renders everything 1`] = `
}
>
+
+
renders everything 1`] = `
}
/>
-
renders everything 1`] = `
}
}
>
- 1116717
- dias atrás
+ NaN
+ minutos atrás
@@ -171,6 +160,7 @@ exports[` renders everything 1`] = `
/>
+
renders everything 1`] = `
+
+
+
', () => {
.create()
.toJSON();
expect(tree).toMatchSnapshot();
- expect(wrapper.find('View').length).toBe(18);
+ expect(wrapper.find('View').length).toBe(16);
expect(wrapper.find('Text').length).toBe(10);
- expect(wrapper.find('TouchableOpacity').length).toBe(2);
+ expect(wrapper.find('TouchableOpacity').length).toBe(1);
expect(wrapper.find('Icon').length).toBe(2);
expect(wrapper.find('TextInput').length).toBe(2);
});
@@ -33,12 +33,12 @@ describe('', () => {
styles.TopicCreatemasterView
);
expect(wrapper.find('View').at(2)).toHaveStyle(styles.TopicCreateheader);
- expect(wrapper.find('View').at(8)).toHaveStyle(styles.TopicCreatecontainer);
- expect(wrapper.find('View').at(10)).toHaveStyle(styles.TopicCreateUserDiv);
- expect(wrapper.find('View').at(12)).toHaveStyle(
+ expect(wrapper.find('View').at(6)).toHaveStyle(styles.TopicCreatecontainer);
+ expect(wrapper.find('View').at(8)).toHaveStyle(styles.TopicCreateUserDiv);
+ expect(wrapper.find('View').at(10)).toHaveStyle(
styles.TopicCreatetituloDiv
);
- expect(wrapper.find('View').at(16)).toHaveStyle(
+ expect(wrapper.find('View').at(14)).toHaveStyle(
styles.TopicCreatescrollDiv
);
});
@@ -55,6 +55,9 @@ describe('', () => {
expect(wrapper.find('Text').at(8)).toHaveText('username');
});
it('renders TouchableOpacity correctly', () => {
+ expect(wrapper.find('TouchableOpacity').at(0)).toHaveStyle(
+ styles.TopicCreatepublicarDiv
+ );
expect(wrapper.find('TouchableOpacity').at(0)).toHaveProp('onPress');
});
it('renders Icon correctly', () => {
diff --git a/__tests__/topicView.test.native.js b/__tests__/topicView.test.native.js
index 3dc348f..376dbe1 100644
--- a/__tests__/topicView.test.native.js
+++ b/__tests__/topicView.test.native.js
@@ -12,7 +12,7 @@ jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
let wrapper;
-describe('', () => {
+describe('', () => {
beforeEach(() => {
wrapper = mount();
});
@@ -23,15 +23,15 @@ describe('', () => {
.toJSON();
expect(tree).toMatchSnapshot();
expect(wrapper.find('KeyboardAvoidingView').length).toBe(1);
- expect(wrapper.find('View').length).toBe(36);
+ expect(wrapper.find('View').length).toBe(38);
expect(wrapper.find('Header').length).toBe(1);
expect(wrapper.find('Image').length).toBe(2);
expect(wrapper.find('Data').length).toBe(1);
expect(wrapper.find('ScrollView').length).toBe(2);
expect(wrapper.find('Comments').length).toBe(1);
- expect(wrapper.find('Text').length).toBe(26);
- expect(wrapper.find('TouchableOpacity').length).toBe(2);
- expect(wrapper.find('Icon').length).toBe(5);
+ expect(wrapper.find('Text').length).toBe(30);
+ expect(wrapper.find('TouchableOpacity').length).toBe(1);
+ expect(wrapper.find('Icon').length).toBe(7);
});
it('renders KeyboardAvoidingView correctly', () => {
expect(wrapper.find('KeyboardAvoidingView').at(0)).toHaveStyle(
@@ -48,7 +48,7 @@ describe('', () => {
expect(wrapper.find('Image').at(0)).toHaveProp('defaultSource');
});
it('renders Data correctly', () => {
- expect(wrapper.find('Data').at(0)).toHaveProp('time');
+ expect(wrapper.find('Data').at(0)).toHaveProp('tempo');
});
it('renders ScrollView correctly', () => {
expect(wrapper.find('ScrollView').at(0)).toHaveStyle(
@@ -70,32 +70,44 @@ describe('', () => {
expect(wrapper.find('View').at(16)).toHaveStyle({ marginTop: 10 });
expect(wrapper.find('View').at(17)).toHaveStyle({ marginTop: 10 });
expect(wrapper.find('View').at(20)).toHaveStyle(styles.topicContainer);
- expect(wrapper.find('View').at(28)).toHaveStyle(styles.commentsBar);
- expect(wrapper.find('View').at(30)).toHaveStyle(styles.commentsListDiv);
- expect(wrapper.find('View').at(32)).toHaveStyle(styles.commentsList);
+ expect(wrapper.find('View').at(26)).toHaveStyle(styles.shareIcon);
+ expect(wrapper.find('View').at(30)).toHaveStyle(styles.commentsBar);
+ expect(wrapper.find('View').at(32)).toHaveStyle(styles.commentsListDiv);
+ expect(wrapper.find('View').at(34)).toHaveStyle(styles.commentsList);
});
it('renders Text correctly', () => {
expect(wrapper.find('Text').at(4)).toHaveStyle(styles.nameUser);
expect(wrapper.find('Text').at(8)).toHaveStyle(styles.topicDivTitle);
- expect(wrapper.find('Text').at(22)).toHaveStyle(styles.commentsBarText);
- expect(wrapper.find('Text').at(22)).toHaveText('Novo Comentário');
+ expect(wrapper.find('Text').at(24)).toHaveText('Compartilhar');
+ expect(wrapper.find('Text').at(24)).toHaveStyle({ fontSize: 10 });
+ expect(wrapper.find('Text').at(26)).toHaveStyle(styles.commentsBarText);
+ expect(wrapper.find('Text').at(26)).toHaveText('Novo Comentário');
});
it('renders TouchableOpacity correctly', () => {
+ expect(wrapper.find('TouchableOpacity').at(0)).toHaveStyle(
+ styles.commentsBarDiv
+ );
expect(wrapper.find('TouchableOpacity').at(0)).toHaveProp('onPress');
});
it('renders Icon correctly', () => {
- expect(wrapper.find('Icon').at(1)).toHaveProp('size', 18);
- expect(wrapper.find('Icon').at(1)).toHaveProp('color', gray.shark());
- expect(wrapper.find('Icon').at(1)).toHaveProp('onPress');
- expect(wrapper.find('Icon').at(1)).toHaveProp('name', 'arrowup');
+ expect(wrapper.find('Icon').at(2)).toHaveProp('name', 'arrowup');
expect(wrapper.find('Icon').at(2)).toHaveProp('size', 18);
expect(wrapper.find('Icon').at(2)).toHaveProp('color', gray.shark());
expect(wrapper.find('Icon').at(2)).toHaveProp('onPress');
- expect(wrapper.find('Icon').at(3)).toHaveProp('name', 'corner-up-right');
- expect(wrapper.find('Icon').at(3)).toHaveProp('size', 15);
+ expect(wrapper.find('Icon').at(3)).toHaveProp('name', 'arrowdown');
+ expect(wrapper.find('Icon').at(3)).toHaveProp('size', 18);
expect(wrapper.find('Icon').at(3)).toHaveProp('color', gray.shark());
- expect(wrapper.find('Icon').at(4)).toHaveProp('name', 'triangle-right');
- expect(wrapper.find('Icon').at(4)).toHaveProp('size', 15);
+ expect(wrapper.find('Icon').at(3)).toHaveProp('onPress');
+ expect(wrapper.find('Icon').at(4)).toHaveProp('name', 'edit');
+ expect(wrapper.find('Icon').at(4)).toHaveProp('size', 18);
expect(wrapper.find('Icon').at(4)).toHaveProp('color', gray.shark());
+ expect(wrapper.find('Icon').at(4)).toHaveProp('onPress');
+ expect(wrapper.find('Icon').at(5)).toHaveProp('name', 'corner-up-right');
+ expect(wrapper.find('Icon').at(5)).toHaveProp('size', 15);
+ expect(wrapper.find('Icon').at(5)).toHaveProp('color', gray.shark());
+ expect(wrapper.find('Icon').at(6)).toHaveStyle(styles.commentsBarIcon);
+ expect(wrapper.find('Icon').at(6)).toHaveProp('name', 'triangle-right');
+ expect(wrapper.find('Icon').at(6)).toHaveProp('size', 15);
+ expect(wrapper.find('Icon').at(6)).toHaveProp('color', gray.shark());
});
});
diff --git a/package.json b/package.json
index 4f70479..91d300e 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
- "test": "jest",
+ "test": "jest --all --no-watchman",
"coverage": "rm -rf coverage/ node_modules/.cache/ && NODE_ENV=test npx jest --collect-coverage",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
diff --git a/src/screen/forum/components/NewTopic.js b/src/screen/forum/components/NewTopic.js
index 3dfcbab..0bb0544 100644
--- a/src/screen/forum/components/NewTopic.js
+++ b/src/screen/forum/components/NewTopic.js
@@ -25,14 +25,7 @@ export default function NewTopic({ navigation, topTopic }) {
{item?.createdAt}
-
-
- {item?.comments.length}
-
+
{item?.likes.length}
diff --git a/src/screen/topic/TopicCreate.js b/src/screen/topic/TopicCreate.js
index f667f2f..7e857c0 100644
--- a/src/screen/topic/TopicCreate.js
+++ b/src/screen/topic/TopicCreate.js
@@ -34,19 +34,10 @@ export default function TopicCreate({ navigation }) {
return (
- navigation.push('PlantCard', { itemID: plantID })}
- >
-
-
- {plant?.scientificName}
-
-
+
+
+ {plant?.scientificName}
+
postTopic()}
diff --git a/src/screen/topic/TopicView.js b/src/screen/topic/TopicView.js
index 3e69445..6e4e3b6 100644
--- a/src/screen/topic/TopicView.js
+++ b/src/screen/topic/TopicView.js
@@ -27,18 +27,15 @@ import { gray, highlight } from '../../theme/colorPalette';
function Data({ time }) {
const now = new Date();
- const tmp = Math.trunc((now - time) / 1000 / 60);
+ const action = new Date(time);
+ const tmp = Math.trunc((now - action) / 1000 / 60);
if (tmp / 60 > 24) {
- return (
- {Math.trunc(tmp / 24)} dias atrás
- );
+ return {tmp / 24} dias atrás;
}
if (tmp / 3600 > 24) {
- return (
- {Math.trunc(tmp / 60)} horas atrás
- );
+ return {tmp / 24} horas atrás;
}
- return {Math.trunc(tmp)} minutos atrás;
+ return {tmp} minutos atrás;
}
export default function TopicView({ navigation }) {
@@ -48,7 +45,7 @@ export default function TopicView({ navigation }) {
const [topic, setTopic] = useState({});
const [isNewComment, setIsNewComment] = useState(true);
const [isEditing, setIsEditing] = useState(false);
- const [isEditable, setIsEditable] = useState(false);
+ const [isEditable, setIsEditable] = useState(true);
const [commentText, setCommentText] = useState('');
const [topicIsLiked, setTopicIsLiked] = useState(false);
const [topicIsNotLiked, setTopicIsNotLiked] = useState(false);
@@ -160,7 +157,7 @@ export default function TopicView({ navigation }) {
/>
{topic?.user?.username}
-
+
diff --git a/src/screen/topic/comment/Comments.js b/src/screen/topic/comment/Comments.js
index df98af2..6b7bd85 100644
--- a/src/screen/topic/comment/Comments.js
+++ b/src/screen/topic/comment/Comments.js
@@ -52,9 +52,7 @@ export default function Comments({ topic, setTopic, user, like, dislike }) {
{username}
{topicEditing !== id ? (
-
- {description}
-
+ {description}
) : (
dislike('comment', id)}
/>
- {!!(user?._id === userID) && (
+ {user?._id === userID && (
<>
-
-
+
+
+
+
{title}
-
-
+
);
}
@@ -23,11 +30,6 @@ const styles = StyleSheet.create({
alignContent: 'space-between',
paddingTop: 15,
},
- headerNav: {
- flex: 0.8,
- flexDirection: 'row',
- alignItems: 'center',
- },
publicarDiv: {
flexDirection: 'row',
alignItems: 'center',
diff --git a/src/services/endpoints/topic.js b/src/services/endpoints/topic.js
index 2287bc4..afc62bf 100644
--- a/src/services/endpoints/topic.js
+++ b/src/services/endpoints/topic.js
@@ -18,18 +18,6 @@ export const createTopic = async (topicID, topicBody) => {
});
};
-export const topTopic = () => {
- const TOPIC = ENDPOINTS.API.topic;
- return new Promise((resolve, reject) => {
- fetch(ENDPOINTS.API.base_url + TOPIC.listTop.route, {
- method: TOPIC.listTop.method,
- })
- .then((res) => res.json())
- .then(resolve)
- .catch(reject);
- });
-};
-
export const getTopic = (topicID) => {
const TOPIC = ENDPOINTS.API.topic;
return new Promise((resolve, reject) => {
diff --git a/src/settings/endpoints.js b/src/settings/endpoints.js
index 1b4f6b7..7a0895e 100644
--- a/src/settings/endpoints.js
+++ b/src/settings/endpoints.js
@@ -87,10 +87,6 @@ const ENDPOINTS = {
route: (topicID) => `/topic/find/${topicID}`,
method: 'GET',
},
- listTop: {
- route: `/topic/list`,
- method: 'GET',
- },
create: {
route: (plantID) => `/topic/create/${plantID}`,
method: 'POST',