@@ -3,26 +3,21 @@ import {shallow} from 'enzyme';
33
44import { multiFilePatchBuilder } from '../builder/patch' ;
55import { pullRequestBuilder } from '../builder/pr' ;
6- import PullRequestCommentsView , { PullRequestCommentView } from '../../lib/views/pr-review-comments-view' ;
7-
8- describe ( 'PullRequestCommentsView' , function ( ) {
9- function buildApp ( multiFilePatch , pullRequest , overrideProps ) {
10- const relay = {
11- hasMore : ( ) => { } ,
12- loadMore : ( ) => { } ,
13- isLoading : ( ) => { } ,
14- } ;
6+ import PullRequestReviewCommentThreadView , { PullRequestCommentView } from '../../lib/views/pr-review-comment-thread-view' ;
7+
8+ describe ( 'PullRequestReviewCommentThreadView' , function ( ) {
9+ function buildApp ( multiFilePatch , commentThread , overrideProps = { } ) {
1510 return shallow (
16- < PullRequestCommentsView
17- isPatchVisible = { sinon . stub ( ) . returns ( true ) }
18- getBufferRowForDiffPosition = { multiFilePatch . getBufferRowForDiffPosition } reviews = { pullRequest . reviews }
19- commentThreads = { pullRequest . commentThreads }
20- relay = { relay }
11+ < PullRequestReviewCommentThreadView
12+ isPatchVisible = { ( ) => true }
13+ getBufferRowForDiffPosition = { multiFilePatch . getBufferRowForDiffPosition }
14+ commentThread = { commentThread }
2115 switchToIssueish = { ( ) => { } }
2216 { ...overrideProps }
2317 /> ,
2418 ) ;
2519 }
20+
2621 it ( 'adjusts the position for comments after hunk headers' , function ( ) {
2722 const { multiFilePatch} = multiFilePatchBuilder ( )
2823 . addFilePatch ( fp => {
@@ -48,11 +43,14 @@ describe('PullRequestCommentsView', function() {
4843 } )
4944 . build ( ) ;
5045
51- const wrapper = buildApp ( multiFilePatch , pr , { } ) ;
46+ const wrapper0 = buildApp ( multiFilePatch , pr . commentThreads [ 0 ] ) ;
47+ assert . deepEqual ( wrapper0 . find ( 'Marker' ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 1 , 0 ] , [ 1 , 0 ] ] ) ;
5248
53- assert . deepEqual ( wrapper . find ( 'Marker' ) . at ( 0 ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 1 , 0 ] , [ 1 , 0 ] ] ) ;
54- assert . deepEqual ( wrapper . find ( 'Marker' ) . at ( 1 ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 12 , 0 ] , [ 12 , 0 ] ] ) ;
55- assert . deepEqual ( wrapper . find ( 'Marker' ) . at ( 2 ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 20 , 0 ] , [ 20 , 0 ] ] ) ;
49+ const wrapper1 = buildApp ( multiFilePatch , pr . commentThreads [ 1 ] ) ;
50+ assert . deepEqual ( wrapper1 . find ( 'Marker' ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 12 , 0 ] , [ 12 , 0 ] ] ) ;
51+
52+ const wrapper2 = buildApp ( multiFilePatch , pr . commentThreads [ 2 ] ) ;
53+ assert . deepEqual ( wrapper2 . find ( 'Marker' ) . prop ( 'bufferRange' ) . serialize ( ) , [ [ 20 , 0 ] , [ 20 , 0 ] ] ) ;
5654 } ) ;
5755
5856 it ( 'does not render comment if patch is too large or collapsed' , function ( ) {
@@ -64,9 +62,8 @@ describe('PullRequestCommentsView', function() {
6462 } )
6563 . build ( ) ;
6664
67- const wrapper = buildApp ( multiFilePatch , pr , { isPatchVisible : ( ) => { return false ; } } ) ;
68- const comments = wrapper . find ( 'PullRequestCommentView' ) ;
69- assert . lengthOf ( comments , 0 ) ;
65+ const wrapper = buildApp ( multiFilePatch , pr . commentThreads [ 0 ] , { isPatchVisible : ( ) => false } ) ;
66+ assert . isFalse ( wrapper . exists ( 'PullRequestCommentView' ) ) ;
7067 } ) ;
7168
7269 it ( 'does not render comment if position is null' , function ( ) {
@@ -88,11 +85,11 @@ describe('PullRequestCommentsView', function() {
8885 } )
8986 . build ( ) ;
9087
91- const wrapper = buildApp ( multiFilePatch , pr , { } ) ;
88+ const wrapper = buildApp ( multiFilePatch , pr . commentThreads [ 0 ] ) ;
9289
9390 const comments = wrapper . find ( 'PullRequestCommentView' ) ;
9491 assert . lengthOf ( comments , 1 ) ;
95- assert . strictEqual ( comments . at ( 0 ) . prop ( 'comment' ) . body , 'one' ) ;
92+ assert . strictEqual ( comments . prop ( 'comment' ) . body , 'one' ) ;
9693 } ) ;
9794} ) ;
9895
@@ -132,7 +129,7 @@ describe('PullRequestCommentView', function() {
132129 assert . strictEqual ( avatar . getElement ( 'src' ) . props . src , avatarUrl ) ;
133130 assert . strictEqual ( avatar . getElement ( 'alt' ) . props . alt , login ) ;
134131
135- assert . isTrue ( wrapper . text ( ) . includes ( `${ login } commented` ) ) ;
132+ assert . include ( wrapper . text ( ) , `${ login } commented` ) ;
136133
137134 const a = wrapper . find ( '.github-PrComment-timeAgo' ) ;
138135 assert . strictEqual ( a . getElement ( 'href' ) . props . href , commentUrl ) ;
@@ -147,12 +144,12 @@ describe('PullRequestCommentView', function() {
147144
148145 it ( 'contains the text `someone commented` for null authors' , function ( ) {
149146 const wrapper = shallow ( buildApp ( { author : null } ) ) ;
150- assert . isTrue ( wrapper . text ( ) . includes ( 'someone commented' ) ) ;
147+ assert . include ( wrapper . text ( ) , 'someone commented' ) ;
151148 } ) ;
152149
153150 it ( 'hides minimized comment' , function ( ) {
154151 const wrapper = shallow ( buildApp ( { isMinimized : true } ) ) ;
155- assert . isTrue ( wrapper . find ( '.github-PrComment-hidden' ) . exists ( ) ) ;
156- assert . isFalse ( wrapper . find ( '.github-PrComment-header' ) . exists ( ) ) ;
152+ assert . isTrue ( wrapper . exists ( '.github-PrComment-hidden' ) ) ;
153+ assert . isFalse ( wrapper . exists ( '.github-PrComment-header' ) ) ;
157154 } ) ;
158155} ) ;
0 commit comments