mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 05:42:30 +03:00
e516e0db23
- [x] separates modules into `fundamental`, `core`, `plugins` - [x] optional modules with `@OptionalModule` decorator to install modules with requirements met(`requires`, `if`) - [x] `module.contributesTo` defines optional features that will be enabled if module registered - [x] `AFFiNE.plugins.use('payment', {})` to enable a optional/plugin module - [x] `PaymentModule` is the first plugin module - [x] GraphQLSchema will not be generated for non-included modules - [x] Frontend can use `ServerConfigType` query to detect which features are enabled - [x] override existing provider globally
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
/// <reference types="../src/global.d.ts" />
|
|
|
|
import { TestingModule } from '@nestjs/testing';
|
|
import ava, { type TestFn } from 'ava';
|
|
|
|
import { CacheModule } from '../src/fundamentals/cache';
|
|
import { SessionModule, SessionService } from '../src/fundamentals/session';
|
|
import { createTestingModule } from './utils';
|
|
|
|
const test = ava as TestFn<{
|
|
session: SessionService;
|
|
module: TestingModule;
|
|
}>;
|
|
|
|
test.beforeEach(async t => {
|
|
const module = await createTestingModule({
|
|
imports: [CacheModule, SessionModule],
|
|
});
|
|
const session = module.get(SessionService);
|
|
t.context.module = module;
|
|
t.context.session = session;
|
|
});
|
|
|
|
test.afterEach.always(async t => {
|
|
await t.context.module.close();
|
|
});
|
|
|
|
test('should be able to set session', async t => {
|
|
const { session } = t.context;
|
|
await session.set('test', 'value');
|
|
t.is(await session.get('test'), 'value');
|
|
});
|
|
|
|
test('should be expired by ttl', async t => {
|
|
const { session } = t.context;
|
|
await session.set('test', 'value', 100);
|
|
t.is(await session.get('test'), 'value');
|
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
t.is(await session.get('test'), undefined);
|
|
});
|