Skip to content

Commit 4acac3b

Browse files
test(mapper): uncomment tests
1 parent a9dabb2 commit 4acac3b

File tree

4 files changed

+55
-43
lines changed

4 files changed

+55
-43
lines changed

src/mapper/mapper.spec.ts

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ describe('Mapper', () => {
222222
})
223223

224224
it('complex object', () => {
225-
type ObjType = { name: StringAttribute; age: NumberAttribute; children: ListAttribute }
225+
226+
interface ObjType{ name: StringAttribute; age: NumberAttribute; children: ListAttribute }
226227
const attrValue = <MapAttribute<ObjType>>toDbOne({
227228
name: 'Max',
228229
age: 35,
@@ -738,7 +739,6 @@ describe('Mapper', () => {
738739
})
739740

740741
describe('from db', () => {
741-
// FIXME TEST fix this test
742742
describe('model with complex property values (decorators)', () => {
743743
let product: Product
744744

@@ -826,37 +826,46 @@ describe('Mapper', () => {
826826
expect(Array.from(cities)[1]).toBe('bern')
827827
})
828828

829-
// it('awardWinningYears', () => {
830-
// expect(organization.awardWinningYears).toBeDefined();
831-
// expect(organization.awardWinningYears instanceof Set).toBeTruthy();
832-
//
833-
// const awardWinningYears: Set<number> = organization.awardWinningYears;
834-
// expect(awardWinningYears.size).toBe(3);
835-
// expect(Array.from(awardWinningYears)[0]).toBe(2002);
836-
// expect(Array.from(awardWinningYears)[1]).toBe(2015);
837-
// expect(Array.from(awardWinningYears)[2]).toBe(2017);
838-
// });
839-
//
840-
// it('mixedList', () => {
841-
// expect(organization.mixedList).toBeDefined();
842-
// expect(Array.isArray(organization.mixedList)).toBeTruthy();
843-
//
844-
// const mixedList: any[] = organization.mixedList;
845-
// expect(mixedList.length).toBe(3);
846-
// expect(mixedList[0]).toBe('sample');
847-
// expect(mixedList[1]).toBe(26);
848-
// expect(mixedList[2]).toBe(true);
849-
// });
850-
//
851-
// it('sortedSet', () => {
852-
// expect(organization.setWithComplexSorted).toBeDefined();
853-
// expect(organization.setWithComplexSorted instanceof Set).toBeTruthy();
854-
//
855-
// const sortedSet: Set<string> = organization.setWithComplexSorted;
856-
// expect(sortedSet.size).toBe(2);
857-
// expect(Array.from(sortedSet)[0]).toBe('1');
858-
// expect(Array.from(sortedSet)[1]).toBe('2');
859-
// });
829+
it('birthdays', () => {
830+
expect(organization.birthdays).toBeDefined()
831+
expect(organization.birthdays instanceof Set).toBeTruthy()
832+
833+
const birthdays: Set<Birthday> = organization.birthdays
834+
expect(birthdays.size).toBe(1)
835+
836+
const birthday: Birthday = Array.from(birthdays)[0]
837+
expect(birthday).toBeDefined()
838+
expect(birthday.date).toEqual(new Date('1958-04-13'))
839+
expect(Array.isArray(birthday.presents)).toBeTruthy()
840+
})
841+
842+
843+
it('awards', () => {
844+
expect(organization.awards).toBeDefined()
845+
expect(organization.awards instanceof Set).toBeTruthy()
846+
847+
const awards = organization.awards
848+
expect(awards.size).toBe(1)
849+
const award = Array.from(awards)[0]
850+
851+
expect(award).toBeDefined()
852+
expect(award).toBe('Best of Swiss Web')
853+
})
854+
855+
it('events', ()=>{
856+
expect(organization.events).toBeDefined()
857+
expect(organization.events instanceof Set).toBeTruthy()
858+
859+
const events = organization.events
860+
expect(events.size).toBe(1)
861+
862+
const event = Array.from(events)[0]
863+
864+
expect(event).toBeDefined()
865+
expect(typeof event).toBe('object')
866+
expect(event.name).toBe('yearly get together')
867+
expect(event.participants).toBe(125)
868+
})
860869
})
861870
})
862871
})

test/models/complex.model.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { DateProperty, Model, PartitionKey, Property, SortedSet, SortKey, Transient, TypedSet } from '../../src/dynamo-easy'
1+
import {
2+
DateProperty,
3+
Model,
4+
PartitionKey,
5+
Property,
6+
SortedSet,
7+
SortKey,
8+
Transient,
9+
TypedSet,
10+
} from '../../src/dynamo-easy'
211
import { NestedObject } from './nested-object.model'
312

413
@Model({ tableName: 'complex_model' })

test/models/model-with-indexes.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
GSISortKey,
66
LSISortKey,
77
Model,
8-
PartitionKey, Property,
8+
PartitionKey,
9+
Property,
910
SortKey,
1011
} from '../../src/dynamo-easy'
1112

test/models/real-world/order.model.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
// tslint:disable:max-classes-per-file
22

3-
import {
4-
CustomMapper,
5-
DateProperty,
6-
GSIPartitionKey,
7-
GSISortKey,
8-
Model,
9-
PartitionKey,
10-
} from '../../../src/dynamo-easy'
3+
import { CustomMapper, DateProperty, GSIPartitionKey, GSISortKey, Model, PartitionKey } from '../../../src/dynamo-easy'
114
import { FormId, FormIdsMapper } from './form-id.model'
125
import { FormType } from './form-type.enum'
136
import { OrderId, OrderIdMapper } from './order-id.model'

0 commit comments

Comments
 (0)