Skip to content

Commit

Permalink
test: fix client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZerNico committed May 28, 2023
1 parent b9e040a commit 94167cc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/runtime/logto/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ import { App, EventHandler, Router, createApp, createRouter, toNodeListener } fr
import supertest, { SuperTest, Test } from 'supertest'
import { type InteractionMode } from '@logto/node'
import { LogtoClient } from './client'
import { LogtoNuxtConfig } from "../types"

const config: LogtoNuxtConfig = {
appId: 'app_id_value',
const config = {
appSecret: 'app_secret_value',
endpoint: 'https://logto.dev',
origin: 'http://localhost:3000',
basePath: '/api/logto',
cookieSecret: 'complex_password_at_least_32_characters_long',
cookieSecure: process.env.NODE_ENV === 'production',
}

const publicConfig = {
appId: 'app_id_value',
basePath: '/api/logto',
origin: 'http://localhost:3000',
}

const signInUrl = 'http://mock-logto-server.com/sign-in'

vi.mock('#imports', () => ({
useRuntimeConfig: () => {
return {
logto: config,
public: {
logto: publicConfig,
}
}
},
}))
Expand Down Expand Up @@ -56,7 +62,7 @@ vi.mock('@logto/node', () => ({
signIn()
}
signOut = async () => {
this.navigate(config.origin)
this.navigate(publicConfig.origin)
signOut()
}
handleSignInCallback = handleSignInCallback
Expand Down Expand Up @@ -112,7 +118,7 @@ describe('Nuxt LogtoClient', () => {

const result = await request.get('/api/logto/sign-in-callback')

expect(result.header.location).toBe(config.origin)
expect(result.header.location).toBe(publicConfig.origin)
expect(handleSignInCallback).toHaveBeenCalled()
expect(save).toHaveBeenCalled()
})
Expand All @@ -125,7 +131,7 @@ describe('Nuxt LogtoClient', () => {

const result = await request.get('/api/logto/sign-out')

expect(result.header.location).toBe(`${config.origin}`)
expect(result.header.location).toBe(`${publicConfig.origin}`)
expect(save).toHaveBeenCalled()
expect(signOut).toHaveBeenCalled()
})
Expand Down

0 comments on commit 94167cc

Please sign in to comment.