Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing Typescript integ tests after split #1639

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions integ-tests/typescript/tests/input-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,79 @@ describe('Basic Input/Output Tests', () => {
})

describe('Output Types', () => {
it('should work for all outputs', async () => {
it('single bool', async () => {
const input = 'test input'

const bool = await b.FnOutputBool(input)
expect(bool).toEqual(true)
})

it('single int', async () => {
const input = 'test input'
const int = await b.FnOutputInt(input)
expect(int).toEqual(5)
})

it('single class', async () => {
const input = 'test input'
const classs = await b.FnOutputClass(input)
expect(classs.prop1).not.toBeNull()
expect(classs.prop2).toEqual(540)
})

it('single class list', async () => {
const input = 'test input'
const list = await b.FnOutputClassList(input)
expect(list.length).toBeGreaterThan(0)
expect(list[0].prop1.length).toBeGreaterThan(0)
})

it('enum list', async () => {
const enumList = await b.FnEnumListOutput('input')
expect(enumList.length).toBe(2)
})

it('single class with enum', async () => {
const input = 'test input'
const classWEnum = await b.FnOutputClassWithEnum(input)
expect(['ONE', 'TWO']).toContain(classWEnum.prop2)
})

const classs = await b.FnOutputClass(input)
expect(classs.prop1).not.toBeNull()
expect(classs.prop2).toEqual(540)
it('optional list and map', async () => {
let res = await b.AllowedOptionals({ p: null, q: null })
expect(res).toEqual({ p: null, q: null })

res = await b.AllowedOptionals({ p: ['test'], q: { test: 'ok' } })
expect(res).toEqual({ p: ['test'], q: { test: 'ok' } })
})

it('single optional string', async () => {
const res = await b.FnNamedArgsSingleStringOptional()
expect(res).toContain('none')
})

it('single map string to string', async () => {
const res = await b.TestFnNamedArgsSingleMapStringToString({ lorem: 'ipsum', dolor: 'sit' })
expect(res).toHaveProperty('lorem', 'ipsum')
})

it('single map string to map', async () => {
const res = await b.TestFnNamedArgsSingleMapStringToMap({ lorem: { word: 'ipsum' }, dolor: { word: 'sit' } })
expect(res).toHaveProperty('lorem', { word: 'ipsum' })
})

it('literal int', async () => {
const int = await b.FnOutputLiteralInt('input')
expect(int).toEqual(5)
})

it('literal bool', async () => {
const bool = await b.FnOutputLiteralBool('input')
expect(bool).toEqual(false)
})

it('literal string', async () => {
const str = await b.FnOutputLiteralString('input')
expect(str).toEqual('example output')
})
})
})
Expand Down
138 changes: 0 additions & 138 deletions integ-tests/typescript/tests/integ-tests.test.ts.old
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ config()
jest.setTimeout(15_000)

describe('Integ tests', () => {
test('should handle invalid AWS region gracefully', async () => {
const response = b.TestAwsInvalidRegion('Write a nice short story about Dr. Pepper')

await expect(response).rejects.toMatchObject({
code: 'GenericFailure',
})
})

test('should handle invalid AWS access keygracefully', async () => {
const response = b.TestAwsInvalidAccessKey('Write a nice short story about Dr. Pepper')

await expect(response).rejects.toMatchObject({
code: 'GenericFailure',
})
})

test.skip('should handle invalid AWS profile gracefully', async () => {
const response = b.TestAwsInvalidProfile('Write a nice short story about Dr. Pepper')

Expand All @@ -62,128 +46,6 @@ describe('Integ tests', () => {
})
})

describe('should work for all inputs', () => {
it('single bool', async () => {
const res = await b.TestFnNamedArgsSingleBool(true)
expect(res).toEqual('true')
})

it('single string list', async () => {
const res = await b.TestFnNamedArgsSingleStringList(['a', 'b', 'c'])
expect(res).toContain('a')
expect(res).toContain('b')
expect(res).toContain('c')
})

it('optional list and map', async () => {
let res = await b.AllowedOptionals({ p: null, q: null })
expect(res).toEqual({ p: null, q: null })

res = await b.AllowedOptionals({ p: ['test'], q: { test: 'ok' } })
expect(res).toEqual({ p: ['test'], q: { test: 'ok' } })
})

it('single class', async () => {
console.log('calling with class')
const res = await b.TestFnNamedArgsSingleClass({
key: 'key',
key_two: true,
key_three: 52,
})
console.log('got response', res)
expect(res).toContain('52')
})

it('multiple classes', async () => {
const res = await b.TestMulticlassNamedArgs(
{
key: 'key',
key_two: true,
key_three: 52,
},
{
key: 'key',
key_two: true,
key_three: 64,
},
)
expect(res).toContain('52')
expect(res).toContain('64')
})

it('single enum list', async () => {
const res = await b.TestFnNamedArgsSingleEnumList([NamedArgsSingleEnumList.TWO])
expect(res).toContain('TWO')
})

it('single float', async () => {
const res = await b.TestFnNamedArgsSingleFloat(3.12)
expect(res).toContain('3.12')
})

it('single int', async () => {
const res = await b.TestFnNamedArgsSingleInt(3566)
expect(res).toContain('3566')
})

it('single optional string', async () => {
// TODO fix the fact it's required.
const res = await b.FnNamedArgsSingleStringOptional()
})

it('single map string to string', async () => {
const res = await b.TestFnNamedArgsSingleMapStringToString({ lorem: 'ipsum', dolor: 'sit' })
expect(res).toHaveProperty('lorem', 'ipsum')
})

it('single map string to class', async () => {
const res = await b.TestFnNamedArgsSingleMapStringToClass({ lorem: { word: 'ipsum' }, dolor: { word: 'sit' } })
expect(res).toHaveProperty('lorem', { word: 'ipsum' })
})

it('single map string to map', async () => {
const res = await b.TestFnNamedArgsSingleMapStringToMap({ lorem: { word: 'ipsum' }, dolor: { word: 'sit' } })
expect(res).toHaveProperty('lorem', { word: 'ipsum' })
})
})

it('should work for all outputs', async () => {
const a = 'a' // dummy
let bool = await b.FnOutputBool(a)
expect(bool).toEqual(true)

let int = await b.FnOutputInt(a)
expect(int).toEqual(5)

let literal_integer = await b.FnOutputLiteralInt(a)
expect(literal_integer).toEqual(5)

let literal_bool = await b.FnOutputLiteralBool(a)
expect(literal_bool).toEqual(false)

let literal_string = await b.FnOutputLiteralString(a)
expect(literal_string).toEqual('example output')

const list = await b.FnOutputClassList(a)
console.log(list);
expect(list.length).toBeGreaterThan(0)
assert(list[0].prop1.length > 0)

const classWEnum = await b.FnOutputClassWithEnum(a)
expect(['ONE', 'TWO']).toContain(classWEnum.prop2)

const classs = await b.FnOutputClass(a)
expect(classs.prop1).not.toBeNull()
// Actually select 540
expect(classs.prop2).toEqual(540)

// enum list output
const enumList = await b.FnEnumListOutput(a)
expect(enumList.length).toBe(2)

const myEnum = await b.FnEnumOutput(a)
})

it('works with retries1', async () => {
try {
await b.TestRetryConstant()
Expand Down
Loading