11import {
22 expect
33} from 'chai' ;
4+ import fse from 'fs-extra' ;
45import path from 'path' ;
56
67import {
78 fail ,
89 todo
910} from '../utils' ;
1011
11- import * as helpers from '../../build/src/helpers' ;
12+ import {
13+ getGitattributesPathFromRepo ,
14+ loadGitattributeFiltersFromRepo ,
15+ repoHasLfsFilters ,
16+ repoHasLfsObjectBin
17+ } from '../../build/src/helpers' ;
1218import track from '../../build/src/commands/track' ;
1319
1420describe ( 'helpers' , ( ) => {
21+ describe . only ( 'errorCatchHandler' , ( ) => {
22+ describe ( 'when the error is from LFS' , ( ) => {
23+ it ( 'returns a response object' , todo ) ;
24+ } ) ;
25+
26+ describe ( 'when the error is not from LFS' , ( ) => {
27+ it ( 'rethrows the error code' , todo ) ;
28+ } ) ;
29+ } ) ;
30+
1531 describe ( 'getGitattributesPathFromRepo' , ( ) => {
1632 it ( "gets the location of a repository's `.gitattributes` file" , function ( ) {
1733 const {
1834 lfsTestRepo
1935 } = this ;
2036
21- expect ( helpers . getGitattributesPathFromRepo ( lfsTestRepo ) )
37+ expect ( getGitattributesPathFromRepo ( lfsTestRepo ) )
2238 . to . equal ( path . join ( lfsTestRepo . workdir ( ) , '.gitattributes' ) ) ;
2339 } ) ;
2440 } ) ;
@@ -30,7 +46,7 @@ describe('helpers', () => {
3046 } = this ;
3147
3248 return track ( lfsTestRepo , [ '*.md' , 'test.txt' ] )
33- . then ( ( ) => helpers . loadGitattributeFiltersFromRepo ( lfsTestRepo ) )
49+ . then ( ( ) => loadGitattributeFiltersFromRepo ( lfsTestRepo ) )
3450 . then ( ( result ) => {
3551 expect ( result ) . to . have . members ( [ '*.md' , 'test.txt' ] ) ;
3652 } ) ;
@@ -42,7 +58,7 @@ describe('helpers', () => {
4258 emptyRepo
4359 } = this ;
4460
45- return helpers . loadGitattributeFiltersFromRepo ( emptyRepo )
61+ return loadGitattributeFiltersFromRepo ( emptyRepo )
4662 . then ( ( ) => fail ( 'Expected promise to fail!' ) )
4763 . catch ( ( err ) => {
4864 expect ( err . message ) . to . equal ( 'No .gitattributes found' ) ;
@@ -51,43 +67,75 @@ describe('helpers', () => {
5167 } ) ;
5268 } ) ;
5369
54- describe ( 'repoHasLfsFilters ' , ( ) => {
55- describe ( 'when the provided repository has `.gitattributes` filters ' , ( ) => {
70+ describe ( 'repoHasLfs ' , ( ) => {
71+ describe ( 'when the provided repository does not have LFS support enabled ' , ( ) => {
5672 it ( 'returns `true`' , todo ) ;
5773 } ) ;
5874
59- describe ( 'when the provided repository has no `.gitattributes` filters ' , ( ) => {
75+ describe ( 'when the provided repository has LFS support enabled ' , ( ) => {
6076 it ( 'returns `false`' , todo ) ;
6177 } ) ;
6278 } ) ;
6379
64- describe ( 'repoHasLfsObjectBin' , ( ) => {
65- describe ( 'when `.git/lfs` exists in the provided repository' , ( ) => {
66- it ( 'returns `true`' , todo ) ;
67- } ) ;
80+ describe ( 'repoHasLfsFilters' , ( ) => {
81+ describe ( 'when the provided repository has `.gitattributes` filters' , ( ) => {
82+ it ( 'returns `true`' , function ( ) {
83+ const {
84+ lfsTestRepo
85+ } = this ;
6886
69- describe ( 'when `.git/lfs` does not exist in the provided repository' , ( ) => {
70- it ( 'returns `false`' , todo ) ;
87+ return track ( lfsTestRepo , [ '*.md' ] )
88+ . then ( ( ) => repoHasLfsFilters ( lfsTestRepo ) )
89+ . then ( ( result ) => {
90+ expect ( result ) . to . be . true ;
91+ } ) ;
92+ } ) ;
7193 } ) ;
72- } ) ;
7394
74- describe ( 'repoHasLfs' , ( ) => {
75- describe ( 'when the provided repository does not have LFS support enabled' , ( ) => {
76- it ( 'returns `true`' , todo ) ;
77- } ) ;
95+ describe ( 'when the provided repository has no `.gitattributes` filters' , ( ) => {
96+ it ( 'returns `false`' , function ( ) {
97+ const {
98+ lfsTestRepo
99+ } = this ;
78100
79- describe ( 'when the provided repository has LFS support enabled' , ( ) => {
80- it ( 'returns `false`' , todo ) ;
101+ return repoHasLfsFilters ( lfsTestRepo )
102+ . then ( ( result ) => {
103+ expect ( result ) . to . be . false ;
104+ } ) ;
105+ } ) ;
81106 } ) ;
82107 } ) ;
83108
84- describe ( 'errorCatchHandler' , ( ) => {
85- describe ( 'when the error is from LFS' , ( ) => {
86- it ( 'returns a response object' , todo ) ;
109+ describe ( 'repoHasLfsObjectBin' , ( ) => {
110+ describe ( 'when `.git/lfs` exists in the provided repository' , ( ) => {
111+ it ( 'returns `true`' , function ( ) {
112+ const {
113+ lfsTestRepo
114+ } = this ;
115+
116+ return fse . mkdir ( path . join ( lfsTestRepo . path ( ) , 'lfs' ) )
117+ . then ( ( ) => repoHasLfsObjectBin ( lfsTestRepo ) )
118+ . then ( ( result ) => {
119+ expect ( result ) . to . be . true ;
120+ } ) ;
121+ } ) ;
87122 } ) ;
88123
89- describe ( 'when the error is not from LFS' , ( ) => {
90- it ( 'rethrows the error code' , todo ) ;
124+ describe ( 'when `.git/lfs` does not exist in the provided repository' , ( ) => {
125+ it ( 'returns `false`' , function ( ) {
126+ const {
127+ emptyRepo
128+ } = this ;
129+
130+ return repoHasLfsObjectBin ( emptyRepo )
131+ . then ( ( result ) => {
132+ expect ( result ) . to . be . false ;
133+ } ) ;
134+ } ) ;
91135 } ) ;
92136 } ) ;
137+
138+ describe ( 'verifyOutput' , ( ) => {
139+ describe ( 'when the provided stats ' )
140+ } ) ;
93141} ) ;
0 commit comments