);
}
@@ -66,25 +77,21 @@ 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([]),
});
}
});
@@ -108,21 +115,30 @@ 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');
@@ -134,21 +150,30 @@ 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);
@@ -158,10 +183,12 @@ 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);
@@ -170,8 +197,4 @@ 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 e4b53f3b..df65698b 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,22 +22,30 @@ 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}
);
}
@@ -51,7 +59,7 @@ function ConversationTestApp() {
- )
+ );
}
const realFetchWithTimeout = fetchUtil.fetchWithTimeout;
@@ -70,7 +78,6 @@ let fetchTopics;
let statusTopic;
let fetchTopic;
beforeEach(() => {
-
statusCards = 200;
fetchCards = [];
statusChannels = 200;
@@ -85,7 +92,6 @@ beforeEach(() => {
beginSet = false;
const mockFetch = jest.fn().mockImplementation((url, options) => {
-
const params = url.split('/');
if (params[2]?.startsWith('channels?agent')) {
return Promise.resolve({
@@ -93,29 +99,25 @@ 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;
}
@@ -131,8 +133,7 @@ beforeEach(() => {
headers: headers,
json: () => Promise.resolve(fetchTopics),
});
- }
- else {
+ } else {
return Promise.resolve({
url: 'endpoint',
status: 200,
@@ -140,7 +141,6 @@ beforeEach(() => {
json: () => Promise.resolve({}),
});
}
-
});
//@ts-ignore
fetchUtil.fetchWithTimeout = mockFetch;
@@ -155,8 +155,7 @@ afterEach(() => {
fetchUtil.fetchWithCustomTimeout = realFetchWithCustomTimeout;
});
-test('add, update, and remove topic', async() => {
-
+test('add, update, and remove topic', async () => {
render(
);
await waitFor(async () => {
@@ -171,38 +170,53 @@ 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' },
- }
+ },
},
];
@@ -212,20 +226,23 @@ 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 () => {
@@ -238,20 +255,23 @@ 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 () => {
@@ -264,22 +284,31 @@ 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: {
@@ -291,7 +320,7 @@ test('add, update, and remove topic', async() => {
status: 'confirmed',
transform: 'complete',
},
- }
+ },
};
await act(async () => {
@@ -304,19 +333,25 @@ 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 () => {
@@ -329,16 +364,17 @@ 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);
@@ -348,16 +384,13 @@ 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 () => {
@@ -371,29 +404,41 @@ 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' },
- }
+ },
},
];
@@ -404,20 +449,24 @@ 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');
@@ -431,20 +480,24 @@ 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();
@@ -456,26 +509,31 @@ 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' },
- }
+ },
},
];
@@ -487,19 +545,25 @@ 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();
@@ -516,6 +580,4 @@ 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 d0fdd282..918135a4 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,7 +25,12 @@ function InfoView() {
return (
//@ts-ignore
-
{ state.title }
+
+ {state.title}
+
);
}
@@ -64,15 +69,14 @@ 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')) {
@@ -88,12 +92,11 @@ 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([]),
});
}
});
@@ -111,7 +114,6 @@ afterEach(() => {
});
test('conversation selection', async () => {
-
render(
);
await waitFor(async () => {
@@ -124,46 +126,62 @@ 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 () => {
@@ -173,41 +191,50 @@ 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' },
- },
- }];
-
- fetchChannels = [
- { id: 'channel01', revision: 3, data: {
- detailRevision: 4,
- topicRevision: 5,
- }
+ 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',
+ },
+ },
},
];
- fetchDetail = { dataType: 'superbasic', data: JSON.stringify({ subject: 'testing' }), },
+ fetchChannels = [
+ {
+ id: 'channel01',
+ revision: 3,
+ data: {
+ detailRevision: 4,
+ topicRevision: 5,
+ },
+ },
+ ];
- 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 b1a890e5..c3959d40 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,13 +13,20 @@ function ListingView() {
listing = actions;
useEffect(() => {
-
const rendered = [];
- state.contacts.forEach(item => {
+ state.contacts.forEach((item) => {
rendered.push(
-
- { item.name }
-
+
+
+ {item.name}
+
+
,
);
});
setContacts(rendered);
@@ -28,8 +35,11 @@ function ListingView() {
return (
//@ts-ignore
-
- { contacts }
+
+ {contacts}
);
}
@@ -51,9 +61,8 @@ beforeEach(() => {
fetchListing = [];
const mockFetch = jest.fn().mockImplementation((url, options) => {
-
return Promise.resolve({
- json: () => Promise.resolve(fetchListing)
+ json: () => Promise.resolve(fetchListing),
});
});
//@ts-ignore
@@ -96,8 +105,4 @@ 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 f05fa9c6..8eb2f855 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,25 +53,21 @@ 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([]),
});
}
});
@@ -89,7 +85,6 @@ afterEach(() => {
});
test('update contact name', async () => {
-
render(
);
await waitFor(async () => {
@@ -97,21 +92,30 @@ 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');
@@ -123,83 +127,95 @@ 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);
@@ -209,7 +225,4 @@ 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 3f3fedea..e506ead3 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,8 +110,4 @@ 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 9d672e68..711a8562 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,9 +14,15 @@ 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;
@@ -27,7 +33,7 @@ function SessionView() {
const store = useContext(StoreContext);
cardContext = card;
storeContext = store;
- return (
{ state.cardUpdated.toString() }
);
+ return
{state.cardUpdated.toString()}
;
}
function SessionTestApp() {
@@ -64,12 +70,11 @@ 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([]),
});
}
});
@@ -87,14 +92,15 @@ 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: {
@@ -104,30 +110,35 @@ 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 bbaf0f06..7cbbee39 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,8 +63,4 @@ 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 79b2188d..5f67b793 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,10 +25,15 @@ 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);
@@ -36,7 +41,12 @@ function ThreadView() {
return (
//@ts-ignore
-
{ topics }
+
+ {topics}
+
);
}
@@ -75,15 +85,14 @@ 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')) {
@@ -99,12 +108,11 @@ 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([]),
});
}
});
@@ -122,7 +130,6 @@ afterEach(() => {
});
test('add, update, remove topic', async () => {
-
render(
);
await waitFor(async () => {
@@ -130,46 +137,62 @@ 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 () => {
@@ -180,51 +203,64 @@ 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,
- }},
+ {
+ id: 'topic01',
+ revision: 2,
+ data: {
+ detailRevision: 2,
+ tagRevision: 1,
+ },
+ },
];
- 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',
- }
- }}
+ 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);
@@ -232,34 +268,37 @@ 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);
@@ -267,7 +306,5 @@ 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 76f55fb7..0eeaeb78 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,11 +25,19 @@ function TopicsView() {
useEffect(() => {
const rendered = [];
- state.channels.forEach(chan => {
+ state.channels.forEach((chan) => {
rendered.push(
-
- { chan.subject }
-
+
+
+ {chan.subject}
+
+
,
);
});
setChannels(rendered);
@@ -38,8 +46,11 @@ function TopicsView() {
return (
//@ts-ignore
-
- { channels }
+
+ {channels}
);
}
@@ -70,31 +81,26 @@ 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([]),
});
}
});
@@ -120,36 +126,51 @@ 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: [] },
- }
+ },
},
];
@@ -165,8 +186,4 @@ 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 dd7c9b73..d242c080 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,21 +15,20 @@ 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}
);
}
@@ -39,7 +38,7 @@ function UploadTestApp() {
- )
+ );
}
const realPost = axios.post;
@@ -50,7 +49,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 });
}
@@ -71,11 +70,20 @@ 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 () => {
@@ -86,15 +94,21 @@ 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 f5608553..f4a9e35c 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,7 +27,12 @@ function ProfileView() {
return (
//@ts-ignore
-
{ name }
+
+ {name}
+
);
}
@@ -51,13 +56,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
@@ -74,7 +79,6 @@ afterEach(() => {
});
test('update profile name', async () => {
-
render(
);
await waitFor(async () => {
@@ -106,6 +110,4 @@ 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 eeeff61a..9ee754e1 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,8 +37,4 @@ test('display size', async () => {
expect(screen.getByTestId('width').textContent).toBe('1024');
expect(screen.getByTestId('height').textContent).toBe('768');
});
-
});
-
-
-