Skip to content

Commit

Permalink
Merge eaf006e into 08e82f7
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAribart committed Jun 14, 2021
2 parents 08e82f7 + eaf006e commit 53508c7
Show file tree
Hide file tree
Showing 9 changed files with 715 additions and 239 deletions.
4 changes: 1 addition & 3 deletions src/__tests__/entity.delete.unit.test.ts
Expand Up @@ -45,7 +45,6 @@ describe('delete', () => {
})

it('deletes the key from inputs (async)', async () => {
// @ts-expect-error 💥 TODO: Fix return type
const { TableName, Key } = await TestEntity.delete({ email: 'test-pk', sort: 'test-sk' })
expect(TableName).toBe('test-table')
expect(Key).toEqual({ pk: 'test-pk', sk: 'test-sk' })
Expand All @@ -63,7 +62,6 @@ describe('delete', () => {
})

it('filters out extra data (async)', async () => {
// @ts-expect-error 💥 TODO: Fix return type
let { TableName, Key } = await TestEntity.delete({
email: 'test-pk',
sort: 'test-sk',
Expand All @@ -82,7 +80,7 @@ describe('delete', () => {
})

it('coerces key values to correct types (async)', async () => {
// @ts-expect-error 💥 TODO: Fix return type + Support coerce keyword
// @ts-expect-error 💥 TODO: Support coerce keyword
let { TableName, Key } = await TestEntity.delete({ email: 1, sort: true })
expect(TableName).toBe('test-table')
expect(Key).toEqual({ pk: '1', sk: 'true' })
Expand Down
4 changes: 1 addition & 3 deletions src/__tests__/entity.get.unit.test.ts
Expand Up @@ -45,7 +45,6 @@ describe('get', () => {
})

it('gets the key from inputs (async)', async () => {
// @ts-expect-error 💥 TODO: Correct interface ?
const { TableName, Key } = await TestEntity.get({ email: 'test-pk', sort: 'test-sk' })
expect(TableName).toBe('test-table')
expect(Key).toEqual({ pk: 'test-pk', sk: 'test-sk' })
Expand All @@ -63,7 +62,6 @@ describe('get', () => {
})

it('filters out extra data (async)', async () => {
// @ts-expect-error 💥 TODO: Correct interface ?
let { TableName, Key } = await TestEntity.get({
email: 'test-pk',
sort: 'test-sk',
Expand All @@ -82,7 +80,7 @@ describe('get', () => {
})

it('coerces key values to correct types (async)', async () => {
// @ts-expect-error 💥 TODO: Correct interface ? + Support coerce keyword
// @ts-expect-error 💥 TODO: Support coerce keyword
let { TableName, Key } = await TestEntity.get({ email: 1, sort: true })
expect(TableName).toBe('test-table')
expect(Key).toEqual({ pk: '1', sk: 'true' })
Expand Down
24 changes: 24 additions & 0 deletions src/__tests__/entity.utils.unit.test.ts
@@ -0,0 +1,24 @@
import { shouldExecute, shouldParse } from '../classes/Entity'

describe('Entity - utils', () => {
it('should execute', () => {
expect(shouldExecute(true, true)).toBe(true)
expect(shouldExecute(true, false)).toBe(true)
expect(shouldExecute(undefined, true)).toBe(true)
})
it('should not execute', () => {
expect(shouldExecute(false, false)).toBe(false)
expect(shouldExecute(undefined, false)).toBe(false)
expect(shouldExecute(false, true)).toBe(false)
})
it('should parse', () => {
expect(shouldParse(true, true)).toBe(true)
expect(shouldParse(true, false)).toBe(true)
expect(shouldParse(undefined, true)).toBe(true)
})
it('should not parse', () => {
expect(shouldParse(false, false)).toBe(false)
expect(shouldParse(undefined, false)).toBe(false)
expect(shouldParse(false, true)).toBe(false)
})
})
3 changes: 0 additions & 3 deletions src/__tests__/parseMapping.unit.test.ts
Expand Up @@ -128,7 +128,6 @@ describe('parseMapping', () => {
})

it('parses partitionKey as string', async () => {
// @ts-expect-error 💥 TODO: Support GSIs
expect(parseMapping('attr', { type: 'string', partitionKey: 'GSI' }, track)).toEqual({
attr: { type: 'string', partitionKey: 'GSI', coerce: true }
})
Expand Down Expand Up @@ -178,7 +177,6 @@ describe('parseMapping', () => {
expect(() => {
parseMapping(
'attr',
// @ts-expect-error 💥 TODO: Support GSIs
{ type: 'string', partitionKey: 'GSI' },
Object.assign({}, track, { keys: { GSI: { partitionKey: 'GSIpk' } } })
)
Expand All @@ -200,7 +198,6 @@ describe('parseMapping', () => {
expect(() => {
parseMapping(
'attr',
// @ts-expect-error 💥 TODO: Support GSIs
{ type: 'string', sortKey: 'GSI' },
Object.assign({}, track, { keys: { GSI: { partitionKey: 'attr' } } })
)
Expand Down

0 comments on commit 53508c7

Please sign in to comment.