@@ -3,7 +3,6 @@ const WinstonLoggerAdapter = require('../lib/Adapters/Logger/WinstonLoggerAdapte
3
3
. WinstonLoggerAdapter ;
4
4
const GridFSBucketAdapter = require ( '../lib/Adapters/Files/GridFSBucketAdapter' )
5
5
. GridFSBucketAdapter ;
6
- const GridStoreAdapter = require ( '../lib/Adapters/Files/GridStoreAdapter' ) . GridStoreAdapter ;
7
6
const Config = require ( '../lib/Config' ) ;
8
7
const FilesController = require ( '../lib/Controllers/FilesController' ) . default ;
9
8
const databaseURI = 'mongodb://localhost:27017/parse' ;
@@ -24,8 +23,8 @@ const mockAdapter = {
24
23
describe ( 'FilesController' , ( ) => {
25
24
it ( 'should properly expand objects' , done => {
26
25
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 ) ;
29
28
const result = filesController . expandFilesInObject ( config , function ( ) { } ) ;
30
29
31
30
expect ( result ) . toBeUndefined ( ) ;
@@ -88,19 +87,19 @@ describe('FilesController', () => {
88
87
89
88
it ( 'should add a unique hash to the file name when the preserveFileName option is false' , done => {
90
89
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 ( ) ) ;
94
93
const fileName = 'randomFileName.pdf' ;
95
94
const regexEscapedFileName = fileName . replace ( / \. / g, '\\$&' ) ;
96
- const filesController = new FilesController ( gridStoreAdapter , null , {
95
+ const filesController = new FilesController ( gridFSAdapter , null , {
97
96
preserveFileName : false ,
98
97
} ) ;
99
98
100
99
filesController . createFile ( config , fileName ) ;
101
100
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 (
104
103
`^.{32}_${ regexEscapedFileName } $`
105
104
) ;
106
105
@@ -109,42 +108,42 @@ describe('FilesController', () => {
109
108
110
109
it ( 'should not add a unique hash to the file name when the preserveFileName option is true' , done => {
111
110
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 ( ) ) ;
115
114
const fileName = 'randomFileName.pdf' ;
116
- const filesController = new FilesController ( gridStoreAdapter , null , {
115
+ const filesController = new FilesController ( gridFSAdapter , null , {
117
116
preserveFileName : true ,
118
117
} ) ;
119
118
120
119
filesController . createFile ( config , fileName ) ;
121
120
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 ) ;
124
123
125
124
done ( ) ;
126
125
} ) ;
127
126
128
127
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 ) ;
132
131
133
132
const result = await filesController . getMetadata ( ) ;
134
133
expect ( result ) . toEqual ( { } ) ;
135
134
} ) ;
136
135
137
136
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' ) ;
139
138
const fileName = 'foo/randomFileName.pdf' ;
140
- expect ( gridStoreAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
139
+ expect ( gridFSAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
141
140
done ( ) ;
142
141
} ) ;
143
142
144
143
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' ) ;
146
145
const fileName = 'foo/randomFileName.pdf' ;
147
- expect ( gridStoreAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
146
+ expect ( gridFSAdapter . validateFilename ( fileName ) ) . not . toBe ( null ) ;
148
147
done ( ) ;
149
148
} ) ;
150
149
} ) ;
0 commit comments