sdk-monorepo/test/data.test.ts

32 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2023-05-11 21:49:07 +03:00
import chai from 'chai'
import { ErrorUtils } from '@tornado/sdk-utils'
import { Cache, Files } from '@tornado/sdk-data'
2023-05-11 21:49:07 +03:00
const expect = chai.expect
describe('data', () => {
if (!process.env.EXPORT_TEST_DIRNAME)
throw ErrorUtils.getError('data.test.ts: no cache test dirname provided')
it(`Files.gzipSync: should be able to zip dir`, () => {
const filepath = Files.getCachePath(process.env.EXPORT_TEST_DIRNAME!)
Files.gzipSync(filepath, filepath)
})
it(`Files.gunzipSync: should be able to unzip dir`, () => {
const filepath = Files.getCachePath(process.env.EXPORT_TEST_DIRNAME!)
Files.gunzipSync(filepath, Files.getCachePath())
})
it(`Cache.jsonify: should be able to write db docs to json`, async () => {
const cache = new Cache.Base(process.env.EXPORT_TEST_DIRNAME!)
await cache.jsonify()
})
it(`Cache.zip: should be able to zip or load from zip ${process.env.EXPORT_TEST_DIRNAME}`, async () => {
2023-05-11 21:49:07 +03:00
const cache = new Cache.Base(process.env.EXPORT_TEST_DIRNAME!)
await cache.zip(undefined, true)
2023-05-11 21:49:07 +03:00
}).timeout(0)
})