Skip to content

Commit

Permalink
Merge pull request #38 from NickBolles/master
Browse files Browse the repository at this point in the history
WIP: Parse into correct classes
  • Loading branch information
derbenoo authored Mar 15, 2020
2 parents 7bf2623 + f4f6b08 commit bbadb57
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions libs/ts-configurable/src/lib/configurable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,36 @@ describe('libs/config: @Configurable() decorator', () => {
delivered: false,
},
});
expect(config.order).toBeInstanceOf(OrderConfig);
});

it('Allows methods on properties that are classes themselves', () => {
class OrderConfig {
delivered = false;
isCompleted() {
return this.delivered;
}
}

@Configurable()
class PizzaConfig {
id = 1;
order = new OrderConfig();
}

expect(() => {
const _ = new PizzaConfig();
}).not.toThrow();

const config = new PizzaConfig();
expect(config).toEqual({
id: 1,
order: {
delivered: false,
},
});
expect(config.order).toBeInstanceOf(OrderConfig);
expect(config.order.isCompleted()).toBe(false);
});

/** Decryption */
Expand Down

0 comments on commit bbadb57

Please sign in to comment.