2022-06-17 21:35:26 +02:00
|
|
|
import { ApiTokenType } from '../../types/models/api-token';
|
|
|
|
import { validateSchema } from '../validate';
|
|
|
|
import { ApiTokenSchema } from './api-token-schema';
|
|
|
|
|
2022-08-17 10:55:52 +02:00
|
|
|
const defaultData: ApiTokenSchema = {
|
|
|
|
secret: '',
|
|
|
|
username: '',
|
2023-05-19 09:07:23 +02:00
|
|
|
tokenName: '',
|
2022-08-17 10:55:52 +02:00
|
|
|
type: ApiTokenType.CLIENT,
|
|
|
|
environment: '',
|
|
|
|
projects: [],
|
|
|
|
expiresAt: '2022-01-01T00:00:00.000Z',
|
|
|
|
createdAt: '2022-01-01T00:00:00.000Z',
|
|
|
|
seenAt: '2022-01-01T00:00:00.000Z',
|
|
|
|
project: '',
|
|
|
|
};
|
|
|
|
|
2022-06-17 21:35:26 +02:00
|
|
|
test('apiTokenSchema', () => {
|
2022-08-17 10:55:52 +02:00
|
|
|
const data: ApiTokenSchema = { ...defaultData };
|
|
|
|
|
|
|
|
expect(
|
|
|
|
validateSchema('#/components/schemas/apiTokenSchema', data),
|
|
|
|
).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
2022-06-17 21:35:26 +02:00
|
|
|
test('apiTokenSchema empty', () => {
|
|
|
|
expect(
|
|
|
|
validateSchema('#/components/schemas/apiTokenSchema', {}),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|