-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* define entity type annotation * add test classes * define entity type constructor * define annotations * use superagent instead of axios (#18) * use superagent instead of axios * 2.13.0 * include original error for futher processing * Add type renderer (#19) * add type renderer * render type declarations * sort exported entity types * fix build * implement client-cli * 2.14.0 * add file schema renderer (#20) * add file schema renderer * 2.14.1 * test entity annotations * 2.14.2
- Loading branch information
1 parent
a60db70
commit eff55db
Showing
5 changed files
with
164 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import {EdmSchema} from '@themost/client'; | ||
import {TestContext} from './TestUtils'; | ||
|
||
class Thing { | ||
id?: number; | ||
name?: string; | ||
description?: string; | ||
createdBy?: number; | ||
modifiedBy?: number; | ||
dateCreated?: Date; | ||
dateModified?: Date; | ||
sameAs?: string; | ||
url?: string; | ||
image?: string; | ||
additionalType?: string; | ||
identifier?: string; | ||
alternateName?: string; | ||
disambiguatingDescription?: string; | ||
} | ||
|
||
@EdmSchema.entitySet('Products') | ||
class Product extends Thing { | ||
model?: string; | ||
productID?: string; | ||
category?: string; | ||
releaseDate?: Date; | ||
discontinued?: boolean; | ||
price?: number; | ||
isRelatedTo?: Product | number; | ||
isSimilarTo?: Product | number; | ||
} | ||
|
||
@EdmSchema.entityType('Order') | ||
class Order extends Thing { | ||
orderDate?: Date; | ||
customer?: Person | number; | ||
orderedItem?: Product | number; | ||
} | ||
|
||
@EdmSchema.entityType() | ||
class Person extends Thing { | ||
|
||
} | ||
|
||
describe('EdmSchema', () => { | ||
|
||
let context: TestContext; | ||
beforeAll(async () => { | ||
context = new TestContext(); | ||
await context.authenticate(); | ||
}); | ||
|
||
it('should define entity set annotation', () => { | ||
const annotation = Product as unknown as { | ||
EntitySet: { | ||
name: string | ||
} | ||
} | ||
expect(annotation.EntitySet).toBeTruthy(); | ||
expect(annotation.EntitySet.name).toEqual('Products'); | ||
}); | ||
|
||
it('should define entity type annotation', () => { | ||
const annotation = Order as unknown as { | ||
Entity: { | ||
name: string | ||
} | ||
} | ||
expect(annotation.Entity).toBeTruthy(); | ||
expect(annotation.Entity.name).toEqual('Order'); | ||
}); | ||
|
||
it('should define entity type annotation from class', () => { | ||
const annotation = Person as unknown as { | ||
Entity: { | ||
name: string | ||
} | ||
} | ||
expect(annotation.Entity).toBeTruthy(); | ||
expect(annotation.Entity.name).toEqual('Person'); | ||
}); | ||
|
||
it('should get items by using class', async () => { | ||
const items = await context.model(Product).where<Product>((x) => x.category === 'Laptops').getItems(); | ||
expect(items).toBeTruthy(); | ||
expect(items.length).toBeTruthy(); | ||
}); | ||
}); |