diff options
author | Xianny <8582774+xianny@users.noreply.github.com> | 2019-01-09 05:50:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-09 05:50:51 +0800 |
commit | 27fc640a9eae70813e9f02cda2c27a4509a04591 (patch) | |
tree | 487721d8f59a978e23bb0e5d35b573eae7ec6b0a /packages/pipeline/test/entities | |
parent | 4689f20b86333d74fa0ccd45b23c560a0a0361b5 (diff) | |
download | dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar.gz dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar.bz2 dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar.lz dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar.xz dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.tar.zst dexon-sol-tools-27fc640a9eae70813e9f02cda2c27a4509a04591.zip |
fetch and save copper (#1472)
Fetch and save Copper CRM
Diffstat (limited to 'packages/pipeline/test/entities')
-rw-r--r-- | packages/pipeline/test/entities/copper_test.ts | 54 | ||||
-rw-r--r-- | packages/pipeline/test/entities/util.ts | 4 |
2 files changed, 56 insertions, 2 deletions
diff --git a/packages/pipeline/test/entities/copper_test.ts b/packages/pipeline/test/entities/copper_test.ts new file mode 100644 index 000000000..2543364e6 --- /dev/null +++ b/packages/pipeline/test/entities/copper_test.ts @@ -0,0 +1,54 @@ +import 'mocha'; +import 'reflect-metadata'; + +import { + CopperActivity, + CopperActivityType, + CopperCustomField, + CopperLead, + CopperOpportunity, +} from '../../src/entities'; +import { createDbConnectionOnceAsync } from '../db_setup'; +import { + ParsedActivities, + ParsedActivityTypes, + ParsedCustomFields, + ParsedLeads, + ParsedOpportunities, +} from '../fixtures/copper/parsed_entities'; +import { chaiSetup } from '../utils/chai_setup'; + +import { testSaveAndFindEntityAsync } from './util'; + +chaiSetup.configure(); + +describe('Copper entities', () => { + describe('save and find', async () => { + it('Copper lead', async () => { + const connection = await createDbConnectionOnceAsync(); + const repository = connection.getRepository(CopperLead); + ParsedLeads.forEach(async entity => testSaveAndFindEntityAsync(repository, entity)); + }); + it('Copper activity', async () => { + const connection = await createDbConnectionOnceAsync(); + const repository = connection.getRepository(CopperActivity); + ParsedActivities.forEach(async entity => testSaveAndFindEntityAsync(repository, entity)); + }); + // searching on jsonb fields is broken in typeorm + it.skip('Copper opportunity', async () => { + const connection = await createDbConnectionOnceAsync(); + const repository = connection.getRepository(CopperOpportunity); + ParsedOpportunities.forEach(async entity => testSaveAndFindEntityAsync(repository, entity)); + }); + it('Copper activity type', async () => { + const connection = await createDbConnectionOnceAsync(); + const repository = connection.getRepository(CopperActivityType); + ParsedActivityTypes.forEach(async entity => testSaveAndFindEntityAsync(repository, entity)); + }); + it('Copper custom field', async () => { + const connection = await createDbConnectionOnceAsync(); + const repository = connection.getRepository(CopperCustomField); + ParsedCustomFields.forEach(async entity => testSaveAndFindEntityAsync(repository, entity)); + }); + }); +}); diff --git a/packages/pipeline/test/entities/util.ts b/packages/pipeline/test/entities/util.ts index 043a3b15d..42df23a4a 100644 --- a/packages/pipeline/test/entities/util.ts +++ b/packages/pipeline/test/entities/util.ts @@ -15,9 +15,9 @@ const expect = chai.expect; * @param entity An instance of a TypeORM entity which will be saved/retrieved from the database. */ export async function testSaveAndFindEntityAsync<T>(repository: Repository<T>, entity: T): Promise<void> { - // Note(albrow): We are forced to use an 'as any' hack here because + // Note(albrow): We are forced to use an 'any' hack here because // TypeScript complains about stack depth when checking the types. - await repository.save(entity as any); + await repository.save<any>(entity); const gotEntity = await repository.findOneOrFail({ where: entity, }); |