);
}
@@ -77,21 +66,25 @@ let fetchProfile;
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
const realFetchWithCustomTimeout = fetchUtil.fetchWithCustomTimeout;
beforeEach(() => {
+
fetchCards = [];
fetchProfile = {};
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
if (url.startsWith('/contact/cards?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
- } else if (url.startsWith('/contact/cards/000a/profile?agent')) {
+ }
+ else if (url.startsWith('/contact/cards/000a/profile?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchProfile),
+ json: () => Promise.resolve(fetchProfile)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -115,30 +108,21 @@ test('add, update and remove contact', async () => {
expect(cardContext).not.toBe(null);
});
- fetchCards = [
- {
- id: '000a',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
await act(async () => {
cardContext.actions.setToken('abc123');
@@ -150,30 +134,21 @@ test('add, update and remove contact', async () => {
expect(screen.getByTestId('cardid-000a').textContent).toBe('tester');
});
- fetchCards = [
- {
- id: '000a',
- revision: 2,
- data: {
- detailRevision: 2,
- profileRevision: 4,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- },
- },
- ];
+ fetchCards = [{
+ id: '000a',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ profileRevision: 4,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ }
+ }];
- fetchProfile = {
- guid: '01ab23',
- handle: 'test1',
- name: 'tested',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- };
+ fetchProfile = { guid: '01ab23', handle: 'test1', name: 'tested', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' };
await act(async () => {
cardContext.actions.setRevision(2);
@@ -183,12 +158,10 @@ test('add, update and remove contact', async () => {
expect(screen.getByTestId('cardid-000a').textContent).toBe('tested');
});
- fetchCards = [
- {
- id: '000a',
- revision: 3,
- },
- ];
+ fetchCards = [{
+ id: '000a',
+ revision: 3,
+ }];
await act(async () => {
cardContext.actions.setRevision(3);
@@ -197,4 +170,8 @@ test('add, update and remove contact', async () => {
await waitFor(async () => {
expect(screen.getByTestId('cards').children).toHaveLength(0);
});
+
});
+
+
+
diff --git a/net/web/test/Conversation.test.tsx b/net/web/test/Conversation.test.tsx
index df65698b..e4b53f3b 100644
--- a/net/web/test/Conversation.test.tsx
+++ b/net/web/test/Conversation.test.tsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useContext } from 'react';
-import { prettyDOM } from '@testing-library/dom';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import { prettyDOM } from '@testing-library/dom'
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { CardContextProvider, CardContext } from 'context/CardContext';
import { ChannelContextProvider, ChannelContext } from 'context/ChannelContext';
import { ConversationContextProvider, ConversationContext } from 'context/ConversationContext';
@@ -22,30 +22,22 @@ function ConversationView() {
conversationContext = conversation;
useEffect(() => {
- const rendered = [];
+ const rendered = []
const entries = Array.from(conversation.state.topics.values());
- entries.forEach((entry) => {
+ entries.forEach(entry => {
rendered.push(
-
);
});
setTopics(rendered);
setRenderCount(renderCount + 1);
- }, [conversation.state]);
+ }, [conversation.state])
return (
//@ts-ignore
-
- {topics}
+
+ { topics }
);
}
@@ -59,7 +51,7 @@ function ConversationTestApp() {
- );
+ )
}
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
@@ -78,6 +70,7 @@ let fetchTopics;
let statusTopic;
let fetchTopic;
beforeEach(() => {
+
statusCards = 200;
fetchCards = [];
statusChannels = 200;
@@ -92,6 +85,7 @@ beforeEach(() => {
beginSet = false;
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
const params = url.split('/');
if (params[2]?.startsWith('channels?agent')) {
return Promise.resolve({
@@ -99,25 +93,29 @@ beforeEach(() => {
status: statusChannels,
json: () => Promise.resolve(fetchChannels),
});
- } else if (params[4]?.startsWith('channels?contact')) {
+ }
+ else if (params[4]?.startsWith('channels?contact')) {
return Promise.resolve({
url: 'getCardChannels',
status: statusCardChannels,
json: () => Promise.resolve(fetchCardChannels),
});
- } else if (params[2]?.split('?')[0] === 'cards') {
+ }
+ else if (params[2]?.split('?')[0] === 'cards') {
return Promise.resolve({
url: 'getCards',
status: statusCards,
json: () => Promise.resolve(fetchCards),
});
- } else if (params[4] === 'topics') {
+ }
+ else if (params[4] === 'topics') {
return Promise.resolve({
url: 'getTopic',
status: statusTopic,
json: () => Promise.resolve(fetchTopic),
});
- } else if (params[6]?.split('?')[0] === 'topics' || params[4]?.split('?')[0] === 'topics') {
+ }
+ else if (params[6]?.split('?')[0] === 'topics' || params[4]?.split('?')[0] === 'topics') {
if (url.endsWith('end=48')) {
endSet = true;
}
@@ -133,7 +131,8 @@ beforeEach(() => {
headers: headers,
json: () => Promise.resolve(fetchTopics),
});
- } else {
+ }
+ else {
return Promise.resolve({
url: 'endpoint',
status: 200,
@@ -141,6 +140,7 @@ beforeEach(() => {
json: () => Promise.resolve({}),
});
}
+
});
//@ts-ignore
fetchUtil.fetchWithTimeout = mockFetch;
@@ -155,7 +155,8 @@ afterEach(() => {
fetchUtil.fetchWithCustomTimeout = realFetchWithCustomTimeout;
});
-test('add, update, and remove topic', async () => {
+test('add, update, and remove topic', async() => {
+
render(
);
await waitFor(async () => {
@@ -170,53 +171,38 @@ test('add, update, and remove topic', async () => {
});
fetchChannels = [
- {
- id: '123',
- revision: 2,
- data: {
+ { id: '123', revision: 2, data: {
detailRevision: 3,
topicRevision: 5,
channelSummary: { guid: '11', dataType: 'superbasictopic', data: 'testdata' },
channelDetail: { dataType: 'superbasic', data: 'testdata' },
- },
+ }
},
];
- fetchCards = [
- {
- id: '000a',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchCardChannels = [
- {
- id: 'aabb',
- revision: 2,
- data: {
+ { id: 'aabb', revision: 2, data: {
detailRevision: 3,
topicRevision: 5,
channelSummary: { guid: '11', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
@@ -226,23 +212,20 @@ test('add, update, and remove topic', async () => {
});
fetchTopics = [
- {
- id: '888',
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- topicDetail: {
- guid: '0123',
- dataType: 'topictype',
- data: 'contacttopicdata',
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ { id: '888', revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ topicDetail: {
+ guid: '0123',
+ dataType: 'topictype',
+ data: 'contacttopicdata',
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- },
+ }
+ }
];
await act(async () => {
@@ -255,23 +238,20 @@ test('add, update, and remove topic', async () => {
});
fetchTopics = [
- {
- id: '888',
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- topicDetail: {
- guid: '0123',
- dataType: 'topictype',
- data: 'agenttopicdata',
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ { id: '888', revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ topicDetail: {
+ guid: '0123',
+ dataType: 'topictype',
+ data: 'agenttopicdata',
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- },
+ }
+ }
];
await act(async () => {
@@ -284,31 +264,22 @@ test('add, update, and remove topic', async () => {
});
fetchChannels = [
- {
- id: '123',
- revision: 2,
- data: {
+ { id: '123', revision: 2, data: {
detailRevision: 3,
topicRevision: 6,
- },
+ }
},
];
fetchTopics = [
- {
- id: '888',
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- },
- },
+ { id: '888', revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ }
+ }
];
- fetchTopic = {
- id: '888',
- revision: 5,
- data: {
+ fetchTopic = { id: '888', revision: 5, data: {
detailRevision: 4,
tagRevision: 0,
topicDetail: {
@@ -320,7 +291,7 @@ test('add, update, and remove topic', async () => {
status: 'confirmed',
transform: 'complete',
},
- },
+ }
};
await act(async () => {
@@ -333,25 +304,19 @@ test('add, update, and remove topic', async () => {
});
fetchChannels = [
- {
- id: '123',
- revision: 3,
- data: {
+ { id: '123', revision: 3, data: {
detailRevision: 3,
topicRevision: 7,
- },
+ }
},
];
fetchTopics = [
- {
- id: '888',
- revision: 6,
- data: {
- detailRevision: 4,
- tagRevision: 0,
- },
- },
+ { id: '888', revision: 6, data: {
+ detailRevision: 4,
+ tagRevision: 0,
+ }
+ }
];
await act(async () => {
@@ -364,17 +329,16 @@ test('add, update, and remove topic', async () => {
});
fetchChannels = [
- {
- id: '123',
- revision: 2,
- data: {
+ { id: '123', revision: 2, data: {
detailRevision: 3,
topicRevision: 8,
- },
+ }
},
];
- fetchTopics = [{ id: '888', revision: 6 }];
+ fetchTopics = [
+ { id: '888', revision: 6 }
+ ];
await act(async () => {
channelContext.actions.setRevision(4);
@@ -384,13 +348,16 @@ test('add, update, and remove topic', async () => {
expect(screen.getByTestId('topics').children).toHaveLength(0);
});
+
act(() => {
cardContext.actions.clearToken();
channelContext.actions.clearToken();
});
+
});
-test('load more', async () => {
+test('load more', async() => {
+
render(
);
await waitFor(async () => {
@@ -404,41 +371,29 @@ test('load more', async () => {
channelContext.actions.setToken('abc123');
});
- fetchCards = [
- {
- id: '000a',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchCardChannels = [
- {
- id: 'aabb',
- revision: 2,
- data: {
+ { id: 'aabb', revision: 2, data: {
detailRevision: 3,
topicRevision: 5,
channelSummary: { guid: '11', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
@@ -449,24 +404,20 @@ test('load more', async () => {
fetchTopics = [];
for (let i = 0; i < 32; i++) {
- fetchTopics.push({
- id: i.toString(),
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- topicDetail: {
- guid: '0123',
- dataType: 'topictype',
- data: 'contacttopicdata',
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ fetchTopics.push({ id: i.toString(), revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ topicDetail: {
+ guid: '0123',
+ dataType: 'topictype',
+ data: 'contacttopicdata',
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- });
- }
+ }});
+ }
await act(async () => {
await conversationContext.actions.setChannel('000a', 'aabb');
@@ -480,24 +431,20 @@ test('load more', async () => {
fetchTopics = [];
for (let i = 100; i < 111; i++) {
- fetchTopics.push({
- id: i.toString(),
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- topicDetail: {
- guid: '0123',
- dataType: 'topictype',
- data: 'contacttopicdata',
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ fetchTopics.push({ id: i.toString(), revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ topicDetail: {
+ guid: '0123',
+ dataType: 'topictype',
+ data: 'contacttopicdata',
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- });
- }
+ }});
+ }
await act(async () => {
await conversationContext.actions.loadMore();
@@ -509,31 +456,26 @@ test('load more', async () => {
expect(screen.getByTestId('topics').children).toHaveLength(43);
});
- fetchCards = [
- {
- id: '000a',
- revision: 2,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 7,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 7,
+ notifiedView: 7,
},
- ];
+ }];
fetchCardChannels = [
- {
- id: 'aabb',
- revision: 2,
- data: {
+ { id: 'aabb', revision: 2, data: {
detailRevision: 3,
topicRevision: 6,
channelSummary: { guid: '11', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
@@ -545,25 +487,19 @@ test('load more', async () => {
expect(beginSet).toBe(true);
});
- fetchTopics = [
- {
- id: 300,
- revision: 5,
- data: {
- detailRevision: 3,
- tagRevision: 0,
- topicDetail: {
- guid: '0123',
- dataType: 'topictype',
- data: 'contacttopicdata',
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
- },
+ fetchTopics = [{ id: 300, revision: 5, data: {
+ detailRevision: 3,
+ tagRevision: 0,
+ topicDetail: {
+ guid: '0123',
+ dataType: 'topictype',
+ data: 'contacttopicdata',
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- ];
+ }}];
await act(async () => {
conversationContext.actions.resync();
@@ -580,4 +516,6 @@ test('load more', async () => {
await waitFor(async () => {
expect(screen.getByTestId('topics').children).toHaveLength(0);
});
+
});
+
diff --git a/net/web/test/Info.test.tsx b/net/web/test/Info.test.tsx
index 918135a4..d0fdd282 100644
--- a/net/web/test/Info.test.tsx
+++ b/net/web/test/Info.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { AppContextProvider } from 'context/AppContext';
import { AccountContextProvider } from 'context/AccountContext';
import { ProfileContext, ProfileContextProvider } from 'context/ProfileContext';
@@ -25,12 +25,7 @@ function InfoView() {
return (
//@ts-ignore
-
- {state.title}
-
+
{ state.title }
);
}
@@ -69,14 +64,15 @@ beforeEach(() => {
fetchDetail = {};
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
if (url.startsWith('/contact/cards?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
}
if (url.startsWith('https://test.org/content/channels?contact')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchChannels),
+ json: () => Promise.resolve(fetchChannels)
});
}
if (url.startsWith('https://test.org/content/channels/channel01/topics?contact')) {
@@ -92,11 +88,12 @@ beforeEach(() => {
}
if (url.startsWith('https://test.org/content/channels/channel01/detail')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchDetail),
+ json: () => Promise.resolve(fetchDetail)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -114,6 +111,7 @@ afterEach(() => {
});
test('conversation selection', async () => {
+
render(
);
await waitFor(async () => {
@@ -126,62 +124,46 @@ test('conversation selection', async () => {
conversation.actions.setChannel('card01', 'channel01');
});
- fetchCards = [
- {
- id: 'card01',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: 'guid01',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: 'card01',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: 'guid01', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchChannels = [
- {
- id: 'channel01',
- revision: 2,
- data: {
+ { id: 'channel01', revision: 2, data: {
detailRevision: 3,
topicRevision: 5,
channelSummary: { guid: 'guid01', dataType: 'superbasictopic', data: JSON.stringify({ text: 'testing' }) },
- channelDetail: { dataType: 'superbasic', data: '{}' },
- },
+ channelDetail: { dataType: 'superbasic', data: '{}', },
+ }
},
];
fetchTopics = [
- {
- id: 'topic01',
- revision: 1,
- data: {
- detailRevision: 1,
- tagRevision: 1,
- topicDetail: {
- guid: 'guid01',
- dataType: 'superbasictopic',
- data: JSON.stringify({ text: 'message' }),
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ { id: 'topic01', revision: 1, data: {
+ detailRevision: 1,
+ tagRevision: 1,
+ topicDetail: {
+ guid: 'guid01',
+ dataType: 'superbasictopic',
+ data: JSON.stringify({ text: 'message' }),
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- },
+ }},
];
await act(async () => {
@@ -191,50 +173,41 @@ test('conversation selection', async () => {
await waitFor(async () => {
expect(screen.getByTestId('info').textContent).toBe('');
- });
+ });
- fetchCards = [
- {
- id: 'card01',
- revision: 2,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 7,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: 'guid01',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: 'card01',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 7,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: 'guid01', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchChannels = [
- {
- id: 'channel01',
- revision: 3,
- data: {
+ { id: 'channel01', revision: 3, data: {
detailRevision: 4,
topicRevision: 5,
- },
+ }
},
];
- (fetchDetail = { dataType: 'superbasic', data: JSON.stringify({ subject: 'testing' }) }),
- await act(async () => {
- card.actions.setRevision(2);
- });
+ fetchDetail = { dataType: 'superbasic', data: JSON.stringify({ subject: 'testing' }), },
+
+ await act(async () => {
+ card.actions.setRevision(2);
+ });
await waitFor(async () => {
expect(screen.getByTestId('info').textContent).toBe('testing');
- });
+ });
+
});
+
diff --git a/net/web/test/Listing.test.tsx b/net/web/test/Listing.test.tsx
index c3959d40..b1a890e5 100644
--- a/net/web/test/Listing.test.tsx
+++ b/net/web/test/Listing.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { ProfileContextProvider } from 'context/ProfileContext';
import { SettingsContextProvider } from 'context/SettingsContext';
import { useListing } from 'session/listing/useListing.hook';
@@ -13,20 +13,13 @@ function ListingView() {
listing = actions;
useEffect(() => {
+
const rendered = [];
- state.contacts.forEach((item) => {
+ state.contacts.forEach(item => {
rendered.push(
-
-
- {item.name}
-
-
,
+
+ { item.name }
+
);
});
setContacts(rendered);
@@ -35,11 +28,8 @@ function ListingView() {
return (
//@ts-ignore
-
- {contacts}
+
+ { contacts }
);
}
@@ -61,8 +51,9 @@ beforeEach(() => {
fetchListing = [];
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
return Promise.resolve({
- json: () => Promise.resolve(fetchListing),
+ json: () => Promise.resolve(fetchListing)
});
});
//@ts-ignore
@@ -105,4 +96,8 @@ test('retrieve listing', async () => {
await waitFor(async () => {
expect(screen.getByTestId('contact-abc123').textContent).toBe('mr. tester');
});
+
});
+
+
+
diff --git a/net/web/test/Person.test.tsx b/net/web/test/Person.test.tsx
index 8eb2f855..f05fa9c6 100644
--- a/net/web/test/Person.test.tsx
+++ b/net/web/test/Person.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { CardContext, CardContextProvider } from 'context/CardContext';
import { SettingsContextProvider } from 'context/SettingsContext';
import { useContact } from 'session/contact/useContact.hook';
@@ -26,8 +26,8 @@ function ContactView() {
return (
//@ts-ignore
-
{name}
-
{status}
+
{ name }
+
{ status }
);
}
@@ -53,21 +53,25 @@ beforeEach(() => {
fetchProfile = {};
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
if (url.startsWith('/contact/cards?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
- } else if (url.startsWith('/contact/cards/000a/profile?agent')) {
+ }
+ else if (url.startsWith('/contact/cards/000a/profile?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchProfile),
+ json: () => Promise.resolve(fetchProfile)
});
- } else if (url.startsWith('/contact/cards/000a/detail?agent')) {
+ }
+ else if (url.startsWith('/contact/cards/000a/detail?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchDetail),
+ json: () => Promise.resolve(fetchDetail)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -85,6 +89,7 @@ afterEach(() => {
});
test('update contact name', async () => {
+
render(
);
await waitFor(async () => {
@@ -92,30 +97,21 @@ test('update contact name', async () => {
expect(contactHook).not.toBe(null);
});
- fetchCards = [
- {
- id: '000a',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
await act(async () => {
cardContext.actions.setToken('abc123');
@@ -127,95 +123,83 @@ test('update contact name', async () => {
expect(screen.getByTestId('status').textContent).toBe('connected');
});
- fetchCards = [
- {
- id: '000a',
- revision: 2,
- data: {
- detailRevision: 2,
- profileRevision: 4,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ profileRevision: 4,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
},
- ];
+ }];
- (fetchProfile = {
- guid: '01ab23',
- handle: 'test1',
- name: 'tested',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- }),
- await act(async () => {
- cardContext.actions.setRevision(2);
- });
+ fetchProfile = { guid: '01ab23', handle: 'test1', name: 'tested', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
+
+ await act(async () => {
+ cardContext.actions.setRevision(2);
+ });
await waitFor(async () => {
expect(screen.getByTestId('name').textContent).toBe('tested');
expect(screen.getByTestId('status').textContent).toBe('connected');
});
- fetchCards = [
- {
- id: '000a',
- revision: 2,
- data: {
- detailRevision: 3,
- profileRevision: 4,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 2,
+ data: {
+ detailRevision: 3,
+ profileRevision: 4,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
},
- ];
+ }];
- (fetchDetail = { status: 'confirmed', statusUpdate: 137 }),
- await act(async () => {
- cardContext.actions.setRevision(3);
- });
+ fetchDetail = { status: 'confirmed', statusUpdate: 137 },
+
+ await act(async () => {
+ cardContext.actions.setRevision(3);
+ });
await waitFor(async () => {
expect(screen.getByTestId('name').textContent).toBe('tested');
expect(screen.getByTestId('status').textContent).toBe('connected');
});
- fetchCards = [
- {
- id: '000a',
- revision: 3,
- data: {
- detailRevision: 3,
- profileRevision: 4,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 3,
+ data: {
+ detailRevision: 3,
+ profileRevision: 4,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
},
- ];
+ }];
- (fetchDetail = { status: 'confirmed', statusUpdate: 137 }),
- await act(async () => {
- cardContext.actions.setRevision(4);
- });
+ fetchDetail = { status: 'confirmed', statusUpdate: 137 },
+
+ await act(async () => {
+ cardContext.actions.setRevision(4);
+ });
await waitFor(async () => {
expect(screen.getByTestId('name').textContent).toBe('tested');
expect(screen.getByTestId('status').textContent).toBe('confirmed');
});
- fetchCards = [
- {
- id: '000a',
- revision: 4,
- },
- ];
+ fetchCards = [{
+ id: '000a',
+ revision: 4,
+ }];
await act(async () => {
cardContext.actions.setRevision(5);
@@ -225,4 +209,7 @@ test('update contact name', async () => {
expect(screen.getByTestId('name').textContent).toBe('');
expect(screen.getByTestId('status').textContent).toBe('');
});
+
+
});
+
diff --git a/net/web/test/Profile.test.tsx b/net/web/test/Profile.test.tsx
index e506ead3..3f3fedea 100644
--- a/net/web/test/Profile.test.tsx
+++ b/net/web/test/Profile.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { ProfileContextProvider, ProfileContext } from 'context/ProfileContext';
import * as fetchUtil from 'api/fetchUtil';
@@ -15,17 +15,17 @@ function ProfileView() {
return (
- {renderCount}
- {profile.state.identity?.guid}
- {profile.state.identity?.handle}
- {profile.state.identity?.name}
- {profile.state.identity?.description}
- {profile.state.identity?.location}
- {profile.state.identity?.image}
- {profile.state.identity?.revision}
- {profile.state.identity?.seal}
- {profile.state.identity?.version}
- {profile.state.identity?.node}
+ { renderCount }
+ { profile.state.identity?.guid }
+ { profile.state.identity?.handle }
+ { profile.state.identity?.name }
+ { profile.state.identity?.description }
+ { profile.state.identity?.location }
+ { profile.state.identity?.image }
+ { profile.state.identity?.revision }
+ { profile.state.identity?.seal }
+ { profile.state.identity?.version }
+ { profile.state.identity?.node }
);
}
@@ -35,12 +35,12 @@ function ProfileTestApp() {
- );
+ )
}
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
const realFetchWithCustomTimeout = fetchUtil.fetchWithCustomTimeout;
-let identity = {};
+let identity = { };
beforeEach(() => {
const mockFetch = jest.fn().mockImplementation((url, options) => {
@@ -48,7 +48,7 @@ beforeEach(() => {
identity = JSON.parse(options.body);
}
return Promise.resolve({
- json: () => Promise.resolve(identity),
+ json: () => Promise.resolve(identity)
});
});
//@ts-ignore
@@ -72,7 +72,7 @@ test('testing profile sync', async () => {
});
await waitFor(async () => {
- expect(screen.getByTestId('name').textContent).toBe('');
+ expect(screen.getByTestId('name').textContent).toBe("");
});
await act(async () => {
@@ -82,8 +82,8 @@ test('testing profile sync', async () => {
});
await waitFor(async () => {
- expect(screen.getByTestId('name').textContent).toBe('jester');
- });
+ expect(screen.getByTestId('name').textContent).toBe("jester");
+ });
await act(async () => {
identity = { name: 'tester' };
@@ -91,8 +91,8 @@ test('testing profile sync', async () => {
});
await waitFor(async () => {
- expect(screen.getByTestId('name').textContent).toBe('tester');
- });
+ expect(screen.getByTestId('name').textContent).toBe("tester");
+ });
const count = screen.getByTestId('count').textContent;
@@ -110,4 +110,8 @@ test('testing profile sync', async () => {
await act(async () => {
await profileContext.actions.clearToken();
});
+
});
+
+
+
diff --git a/net/web/test/Session.test.tsx b/net/web/test/Session.test.tsx
index 711a8562..9d672e68 100644
--- a/net/web/test/Session.test.tsx
+++ b/net/web/test/Session.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { AppContextProvider } from 'context/AppContext';
import { AccountContextProvider } from 'context/AccountContext';
import { ProfileContextProvider } from 'context/ProfileContext';
@@ -14,15 +14,9 @@ import * as fetchUtil from 'api/fetchUtil';
let navPath;
jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
- useNavigate: () => {
- return (path) => {
- navPath = path;
- };
- },
- useLocation: () => {
- return 'path';
- },
+ ...jest.requireActual('react-router-dom'),
+ useNavigate: () => { return (path) => { navPath = path } },
+ useLocation: () => { return 'path' },
}));
let cardContext;
@@ -33,7 +27,7 @@ function SessionView() {
const store = useContext(StoreContext);
cardContext = card;
storeContext = store;
- return
{state.cardUpdated.toString()}
;
+ return (
{ state.cardUpdated.toString() }
);
}
function SessionTestApp() {
@@ -70,11 +64,12 @@ beforeEach(() => {
const mockFetch = jest.fn().mockImplementation((url, options) => {
if (url === '/contact/cards?agent=123') {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -92,15 +87,14 @@ afterEach(() => {
});
test('card update indicator', async () => {
- render(
);
+ render(
);
- await waitFor(async () => {
- expect(cardContext).not.toBe(null);
- expect(storeContext).not.toBe(null);
- });
+ await waitFor(async () => {
+ expect(cardContext).not.toBe(null);
+ expect(storeContext).not.toBe(null);
+ });
- fetchCards = [
- {
+ fetchCards = [{
id: '000a',
revision: 1,
data: {
@@ -110,35 +104,30 @@ test('card update indicator', async () => {
notifiedArticle: 5,
notifiedChannel: 6,
notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdated: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
+ cardDetail: { status: 'connected', statusUpdated: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- },
- ];
+ }];
- await act(async () => {
- cardContext.actions.setToken('123');
- storeContext.actions.setValue('cards:updated', 133);
- cardContext.actions.setRevision(1);
- });
+ await act(async () => {
+ cardContext.actions.setToken('123');
+ storeContext.actions.setValue('cards:updated', 133);
+ cardContext.actions.setRevision(1);
+ });
- await waitFor(async () => {
- expect(screen.getByTestId('updated').textContent).toBe('true');
- });
+ await waitFor(async () => {
+ expect(screen.getByTestId('updated').textContent).toBe('true');
+ });
- await act(async () => {
- storeContext.actions.setValue('cards:updated', 136);
- });
+ await act(async () => {
+ storeContext.actions.setValue('cards:updated', 136);
+ });
- await waitFor(async () => {
- expect(screen.getByTestId('updated').textContent).toBe('false');
- });
+ await waitFor(async () => {
+ expect(screen.getByTestId('updated').textContent).toBe('false');
+ });
});
+
+
+
diff --git a/net/web/test/Store.test.tsx b/net/web/test/Store.test.tsx
index 7cbbee39..bbaf0f06 100644
--- a/net/web/test/Store.test.tsx
+++ b/net/web/test/Store.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { StoreContext, StoreContextProvider } from 'context/StoreContext';
@@ -15,8 +15,8 @@ function StoreView() {
return (
- {renderCount}
- {store.state.config}
+ { renderCount }
+ { store.state.config }
);
}
@@ -63,4 +63,8 @@ test('get, set and clear', async () => {
await waitFor(async () => {
expect(screen.getByTestId('config').textContent).toBe('');
});
+
});
+
+
+
diff --git a/net/web/test/Thread.test.tsx b/net/web/test/Thread.test.tsx
index 5f67b793..79b2188d 100644
--- a/net/web/test/Thread.test.tsx
+++ b/net/web/test/Thread.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { AppContextProvider } from 'context/AppContext';
import { AccountContextProvider } from 'context/AccountContext';
import { ProfileContext, ProfileContextProvider } from 'context/ProfileContext';
@@ -25,15 +25,10 @@ function ThreadView() {
useEffect(() => {
const rendered = [];
const entries = Array.from(state.topics.values());
- entries.forEach((entry) => {
+ entries.forEach(entry => {
rendered.push(
-
- {entry.text}
-
,
- );
+
{ entry.text }
+ )
});
setTopics(rendered);
setRenderCount(renderCount + 1);
@@ -41,12 +36,7 @@ function ThreadView() {
return (
//@ts-ignore
-
- {topics}
-
+
{ topics }
);
}
@@ -85,14 +75,15 @@ beforeEach(() => {
fetchDetail = {};
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
if (url.startsWith('/contact/cards?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
}
if (url.startsWith('https://test.org/content/channels?contact')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchChannels),
+ json: () => Promise.resolve(fetchChannels)
});
}
if (url.startsWith('https://test.org/content/channels/channel01/topics?contact')) {
@@ -108,11 +99,12 @@ beforeEach(() => {
}
if (url.startsWith('https://test.org/content/channels/channel01/topics/topic01/detail?contact')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchDetail),
+ json: () => Promise.resolve(fetchDetail)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -130,6 +122,7 @@ afterEach(() => {
});
test('add, update, remove topic', async () => {
+
render(
);
await waitFor(async () => {
@@ -137,62 +130,46 @@ test('add, update, remove topic', async () => {
expect(conversation).not.toBe(null);
});
- fetchCards = [
- {
- id: 'card01',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: 'guid01',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: 'card01',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: 'guid01', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchChannels = [
- {
- id: 'channel01',
- revision: 2,
- data: {
+ { id: 'channel01', revision: 2, data: {
detailRevision: 3,
topicRevision: 5,
channelSummary: { guid: 'guid01', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
fetchTopics = [
- {
- id: 'topic01',
- revision: 1,
- data: {
- detailRevision: 1,
- tagRevision: 1,
- topicDetail: {
- guid: 'guid01',
- dataType: 'superbasictopic',
- data: JSON.stringify({ text: 'message' }),
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
+ { id: 'topic01', revision: 1, data: {
+ detailRevision: 1,
+ tagRevision: 1,
+ topicDetail: {
+ guid: 'guid01',
+ dataType: 'superbasictopic',
+ data: JSON.stringify({ text: 'message' }),
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
},
- },
+ }},
];
await act(async () => {
@@ -203,64 +180,51 @@ test('add, update, remove topic', async () => {
await waitFor(async () => {
expect(screen.getByTestId('thread').children).toHaveLength(1);
expect(screen.getByTestId('topic01').textContent).toBe('message');
- });
+ });
- fetchCards = [
- {
- id: 'card01',
- revision: 2,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 7,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: 'card01',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 7,
+ notifiedView: 7,
},
- ];
+ }];
fetchChannels = [
- {
- id: 'channel01',
- revision: 3,
- data: {
+ { id: 'channel01', revision: 3, data: {
detailRevision: 3,
topicRevision: 6,
channelSummary: { guid: 'guid01', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
fetchTopics = [
- {
- id: 'topic01',
- revision: 2,
- data: {
- detailRevision: 2,
- tagRevision: 1,
- },
- },
- ];
-
- fetchDetail = {
- id: 'topic01',
- revision: 2,
- data: {
+ { id: 'topic01', revision: 2, data: {
detailRevision: 2,
tagRevision: 1,
- topicDetail: {
- guid: 'guid01',
- dataType: 'superbasictopic',
- data: JSON.stringify({ text: 'message2' }),
- created: 1,
- updated: 1,
- status: 'confirmed',
- transform: 'complete',
- },
- },
- };
+ }},
+ ];
+
+ fetchDetail = { id: 'topic01', revision: 2, data: {
+ detailRevision: 2,
+ tagRevision: 1,
+ topicDetail: {
+ guid: 'guid01',
+ dataType: 'superbasictopic',
+ data: JSON.stringify({ text: 'message2' }),
+ created: 1,
+ updated: 1,
+ status: 'confirmed',
+ transform: 'complete',
+ }
+ }}
await act(async () => {
card.actions.setRevision(2);
@@ -268,37 +232,34 @@ test('add, update, remove topic', async () => {
await waitFor(async () => {
expect(screen.getByTestId('topic01').textContent).toBe('message2');
- });
+ });
- fetchCards = [
- {
- id: 'card01',
- revision: 3,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 8,
- notifiedView: 7,
- },
+ fetchCards = [{
+ id: 'card01',
+ revision: 3,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 8,
+ notifiedView: 7,
},
- ];
+ }];
fetchChannels = [
- {
- id: 'channel01',
- revision: 4,
- data: {
+ { id: 'channel01', revision: 4, data: {
detailRevision: 3,
topicRevision: 7,
channelSummary: { guid: 'guid01', dataType: 'superbasictopic', data: 'testcardtopic' },
channelDetail: { dataType: 'superbasic', data: 'testcardchannel' },
- },
+ }
},
];
- fetchTopics = [{ id: 'topic01', revision: 2 }];
+ fetchTopics = [
+ { id: 'topic01', revision: 2 },
+ ];
await act(async () => {
card.actions.setRevision(3);
@@ -306,5 +267,7 @@ test('add, update, remove topic', async () => {
await waitFor(async () => {
expect(screen.getByTestId('thread').children).toHaveLength(0);
- });
+ });
+
});
+
diff --git a/net/web/test/Topics.test.tsx b/net/web/test/Topics.test.tsx
index 0eeaeb78..76f55fb7 100644
--- a/net/web/test/Topics.test.tsx
+++ b/net/web/test/Topics.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { AppContextProvider } from 'context/AppContext';
import { AccountContextProvider } from 'context/AccountContext';
import { ProfileContextProvider } from 'context/ProfileContext';
@@ -25,19 +25,11 @@ function TopicsView() {
useEffect(() => {
const rendered = [];
- state.channels.forEach((chan) => {
+ state.channels.forEach(chan => {
rendered.push(
-
-
- {chan.subject}
-
-
,
+
+ { chan.subject }
+
);
});
setChannels(rendered);
@@ -46,11 +38,8 @@ function TopicsView() {
return (
//@ts-ignore
-
- {channels}
+
+ { channels }
);
}
@@ -81,26 +70,31 @@ let fetchCardChannels;
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
const realFetchWithCustomTimeout = fetchUtil.fetchWithCustomTimeout;
beforeEach(() => {
- fetchCards = [];
+
+ fetchCards = []
fetchChannels = [];
fetchCardChannels = [];
const mockFetch = jest.fn().mockImplementation((url, options) => {
+
if (url.startsWith('/contact/cards?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCards),
+ json: () => Promise.resolve(fetchCards)
});
- } else if (url.startsWith('/content/channels?agent')) {
+ }
+ else if (url.startsWith('/content/channels?agent')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchChannels),
+ json: () => Promise.resolve(fetchChannels)
});
- } else if (url.startsWith('https://test.org/content/channels?contact')) {
+ }
+ else if (url.startsWith('https://test.org/content/channels?contact')) {
return Promise.resolve({
- json: () => Promise.resolve(fetchCardChannels),
+ json: () => Promise.resolve(fetchCardChannels)
});
- } else {
+ }
+ else {
return Promise.resolve({
- json: () => Promise.resolve([]),
+ json: () => Promise.resolve([])
});
}
});
@@ -126,51 +120,36 @@ test('view merged channels', async () => {
});
fetchChannels = [
- {
- id: '123',
- revision: 3,
- data: {
+ { id: '123', revision: 3, data: {
detailRevision: 4,
topicRevision: 5,
channelDetail: { dataType: 'superbasic', data: JSON.stringify({ subject: 'channelsubject' }), members: [] },
- },
+ }
},
];
- fetchCards = [
- {
- id: '000a',
- revision: 1,
- data: {
- detailRevision: 2,
- profileRevision: 3,
- notifiedProfile: 3,
- notifiedArticle: 5,
- notifiedChannel: 6,
- notifiedView: 7,
- cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab' },
- cardProfile: {
- guid: '01ab23',
- handle: 'test1',
- name: 'tester',
- imageSet: false,
- seal: 'abc',
- version: '1.1.1',
- node: 'test.org',
- },
- },
+ fetchCards = [{
+ id: '000a',
+ revision: 1,
+ data: {
+ detailRevision: 2,
+ profileRevision: 3,
+ notifiedProfile: 3,
+ notifiedArticle: 5,
+ notifiedChannel: 6,
+ notifiedView: 7,
+ cardDetail: { status: 'connected', statusUpdate: 136, token: '01ab', },
+ cardProfile: { guid: '01ab23', handle: 'test1', name: 'tester', imageSet: false,
+ seal: 'abc', version: '1.1.1', node: 'test.org' },
},
- ];
+ }];
fetchCardChannels = [
- {
- id: '2123',
- revision: 3,
- data: {
+ { id: '2123', revision: 3, data: {
detailRevision: 4,
topicRevision: 5,
channelDetail: { dataType: 'superbasic', data: JSON.stringify({ subject: 'cardchannelsubject' }), members: [] },
- },
+ }
},
];
@@ -186,4 +165,8 @@ test('view merged channels', async () => {
expect(screen.getByTestId('channelId-2123').textContent).toBe('cardchannelsubject');
expect(screen.getByTestId('channelId-123').textContent).toBe('channelsubject');
});
+
});
+
+
+
diff --git a/net/web/test/Upload.test.tsx b/net/web/test/Upload.test.tsx
index d242c080..dd7c9b73 100644
--- a/net/web/test/Upload.test.tsx
+++ b/net/web/test/Upload.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { UploadContextProvider, UploadContext } from 'context/UploadContext';
import axios from 'axios';
@@ -15,20 +15,21 @@ function UploadView() {
setRenderCount(renderCount + 1);
upload.state.progress.forEach((value, key) => {
- value.forEach((topic) => {
+ value.forEach(topic => {
if (topic.active?.total > total) {
setTotal(topic.active?.total);
- }
+ };
});
setChannel(key);
});
+
}, [upload.state]);
return (
- {renderCount}
- {channel}
- {total}
+ { renderCount }
+ { channel }
+ { total }
);
}
@@ -38,7 +39,7 @@ function UploadTestApp() {
- );
+ )
}
const realPost = axios.post;
@@ -49,7 +50,7 @@ beforeEach(() => {
const mockPost = jest.fn().mockImplementation(async (url, data, options) => {
for (let i = 0; i < 10; i++) {
- await new Promise((r) => setTimeout(r, 10));
+ await new Promise(r => setTimeout(r, 10));
options.onUploadProgress({ loaded: i * 11, total: 111 });
}
@@ -70,20 +71,11 @@ test('uploading assets', async () => {
expect(uploadContext).not.toBe(null);
});
- asset = [{ assetId: '3', transform: 'acopy;audio', status: 'pending' }];
+ asset = [ { assetId: '3', transform: 'acopy;audio', status: 'pending' } ];
setComplete = false;
await act(async () => {
- uploadContext.actions.addTopic(
- 'asdf',
- '123',
- '1',
- [{ audio: 'asdf' }],
- () => {
- setComplete = true;
- },
- () => {},
- );
+ uploadContext.actions.addTopic('asdf', '123', '1', [{audio: 'asdf'}], ()=>{setComplete=true}, ()=>{});
});
await waitFor(async () => {
@@ -94,21 +86,15 @@ test('uploading assets', async () => {
setComplete = false;
await act(async () => {
- uploadContext.actions.addTopic(
- 'asdf',
- '123',
- '1',
- [{ audio: 'asdf' }],
- () => {
- setComplete = true;
- },
- () => {},
- { server: 'test.org', token: '0011', cardId: '96' },
- );
+ uploadContext.actions.addTopic('asdf', '123', '1', [{audio: 'asdf'}], ()=>{setComplete=true}, ()=>{}, { server: 'test.org', token: '0011', cardId: '96' });
});
await waitFor(async () => {
expect(setComplete).toBe(true);
expect(screen.getByTestId('channel').textContent).toBe('96:123');
});
+
});
+
+
+
diff --git a/net/web/test/User.test.tsx b/net/web/test/User.test.tsx
index f4a9e35c..f5608553 100644
--- a/net/web/test/User.test.tsx
+++ b/net/web/test/User.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { AppContextProvider } from 'context/AppContext';
import { AccountContextProvider } from 'context/AccountContext';
import { ProfileContext, ProfileContextProvider } from 'context/ProfileContext';
@@ -27,12 +27,7 @@ function ProfileView() {
return (
//@ts-ignore
-
- {name}
-
+
{ name }
);
}
@@ -56,13 +51,13 @@ let updated;
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
const realFetchWithCustomTimeout = fetchUtil.fetchWithCustomTimeout;
beforeEach(() => {
- let updated = false;
+ let updated = false;
const mockFetch = jest.fn().mockImplementation((url, options) => {
if (options.method === 'PUT') {
updated = true;
}
return Promise.resolve({
- json: () => Promise.resolve({ name: updated ? 'tested' : 'tester' }),
+ json: () => Promise.resolve({ name: updated ? 'tested' : 'tester' })
});
});
//@ts-ignore
@@ -79,6 +74,7 @@ afterEach(() => {
});
test('update profile name', async () => {
+
render(
);
await waitFor(async () => {
@@ -110,4 +106,6 @@ test('update profile name', async () => {
await waitFor(async () => {
expect(screen.getByTestId('name').textContent).toBe('tested');
});
+
});
+
diff --git a/net/web/test/Viewport.test.tsx b/net/web/test/Viewport.test.tsx
index 9ee754e1..eeeff61a 100644
--- a/net/web/test/Viewport.test.tsx
+++ b/net/web/test/Viewport.test.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
-import { render, act, screen, waitFor, fireEvent } from '@testing-library/react';
+import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
import { SettingsContext, SettingsContextProvider } from 'context/SettingsContext';
@@ -13,10 +13,10 @@ function ViewportView() {
return (
- {renderCount}
- {settings.state.display}
- {settings.state.width}
- {settings.state.height}
+ { renderCount }
+ { settings.state.display }
+ { settings.state.width }
+ { settings.state.height }
);
}
@@ -37,4 +37,8 @@ test('display size', async () => {
expect(screen.getByTestId('width').textContent).toBe('1024');
expect(screen.getByTestId('height').textContent).toBe('768');
});
+
});
+
+
+