Skip to content

Commit

Permalink
Add interests and activities to user profile schema
Browse files Browse the repository at this point in the history
  • Loading branch information
amorimjuliana authored Sep 23, 2020
1 parent 340c3fb commit 9124a2a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/schema/userSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ export const userProfileSchema = new ObjectType({
minLength: 1,
maxLength: 50,
}),
interests: new ArrayType({
maxItems: 30,
items: new StringType({
minLength: 1,
maxLength: 30,
}),
}),
activities: new ArrayType({
maxItems: 30,
items: new StringType({
minLength: 1,
maxLength: 30,
}),
}),
custom: new ObjectType({
propertyNames: new StringType({
maxLength: 50,
Expand Down
2 changes: 2 additions & 0 deletions src/trackingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ type UserProfile = {
company?: string,
companyUrl?: string,
jobTitle?: string,
interests?: string[],
activities?: string[],
custom?: {
[member: string]: Primitive | PrimitiveMap | PrimitiveArray,
},
Expand Down
2 changes: 2 additions & 0 deletions test/facade/trackerFacade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ describe('A tracker facade', () => {
company: 'Croct',
companyUrl: 'http://croct.com',
jobTitle: 'CEO',
interests: ['enterprise'],
activities: ['login'],
custom: {
integer: 1,
number: 1.2,
Expand Down
32 changes: 30 additions & 2 deletions test/schemas/userSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ describe('The user profile schema', () => {
[{companyUrl: `http://www.${'x'.repeat(185)}.com`}],
[{jobTitle: 'x'}],
[{jobTitle: 'x'.repeat(50)}],
[{interests: []}],
[{interests: new Array(30).fill('x')}],
[{activities: []}],
[{activities: new Array(30).fill('x')}],
[{
custom: {
integer: 1,
Expand Down Expand Up @@ -161,19 +165,43 @@ describe('The user profile schema', () => {
],
[{jobTitle: ''}, 'Expected at least 1 character at path \'/jobTitle\', actual 0.'],
[{jobTitle: 'x'.repeat(51)}, 'Expected at most 50 characters at path \'/jobTitle\', actual 51.'],
[
{interests: ['']},
'Expected at least 1 character at path \'/interests/0\', actual 0.',
],
[
{interests: ['x'.repeat(31)]},
'Expected at most 30 characters at path \'/interests/0\', actual 31.',
],
[
{interests: new Array(31).fill('x')},
'Expected at most 30 items at path \'/interests\', actual 31.',
],
[
{activities: ['']},
'Expected at least 1 character at path \'/activities/0\', actual 0.',
],
[
{activities: ['x'.repeat(31)]},
'Expected at most 30 characters at path \'/activities/0\', actual 31.',
],
[
{activities: new Array(31).fill('x')},
'Expected at most 30 items at path \'/activities\', actual 31.',
],
[
{custom: {longString: 'x'.repeat(101)}},
'Expected at most 100 characters at path \'/custom/longString\', actual 101.',
],
[
{custom: {looooooooooooooooooooooooooooooooooooooooooooongKey: 'x'}},
'Expected at most 50 characters at path '
+ '\'/custom/looooooooooooooooooooooooooooooooooooooooooooongKey\', actual 51.',
+ '\'/custom/looooooooooooooooooooooooooooooooooooooooooooongKey\', actual 51.',
],
[
{custom: {map: {looooooooooooooooooooooooooooooooooooooooooooongKey: 'x'}}},
'Expected at most 50 characters at path '
+ '\'/custom/map/looooooooooooooooooooooooooooooooooooooooooooongKey\', actual 51.',
+ '\'/custom/map/looooooooooooooooooooooooooooooooooooooooooooongKey\', actual 51.',
],
[
{custom: {'@foo': 1}},
Expand Down
4 changes: 4 additions & 0 deletions test/tracker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ describe('A tracker', () => {
company: 'Croct',
companyUrl: 'http://croct.com',
jobTitle: 'CEO',
interests: ['enterprise'],
activities: ['login'],
custom: {
integer: 1,
number: 1.2,
Expand Down Expand Up @@ -1001,6 +1003,8 @@ describe('A tracker', () => {
company: 'Croct',
companyUrl: 'http://croct.com',
jobTitle: 'CEO',
interests: ['enterprise'],
activities: ['login'],
custom: {
integer: 1,
number: 1.2,
Expand Down

0 comments on commit 9124a2a

Please sign in to comment.