Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const expectFolding = async (nComments, expComments, expOmitted, allComments = false) => {
for (let n = 0; n < nComments; n++) {
await createCommentAsync(luna, lunaPost.id, `Comment ${n + 1}`); // eslint-disable-line no-await-in-loop
}
const post = await fetchPost(lunaPost.id, null, { allComments });
expect(post.posts.comments, 'to have length', expComments);
expect(post.posts.omittedComments, 'to equal', expOmitted);
};
it(`should publish the X-Freefeed-Server (server version) and Date response header`, async () => {
const resp = await fetch(`${app.context.config.host}/v2/users/whoami`);
expect(resp.status, 'to be', 401);
expect(resp.headers.get('X-Freefeed-Server'), 'to be', serverVersion);
expect(resp.headers.get('Access-Control-Expose-Headers'), 'to contain', 'X-Freefeed-Server');
expect(resp.headers.get('Access-Control-Expose-Headers'), 'to contain', 'Date');
});
it('should not return metatag for unexisting user', async () => {
const meta = await fetchMetatags('evita');
expect(meta, 'not to contain', `
it('does not pass other types', function () {
expect(Stylesheet._isArray(new Date()), 'to be false');
expect(Stylesheet._isArray(/test/i), 'to be false');
expect(Stylesheet._isArray(function () {}), 'to be false');
expect(Stylesheet._isArray({}), 'to be false');
expect(Stylesheet._isArray(''), 'to be false');
expect(Stylesheet._isArray(123), 'to be false');
expect(Stylesheet._isArray(true), 'to be false');
expect(Stylesheet._isArray(undefined), 'to be false');
expect(Stylesheet._isArray(null), 'to be false');
});
});
it('does not pass other types', function () {
expect(Stylesheet._isObject(new Date()), 'to be false');
expect(Stylesheet._isObject(/test/i), 'to be false');
expect(Stylesheet._isObject(function () {}), 'to be false');
expect(Stylesheet._isObject([]), 'to be false');
expect(Stylesheet._isObject(''), 'to be false');
expect(Stylesheet._isObject(123), 'to be false');
expect(Stylesheet._isObject(true), 'to be false');
expect(Stylesheet._isObject(undefined), 'to be false');
expect(Stylesheet._isObject(null), 'to be false');
});
});
it(`should deliver 'post:update' event with isSaved field only to Luna when Luna updates post`, async () => {
const lunaEvent = lunaSession.receive('post:update');
const marsEvent = marsSession.receive('post:update');
const anonEvent = anonSession.receive('post:update');
luna.post = post;
await Promise.all([
funcTestHelper.updatePostAsync(luna, { body: 'Updated post' }),
lunaEvent, marsEvent, anonEvent,
]);
expect(lunaEvent, 'to be fulfilled with value satisfying', { posts: { isSaved: true } });
expect(marsEvent, 'to be fulfilled with value satisfying', { posts: expect.it('to not have key', 'isSaved') });
expect(anonEvent, 'to be fulfilled with value satisfying', { posts: expect.it('to not have key', 'isSaved') });
});
});
it('should not allow anonymous to restore activities', async () => {
const resp = await putActivities(app);
expect(resp.status, 'to equal', 401);
});
const getSubscribers = async (viewerCtx = null) => {
const headers = {};
if (viewerCtx !== null) {
headers['X-Authentication-Token'] = viewerCtx.authToken;
}
const resp = await fetch(`${app.context.config.host}/v1/users/${user.username}/subscribers`, { headers });
const json = await resp.json();
if (!resp.ok) {
const message = json.err ? `${resp.status} ${resp.statusText}: ${json.err}` : `${resp.status} ${resp.statusText}`;
throw new Error(message);
}
expect(json, 'to exhaustively satisfy', schema.userSubscribersResponse);
return json;
};
const expectFolding = async (nLikes, expLikes, expOmitted, allLikes = false) => {
await Promise.all(users.slice(0, nLikes).map((u) => like(lunaPost.id, u.authToken)));
const post = await fetchPost(lunaPost.id, null, { allLikes });
expect(post.posts.likes, 'to have length', expLikes);
expect(post.posts.omittedLikes, 'to equal', expOmitted);
};
it('adds numbers', function () {
expect(add(1, 3), 'to be', 4);
});
});