Skip to content

Commit

Permalink
fix(serializers): revert partially changes in ng-snapshot (#1150)
Browse files Browse the repository at this point in the history
Closes #1148
  • Loading branch information
ahnpnl authored Nov 8, 2021
1 parent 51e432c commit 44b3b77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/__tests__/ng-snapshot.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ngSnapshot from '../serializers/ng-snapshot';

describe('ng-snapshot', () => {
test('should return true when matching the condition', () => {
expect(ngSnapshot.test({ componentRef: 'foo' })).toBe(true);
});

test.each([undefined, null, 1, {}])('should return false when not matching the condition', (value) => {
expect(ngSnapshot.test(value)).toBe(false);
});
});
2 changes: 1 addition & 1 deletion src/serializers/ng-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const print = (fixture: unknown, print: Printer, indent: Indent, opts: PluginOpt

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
const test = (val: any): boolean =>
typeof val === 'object' && Object.prototype.hasOwnProperty.call(val, 'componentRef');
!!val && typeof val === 'object' && Object.prototype.hasOwnProperty.call(val, 'componentRef');

export = {
print,
Expand Down

0 comments on commit 44b3b77

Please sign in to comment.