Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored and astrobot-houston committed Feb 28, 2025
1 parent b5dabe9 commit 9c7afbe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/astro/test/types/session-data.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import "./session-env";
import './session-env';
import { describe, it } from 'node:test';
import { expectTypeOf } from 'expect-type';
import type { AstroCookies, ResolvedSessionConfig } from '../../dist/types/public/index.js';
import { AstroSession } from '../../dist/core/session.js';
import type { AstroCookies, ResolvedSessionConfig } from '../../dist/types/public/index.js';

const defaultMockCookies = {
set: () => {},
delete: () => {},
get: () => 'astro cookie',
};


const defaultConfig: ResolvedSessionConfig<'memory'> = {
driver: 'memory',
cookie: 'test-session',
Expand All @@ -26,13 +25,12 @@ function createSession() {
describe('Session', () => {
it('Types session.get return values', () => {
const session = createSession();

expectTypeOf(session.get('value')).resolves.toEqualTypeOf<string | undefined>();

expectTypeOf(session.get('cart')).resolves.toEqualTypeOf<Array<string> | undefined>();

expectTypeOf(session.get('unknown')).resolves.toEqualTypeOf<any>();

});

it('Types session.set arguments', () => {
Expand All @@ -44,10 +42,8 @@ describe('Session', () => {

// Testing invalid types
// @ts-expect-error This should fail because the value is not a string
expectTypeOf(session.set('value', 1)).toEqualTypeOf<void>();
expectTypeOf(session.set('value', 1)).toEqualTypeOf<void>();
// @ts-expect-error This should fail because the value is not an array
expectTypeOf(session.set('cart', 'invalid')).toEqualTypeOf<void>();
expectTypeOf(session.set('cart', 'invalid')).toEqualTypeOf<void>();
});

});

0 comments on commit 9c7afbe

Please sign in to comment.