Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
have additional empty string test
  • Loading branch information
eduardomourar committed Oct 24, 2020
commit 73afc2d01d7d69d890f3ee57da18c21730c4ede9
2 changes: 2 additions & 0 deletions src/log-delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ export class LoggerProxy implements Logger {
private readonly queue = new Array<PromiseFunction>();

constructor(defaultOptions: InspectOptions = {}) {
// Allow passing Node.js inspect options,
// and change default depth from 4 to 10
inspect.defaultOptions = {
...inspect.defaultOptions,
depth: 10,
Expand Down
1 change: 1 addition & 0 deletions tests/data/sample-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export class SerializableModel extends BaseModel {
public static readonly TYPE_NAME: string = 'Organization::Service::Serializable';

@Expose() somekey?: Optional<string>;
@Expose() somestring?: Optional<string>;
@Expose() someotherkey?: Optional<string>;
@Expose({ name: 'SomeInt' })
@Transform((value, obj) => transformValue(Integer, 'someint', value, obj), {
Expand Down
5 changes: 4 additions & 1 deletion tests/lib/interface.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ describe('when getting interface', () => {
test('base resource model serialize', () => {
const model = SerializableModel.deserialize({
somekey: 'a',
somestring: '',
someotherkey: null,
someint: null,
});
const serialized = JSON.parse(JSON.stringify(model));
expect(Object.keys(serialized).length).toBe(1);
expect(Object.keys(serialized).length).toBe(2);
expect(serialized.somekey).toBe('a');
expect(serialized.somestring).toBe('');
expect(serialized.someotherkey).not.toBeDefined();
});

Expand Down
2 changes: 2 additions & 0 deletions tests/lib/log-delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CloudWatchLogs, {
} from 'aws-sdk/clients/cloudwatchlogs';
import S3, { ListObjectsV2Output } from 'aws-sdk/clients/s3';
import awsUtil from 'aws-sdk/lib/util';
import { inspect } from 'util';

import { SessionProxy } from '../../src/proxy';
import { MetricsPublisherProxy } from '../../src/metrics';
Expand Down Expand Up @@ -1213,6 +1214,7 @@ describe('when delivering logs', () => {
loggerProxy.log('timestamp: [%s]', new Date('2020-01-03'));
loggerProxy.log('timestamp: [%s]', new Date('2020-01-04'));
expect(loggerProxy['queue'].length).toBe(9);
expect(inspect.defaultOptions.depth).toBe(8);
await loggerProxy.processQueue();

expect(cloudWatchLogger['logStreamName']).toBe(LOG_STREAM_NAME);
Expand Down
6 changes: 4 additions & 2 deletions tests/lib/recast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('when recasting objects', () => {
ListListInt: [['1', '2', '3', '']],
ListSetInt: [['1', '2', '3']],
ASet: ['1', '2', '3'],
AnotherSet: ['a', 'b', 'c'],
AnotherSet: ['a', 'b', 'c', ''],
AFreeformDict: { somekey: 'somevalue', someotherkey: '1' },
ANumberDict: { key: '52.76' },
AnInt: '1',
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('when recasting objects', () => {
ListListInt: [[1, 2, 3, null]],
ListListAny: [[{ key: 'val' }]],
ASet: new Set(['1', '2', '3']),
AnotherSet: new Set(['a', 'b', 'c']),
AnotherSet: new Set(['a', 'b', 'c', '']),
AFreeformDict: new Map([
['somekey', 'somevalue'],
['someotherkey', '1'],
Expand Down Expand Up @@ -147,8 +147,10 @@ describe('when recasting objects', () => {
const bool = recastPrimitive(Boolean, k, v);
const num = recastPrimitive(Number, k, v);
const int = recastPrimitive(BigInt, k, v);
const string = recastPrimitive(String, k, v);
expect(bool).toBeNull();
expect(num).toBeNull();
expect(int).toBeNull();
expect(string).toBe('');
});
});