File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ export class ParseOffline {
134134
135135 /**
136136 * Tests if results are still valid
137+ * @param cachedResults A CachedResults object
138+ * @param maxAge The maximum age of the results in milliseconds
137139 */
138140 static areCachedResultsValid (
139141 cachedResults : CachedResults , maxAge : number ,
@@ -144,13 +146,14 @@ export class ParseOffline {
144146
145147 /**
146148 * Saves an image with the given url
147- * @param imgUrl
149+ * @param imgUrl The url of the image to save
150+ * @param worker A previously created service worker in your app
148151 */
149- static saveImageToCache ( imgUrl : string , worker : Worker ) : Promise < any > {
152+ /* static saveImageToCache(imgUrl: string, worker: Worker): Promise<any> {
150153 return new Promise((resolve, reject) => {
151154 worker.postMessage(imgUrl);
152155 worker.onmessage = resolve;
153156 worker.onerror = reject;
154157 });
155- }
158+ } */
156159}
Original file line number Diff line number Diff line change 11import * as Parse from 'parse/node' ;
22import { ParseOffline } from '../src/ParseOffline' ;
33import { CachedResults } from '../src/CachedResults' ;
4+ import * as moment from 'moment' ;
45
56const obj = new Parse . Object ( 'Test' ) ;
67obj . set ( 'testKey' , 1 ) ;
@@ -84,3 +85,16 @@ describe('#getResultsFromTheLocalStorage', () => {
8485 expect ( results . results ) . toEqual ( [ ] ) ;
8586 } ) ;
8687} ) ;
88+
89+ describe ( '#areCachedResultsValid' , ( ) => {
90+ test ( 'should say results are not valid' , ( ) => {
91+ const results = new CachedResults ( [ ] , moment ( ) . subtract ( 3 , 'day' ) . toDate ( ) ) ;
92+ expect ( ParseOffline . areCachedResultsValid ( results , 3000 ) ) . toBe ( false ) ;
93+ } ) ;
94+
95+ test ( 'should say results are valid' , ( ) => {
96+ const ONE_WEEK = 1000 * 60 * 60 * 24 * 7 ;
97+ const results = new CachedResults ( [ ] , moment ( ) . toDate ( ) ) ;
98+ expect ( ParseOffline . areCachedResultsValid ( results , ONE_WEEK ) ) . toBe ( true ) ;
99+ } ) ;
100+ } ) ;
You can’t perform that action at this time.
0 commit comments