File size: 4,249 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
// @flow
import * as channel from '../channel';
const queries = channel.__forQueryTests;
import {
BRIAN_ID,
MAX_ID,
SPECTRUM_COMMUNITY_ID,
SPECTRUM_GENERAL_CHANNEL_ID,
SPECTRUM_PRIVATE_CHANNEL_ID,
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
} from 'api/migrations/seed/default/constants';
describe('models/channel', () => {
describe('channelsByCommunitiesQuery', () => {
it('excludes deleted channels', async () => {
const channels = await queries
.channelsByCommunitiesQuery(SPECTRUM_COMMUNITY_ID)
.run();
expect(
channels.filter(channel => channel.deletedAt !== undefined)
).toEqual([]);
});
});
describe('channelsByIdsQuery', () => {
it('excludes deleted channels', async () => {
const channels = await queries
.channelsByIdsQuery(
SPECTRUM_GENERAL_CHANNEL_ID,
DELETED_COMMUNITY_DELETED_CHANNEL_ID
)
.run();
expect(
channels.filter(channel => channel.deletedAt !== undefined)
).toEqual([]);
});
});
describe('threadsByChannelsQuery', () => {
it('excludes deleted channels', async () => {
const threads = await queries
.threadsByChannelsQuery(DELETED_COMMUNITY_DELETED_CHANNEL_ID)
.run();
expect(threads).toEqual([]);
});
it('excludes deleted threads', async () => {
const threads = await queries
.threadsByChannelsQuery(SPECTRUM_GENERAL_CHANNEL_ID)
.run();
expect(threads.filter(thread => thread.deletedAt !== undefined)).toEqual(
[]
);
});
});
describe('membersByChannelsQuery', () => {
it('excludes deleted channels', async () => {
const members = await queries
.membersByChannelsQuery(DELETED_COMMUNITY_DELETED_CHANNEL_ID)
.run();
expect(members).toEqual([]);
});
it('excludes removed members', async () => {
const members = await queries
.membersByChannelsQuery(SPECTRUM_GENERAL_CHANNEL_ID)
.run();
expect(members.filter(member => !member.isMember)).toEqual([]);
});
});
describe('getChannelsByCommunity', () => {
it('returns correct set of channels', async () => {
expect(
await channel.getChannelsByCommunity(SPECTRUM_COMMUNITY_ID)
).toMatchSnapshot();
});
});
describe('getPublicChannelsByCommunity', () => {
it('returns correct set of channels', async () => {
expect(
await channel.getPublicChannelsByCommunity(SPECTRUM_COMMUNITY_ID)
).toMatchSnapshot();
});
});
describe('getChannelsByUserAndCommunity', () => {
it('returns correct set of channels', async () => {
expect(
await channel.getChannelsByUserAndCommunity(
SPECTRUM_COMMUNITY_ID,
MAX_ID
)
).toMatchSnapshot();
});
});
describe('getChannelsByUser', () => {
it('returns correct set of channels', async () => {
expect(await channel.getChannelsByUser(BRIAN_ID)).toMatchSnapshot();
});
});
describe('getChannelBySlug', () => {
it('excludes deleted channels', async () => {
expect(await channel.getChannelBySlug('deleted', 'spectrum')).toEqual(
null
);
});
});
describe('getChannelById', () => {
it('excludes deleted channels', async () => {
expect(
await channel.getChannelById(DELETED_COMMUNITY_DELETED_CHANNEL_ID)
).toEqual(null);
});
});
describe('getChannels', () => {
it('excludes deleted channels', async () => {
expect(
await channel.getChannels([
SPECTRUM_GENERAL_CHANNEL_ID,
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
])
).toMatchSnapshot();
});
});
describe('getChannelsThreadCounts', () => {
it('excludes deleted channels', async () => {
expect(
await channel.getChannelsThreadCounts([
SPECTRUM_GENERAL_CHANNEL_ID,
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
])
).toMatchSnapshot();
});
it('excludes deleted threads', async () => {
expect(
await channel.getChannelsThreadCounts([
SPECTRUM_GENERAL_CHANNEL_ID,
SPECTRUM_PRIVATE_CHANNEL_ID,
])
).toMatchSnapshot();
});
});
});
|