"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const database_init_1 = __importDefault(require("../helpers/database-init"));
const no_logger_1 = __importDefault(require("../../fixtures/no-logger"));
const api_token_1 = require("../../../lib/types/models/api-token");
let stores;
let db;
beforeAll(async () => {
    db = await (0, database_init_1.default)('api_token_store_serial', no_logger_1.default);
    stores = db.stores;
});
afterAll(async () => {
    await db.destroy();
});
test('get token is undefined when not exist', async () => {
    const token = await stores.apiTokenStore.get('abcde123');
    expect(token).toBeUndefined();
});
test('get token returns the token when exists', async () => {
    const newToken = await stores.apiTokenStore.insert({
        secret: 'abcde321',
        environment: 'default',
        type: api_token_1.ApiTokenType.ADMIN,
        projects: [],
        tokenName: 'admin-test-token',
    });
    const foundToken = await stores.apiTokenStore.get('abcde321');
    expect(foundToken).toBeDefined();
    expect(foundToken.secret).toBe(newToken.secret);
    expect(foundToken.environment).toBe(newToken.environment);
    expect(foundToken.tokenName).toBe(newToken.tokenName);
    expect(foundToken.type).toBe(newToken.type);
});
//# sourceMappingURL=api-token-store.e2e.test.js.map