( write: (location: string, rawContent: any) => Promise<void>, supportsMergeableStore = false, isSynchronizer: 0 | 1 = 0, )
| 134 | let customPersisterChanges: Changes | MergeableChanges = [{}, {}, 1]; |
| 135 | |
| 136 | const getMockedCustom = ( |
| 137 | write: (location: string, rawContent: any) => Promise<void>, |
| 138 | supportsMergeableStore = false, |
| 139 | isSynchronizer: 0 | 1 = 0, |
| 140 | ): Persistable => ({ |
| 141 | autoLoadPause: 100, |
| 142 | getLocation: async (): Promise<string> => '', |
| 143 | getLocationMethod: ['getFoo', () => 'foo'], |
| 144 | getPersister: (store: Store) => { |
| 145 | customPersister = ''; |
| 146 | return createCustomPersister( |
| 147 | store, |
| 148 | async () => jsonParseWithUndefined(customPersister), |
| 149 | async (getContent, changes) => { |
| 150 | customPersister = jsonStringWithUndefined(getContent()); |
| 151 | customPersisterChanges = changes ?? [{}, {}, 1]; |
| 152 | }, |
| 153 | (listener) => { |
| 154 | customPersisterListener = listener; |
| 155 | return 1; |
| 156 | }, |
| 157 | () => (customPersisterListener = undefined), |
| 158 | undefined, |
| 159 | supportsMergeableStore ? 3 : 1, |
| 160 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 161 | // @ts-ignore |
| 162 | {getFoo: () => 'foo'}, |
| 163 | isSynchronizer, |
| 164 | ); |
| 165 | }, |
| 166 | get: async (): Promise<Content | void> => |
| 167 | jsonParseWithUndefined(customPersister), |
| 168 | set: (location: string, content: Content | MergeableContent): Promise<void> => |
| 169 | write(location, jsonStringWithUndefined(content)), |
| 170 | write, |
| 171 | del: async (): Promise<void> => { |
| 172 | customPersister = ''; |
| 173 | }, |
| 174 | getChanges: () => customPersisterChanges, |
| 175 | testMissing: true, |
| 176 | testAutoLoad: true, |
| 177 | }); |
| 178 | |
| 179 | const getMockedStorage = ( |
| 180 | storage: Storage, |
no test coverage detected
searching dependent graphs…