Skip to content

Commit

Permalink
Merge ea2f90f into f418a0a
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgy committed May 31, 2019
2 parents f418a0a + ea2f90f commit 99e06e1
Showing 1 changed file with 64 additions and 10 deletions.
74 changes: 64 additions & 10 deletions test/integration/cloud/reaction.js
Expand Up @@ -385,6 +385,64 @@ describe('Nested reactions violations', () => {
});
});
});

let eatActivity;
let commentFirstLevel;
let commentSecondLevel;
let commentThirdLevel;

describe('When alice eats a cheese burger', () => {
ctx.requestShouldNotError(async () => {
ctx.response = await ctx.alice
.feed('user', ctx.alice.userId)
.addActivity({
verb: 'eat',
object: 'cheeseburger',
});
eatActivity = ctx.response;
eatActivity.actor = ctx.alice.currentUser.full;
});
});

describe('When a reaction is added at the first nesting level', () => {
ctx.requestShouldNotError(async () => {
ctx.response = await ctx.bob.reactions.add('comment', eatActivity.id, {
text: 'Looking yummy! @carl wanna get this on Tuesday?',
});
commentFirstLevel = ctx.response;
});
});

describe('When a reaction is added at the second nesting level', () => {
ctx.requestShouldNotError(async () => {
ctx.response = await ctx.alice.reactions.addChild(
'comment',
commentFirstLevel,
{ text: 'Yes!' },
);
commentSecondLevel = ctx.response;
});
});

describe('When a reaction is added at the third nesting level', () => {
ctx.requestShouldNotError(async () => {
ctx.response = await ctx.bob.reactions.addChild(
'comment',
commentSecondLevel,
{ text: 'I want too!' },
);
commentThirdLevel = ctx.response;
});
});

describe('When a reaction is added at the forth+ nesting level', () => {
ctx.requestShouldError(400, async () => {
ctx.response = await ctx.alice.reactions.addChild(
'like',
commentThirdLevel,
);
});
});
});

describe('Nested reactions madness', () => {
Expand Down Expand Up @@ -430,12 +488,6 @@ describe('Nested reactions madness', () => {
});
});

describe("and then alice likes her own like Bob's comment", () => {
ctx.requestShouldError(400, async () => {
ctx.response = await ctx.alice.reactions.addChild('like', likeReaction);
});
});

describe('and then alice reads the comment reaction', () => {
ctx.requestShouldNotError(async () => {
let reaction = await ctx.alice.reactions.get(comment.id);
Expand Down Expand Up @@ -488,16 +540,18 @@ describe('Nested reactions madness', () => {
});
});

describe("and then alice like her own like Bob's comment", () => {
ctx.requestShouldNotError(async () => {
ctx.response = await ctx.alice.reactions.addChild('like', likeReaction);
});
});

describe('and then alice reads the comment reaction', () => {
ctx.requestShouldNotError(async () => {
let reaction = await ctx.alice.reactions.get(comment.id);
reaction.children_counts.like.should.eql(1);
reaction.latest_children.should.have.all.keys('like');
reaction.latest_children.like.should.have.length(1);
ctx.shouldEqualBesideDuration(
reaction.latest_children.like[0],
likeReaction,
);
});
});

Expand Down

0 comments on commit 99e06e1

Please sign in to comment.