1- const defaultContentTypes = require ( './content-types-list' )
1+ const defaultContentTypes = require ( '../__tests__/utils /content-types-list' )
22
33/**
44 * @param {object } config
55 * @param {object } [config.restaurantConfig]
66 * @param {object } [config.aboutConfig]
77 * @param {object } [config.contentTypes]
88 */
9- function createFakeStrapi ( {
9+ function createStrapiMock ( {
1010 restaurantConfig = { } ,
1111 aboutConfig = { } ,
1212 contentTypes,
1313} ) {
1414 contentTypes = contentTypes || defaultContentTypes
1515
16- const fakePlugin = jest . fn ( ( ) => ( {
17- service : fakePluginService ,
16+ const mockPlugin = jest . fn ( ( ) => ( {
17+ service : mockPluginService ,
1818 } ) )
1919
20- const fakeActionInBatches = jest . fn ( ( ) => {
20+ const mockActionInBatches = jest . fn ( ( ) => {
2121 return [ { id : '1' } ]
2222 } )
2323
24- const fakeAddIndexedContentType = jest . fn ( ( ) => { } )
24+ const mockAddIndexedContentType = jest . fn ( ( ) => { } )
2525
26- const fakePluginService = jest . fn ( ( ) => {
26+ const mockPluginService = jest . fn ( ( ) => {
2727 return {
2828 getContentTypesUid : ( ) => [ 'restaurant' , 'about' ] ,
2929 getCollectionName : ( { contentType } ) => contentType ,
@@ -33,20 +33,20 @@ function createFakeStrapi({
3333 ApiKeyIsFromConfigFile : true ,
3434 HostIsFromConfigFile : true ,
3535 } ) ,
36- actionInBatches : fakeActionInBatches ,
37- addIndexedContentType : fakeAddIndexedContentType ,
36+ actionInBatches : mockActionInBatches ,
37+ addIndexedContentType : mockAddIndexedContentType ,
3838 subscribeContentType : ( ) => {
3939 return
4040 } ,
4141 }
4242 } )
4343
44- const fakeLogger = {
44+ const mockLogger = {
4545 error : jest . fn ( ( ) => { } ) ,
4646 warn : jest . fn ( ( ) => { } ) ,
4747 }
4848
49- const fakeConfig = {
49+ const mockConfig = {
5050 get : jest . fn ( ( ) => {
5151 return {
5252 restaurant : restaurantConfig ,
@@ -55,39 +55,39 @@ function createFakeStrapi({
5555 } ) ,
5656 }
5757
58- const fakeFindWithCount = jest . fn ( ( ) => {
58+ const mockFindWithCount = jest . fn ( ( ) => {
5959 return 1
6060 } )
61- const fakeDb = {
61+ const mockDb = {
6262 query : jest . fn ( ( ) => ( {
63- count : fakeFindWithCount ,
63+ count : mockFindWithCount ,
6464 } ) ) ,
6565 }
6666
67- const fakeFindMany = jest . fn ( ( ) => {
67+ const mockFindMany = jest . fn ( ( ) => {
6868 return [ { id : 1 } ]
6969 } )
7070
71- const fakeFindOne = jest . fn ( ( ) => {
71+ const mockFindOne = jest . fn ( ( ) => {
7272 return [ { id : 1 } ]
7373 } )
7474
75- const fakeEntityService = {
76- findMany : fakeFindMany ,
77- findOne : fakeFindOne ,
75+ const mockEntityService = {
76+ findMany : mockFindMany ,
77+ findOne : mockFindOne ,
7878 }
7979
80- const fakeStrapi = {
81- log : fakeLogger ,
82- plugin : fakePlugin ,
80+ const mockStrapi = {
81+ log : mockLogger ,
82+ plugin : mockPlugin ,
8383 contentTypes,
84- config : fakeConfig ,
85- db : fakeDb ,
86- entityService : fakeEntityService ,
84+ config : mockConfig ,
85+ db : mockDb ,
86+ entityService : mockEntityService ,
8787 }
88- return fakeStrapi
88+ return mockStrapi
8989}
9090
9191module . exports = {
92- createFakeStrapi ,
92+ createStrapiMock ,
9393}
0 commit comments