@@ -3,7 +3,6 @@ const WinstonLoggerAdapter = require('../lib/Adapters/Logger/WinstonLoggerAdapte
33 . WinstonLoggerAdapter ;
44const GridFSBucketAdapter = require ( '../lib/Adapters/Files/GridFSBucketAdapter' )
55 . GridFSBucketAdapter ;
6- const GridStoreAdapter = require ( '../lib/Adapters/Files/GridStoreAdapter' ) . GridStoreAdapter ;
76const Config = require ( '../lib/Config' ) ;
87const FilesController = require ( '../lib/Controllers/FilesController' ) . default ;
98const databaseURI = 'mongodb://localhost:27017/parse' ;
@@ -24,8 +23,8 @@ const mockAdapter = {
2423describe ( 'FilesController' , ( ) => {
2524 it ( 'should properly expand objects' , done => {
2625 const config = Config . get ( Parse . applicationId ) ;
27- const gridStoreAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
28- const filesController = new FilesController ( gridStoreAdapter ) ;
26+ const gridFSAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
27+ const filesController = new FilesController ( gridFSAdapter ) ;
2928 const result = filesController . expandFilesInObject ( config , function ( ) { } ) ;
3029
3130 expect ( result ) . toBeUndefined ( ) ;
@@ -88,19 +87,19 @@ describe('FilesController', () => {
8887
8988 it ( 'should add a unique hash to the file name when the preserveFileName option is false' , done => {
9089 const config = Config . get ( Parse . applicationId ) ;
91- const gridStoreAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
92- spyOn ( gridStoreAdapter , 'createFile' ) ;
93- gridStoreAdapter . createFile . and . returnValue ( Promise . resolve ( ) ) ;
90+ const gridFSAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
91+ spyOn ( gridFSAdapter , 'createFile' ) ;
92+ gridFSAdapter . createFile . and . returnValue ( Promise . resolve ( ) ) ;
9493 const fileName = 'randomFileName.pdf' ;
9594 const regexEscapedFileName = fileName . replace ( / \. / g, '\\$&' ) ;
96- const filesController = new FilesController ( gridStoreAdapter , null , {
95+ const filesController = new FilesController ( gridFSAdapter , null , {
9796 preserveFileName : false ,
9897 } ) ;
9998
10099 filesController . createFile ( config , fileName ) ;
101100
102- expect ( gridStoreAdapter . createFile ) . toHaveBeenCalledTimes ( 1 ) ;
103- expect ( gridStoreAdapter . createFile . calls . mostRecent ( ) . args [ 0 ] ) . toMatch (
101+ expect ( gridFSAdapter . createFile ) . toHaveBeenCalledTimes ( 1 ) ;
102+ expect ( gridFSAdapter . createFile . calls . mostRecent ( ) . args [ 0 ] ) . toMatch (
104103 `^.{32}_${ regexEscapedFileName } $`
105104 ) ;
106105
@@ -109,42 +108,42 @@ describe('FilesController', () => {
109108
110109 it ( 'should not add a unique hash to the file name when the preserveFileName option is true' , done => {
111110 const config = Config . get ( Parse . applicationId ) ;
112- const gridStoreAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
113- spyOn ( gridStoreAdapter , 'createFile' ) ;
114- gridStoreAdapter . createFile . and . returnValue ( Promise . resolve ( ) ) ;
111+ const gridFSAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
112+ spyOn ( gridFSAdapter , 'createFile' ) ;
113+ gridFSAdapter . createFile . and . returnValue ( Promise . resolve ( ) ) ;
115114 const fileName = 'randomFileName.pdf' ;
116- const filesController = new FilesController ( gridStoreAdapter , null , {
115+ const filesController = new FilesController ( gridFSAdapter , null , {
117116 preserveFileName : true ,
118117 } ) ;
119118
120119 filesController . createFile ( config , fileName ) ;
121120
122- expect ( gridStoreAdapter . createFile ) . toHaveBeenCalledTimes ( 1 ) ;
123- expect ( gridStoreAdapter . createFile . calls . mostRecent ( ) . args [ 0 ] ) . toEqual ( fileName ) ;
121+ expect ( gridFSAdapter . createFile ) . toHaveBeenCalledTimes ( 1 ) ;
122+ expect ( gridFSAdapter . createFile . calls . mostRecent ( ) . args [ 0 ] ) . toEqual ( fileName ) ;
124123
125124 done ( ) ;
126125 } ) ;
127126
128127 it ( 'should handle adapter without getMetadata' , async ( ) => {
129- const gridStoreAdapter = new GridFSBucketAdapter ( databaseURI ) ;
130- gridStoreAdapter . getMetadata = null ;
131- const filesController = new FilesController ( gridStoreAdapter ) ;
128+ const gridFSAdapter = new GridFSBucketAdapter ( databaseURI ) ;
129+ gridFSAdapter . getMetadata = null ;
130+ const filesController = new FilesController ( gridFSAdapter ) ;
132131
133132 const result = await filesController . getMetadata ( ) ;
134133 expect ( result ) . toEqual ( { } ) ;
135134 } ) ;
136135
137136 it ( 'should reject slashes in file names' , done => {
138- const gridStoreAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
137+ const gridFSAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
139138 const fileName = 'foo/randomFileName.pdf' ;
140- expect ( gridStoreAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
139+ expect ( gridFSAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
141140 done ( ) ;
142141 } ) ;
143142
144143 it ( 'should also reject slashes in file names' , done => {
145- const gridStoreAdapter = new GridStoreAdapter ( 'mongodb://localhost:27017/parse' ) ;
144+ const gridFSAdapter = new GridFSBucketAdapter ( 'mongodb://localhost:27017/parse' ) ;
146145 const fileName = 'foo/randomFileName.pdf' ;
147- expect ( gridStoreAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
146+ expect ( gridFSAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
148147 done ( ) ;
149148 } ) ;
150149} ) ;
0 commit comments