-
-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix readme + exception on wrong storage
.
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/puppeteer-extra-plugin-session-persistence/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/puppeteer-extra-plugin-session-persistence/src/types.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import test from 'ava'; | ||
import { createStorage, StorageConfig } from './types'; | ||
import { RedisStorage } from './storage/redisStorage'; | ||
import { FileSystemStorage } from './storage/fileSystemStorage'; | ||
import { InMemoryStorage } from './storage/inMemoryStorage'; | ||
|
||
test('createStorage should create RedisStorage instance', (t) => { | ||
const config: StorageConfig = { | ||
name: RedisStorage.name.toLowerCase(), | ||
options: { | ||
host: 'localhost', | ||
port: 6379, | ||
password: 'password', | ||
}, | ||
}; | ||
|
||
const storage = createStorage(config); | ||
t.true(storage instanceof RedisStorage); | ||
}); | ||
|
||
test('createStorage should create FileSystemStorage instance', (t) => { | ||
const config: StorageConfig = { | ||
name: FileSystemStorage.name.toLowerCase(), | ||
options: { | ||
localStorageDataFile: 'localStorageData.json', | ||
cookiesFile: 'cookies.json', | ||
}, | ||
}; | ||
|
||
const storage = createStorage(config); | ||
t.true(storage instanceof FileSystemStorage); | ||
}); | ||
|
||
test('createStorage should create InMemoryStorage instance', (t) => { | ||
const config: StorageConfig = { | ||
name: InMemoryStorage.name.toLowerCase(), | ||
options: undefined, | ||
}; | ||
|
||
const storage = createStorage(config); | ||
t.true(storage instanceof InMemoryStorage); | ||
}); | ||
|
||
test('createStorage should throw an error for unknown storage name', (t) => { | ||
const config: StorageConfig = { | ||
name: 'unknown', | ||
options: undefined, | ||
}; | ||
|
||
const error = t.throws(() => { | ||
createStorage(config); | ||
}); | ||
|
||
t.is(error.message, 'Unknown storage name: unknown'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters