Skip to content

Commit

Permalink
test(stampy.spec): use string for questionId
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhender committed Jul 28, 2023
1 parent bf0995b commit 54304f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/mocks/coda-responses/refresh-coda-data-for-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as fs from 'fs'
import * as path from 'path'
import * as toml from 'toml'

export const questionIds = [8486]
export const questionIds = ['8486']

async function main(): Promise<void> {
const codaToken = readCodaToken()
Expand All @@ -18,7 +18,7 @@ async function main(): Promise<void> {
)
}

const getData = async (questionId: number, codaToken: string) => {
const getData = async (questionId: string, codaToken: string) => {
const options = {
headers: {
Authorization: `Bearer ${codaToken}`,
Expand All @@ -30,7 +30,7 @@ const getData = async (questionId: number, codaToken: string) => {
return JSON.stringify(body)
}

const writeFile = (questionId: number, data: string): Promise<void> => {
const writeFile = (questionId: string, data: string): Promise<void> => {
const filename = `question-${questionId}.json`
const filePath = path.join(__dirname, filename)

Expand Down
6 changes: 3 additions & 3 deletions app/server-utils/stampy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {AnswersRow, loadQuestionDetail} from '~/server-utils/stampy'
import question8486 from '~/mocks/coda-responses/question-8486.json'

export type questionData = [number, {items: AnswersRow[]}]
export const questions: Array<questionData> = [[8486, question8486]]
export type questionData = [string, {items: AnswersRow[]}]
export const questions: Array<questionData> = [['8486', question8486]]

describe('loadQuestionDetail', () => {
it.each<questionData>(questions)('can load question %i', async (questionId, questionData) => {
Expand All @@ -17,7 +17,7 @@ describe('loadQuestionDetail', () => {
})
.reply(200, questionData)

const questionDetail = await loadQuestionDetail('NEVER_RELOAD', questionId.toString())
const questionDetail = await loadQuestionDetail('NEVER_RELOAD', questionId)
const firstItem = questionData.items[0]
expect(questionDetail.data.status).toBe(firstItem.values.Status.name)
const linkUrl = new URL(firstItem.values.Link.url)
Expand Down

0 comments on commit 54304f4

Please sign in to comment.