Permalink
Browse files

fix(test): Fixed broken tests

Product doesn't have custom names anymore and does not interfere with Unit of Work.
  • Loading branch information...
Raphaela Protásio
Raphaela Protásio committed Oct 29, 2016
1 parent 5b5cc7d commit 6722c654edf339508f4526c4e601b8126170b56b
Showing with 24 additions and 20 deletions.
  1. +24 −20 test/unit/Mapping.spec.ts
@@ -132,21 +132,6 @@ describe('Mapping', () => {
});
describe('.entity()', () => {
it('should map custom options for an entity', () => {
let mapping = getMapping(Product);
let options = {
name : 'entity_custom_name',
tableName: 'custom_table_name',
store : 'defaultStore'
};
mapping.entity(options);
assert.strictEqual(mapping.mapping.fetch('entity.name'), options.name);
assert.strictEqual(mapping.mapping.fetch('entity.tableName'), options.tableName);
assert.strictEqual(mapping.mapping.fetch('entity.store'), options.store);
});
it('should map entity with default options', () => {
let wetland = new Wetland({entities: [FooEntity]});
let mapping = wetland.getEntityManager().getMapping(FooEntity);
@@ -158,6 +143,22 @@ describe('Mapping', () => {
assert.strictEqual(mapping.mapping.fetch('entity.tableName'), 'fooentity');
assert.isNull(mapping.mapping.fetch('entity.store'));
});
it('should map custom options for an entity', () => {
let wetland = new Wetland({entities: [FooEntity]});
let mapping = wetland.getEntityManager().getMapping(FooEntity);
let options = {
name : 'foo_custom_name',
tableName: 'custom_table_name',
store : 'myStore'
};
mapping.entity(options);
assert.strictEqual(mapping.mapping.fetch('entity.name'), options.name);
assert.strictEqual(mapping.mapping.fetch('entity.tableName'), options.tableName);
assert.strictEqual(mapping.mapping.fetch('entity.store'), options.store);
});
it('should map an entity with default names set to underscore', () => {
let mapping = getMapping(ToUnderscore);
@@ -272,25 +273,28 @@ describe('Mapping', () => {
describe('.getEntityName()', () => {
it('should get the name of the entity', () => {
let mapping = getMapping(Product);
let wetland = new Wetland({entities: [FooEntity]});
let mapping = wetland.getEntityManager().getMapping(FooEntity);
assert.strictEqual(mapping.getEntityName(), 'entity_custom_name');
assert.strictEqual(mapping.getEntityName(), 'foo_custom_name');
});
});
describe('.getTableName()', () => {
it('should get the name of the table', () => {
let mapping = getMapping(Product);
let wetland = new Wetland({entities: [FooEntity]});
let mapping = wetland.getEntityManager().getMapping(FooEntity);
assert.strictEqual(mapping.getTableName(), 'custom_table_name');
});
});
describe('.getStoreName()', () => {
it('should get the store mapped to this entity', () => {
let mapping = getMapping(Product);
let wetland = new Wetland({entities: [FooEntity]});
let mapping = wetland.getEntityManager().getMapping(FooEntity);
assert.strictEqual(mapping.getStoreName(), 'defaultStore');
assert.strictEqual(mapping.getStoreName(), 'myStore');
});
});

0 comments on commit 6722c65

Please sign in to comment.