Skip to content
/ jest Public
forked from jestjs/jest

Commit

Permalink
Adding Symbols support to jest (jestjs#1948)
Browse files Browse the repository at this point in the history
* Adding Symbols support to jest

* Moving test inside jest-mock-test

* Update index.js
  • Loading branch information
kentaromiura authored and cpojer committed Oct 20, 2016
1 parent 6328bdb commit 96934d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/jest-mock/src/__tests__/jest-mock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ describe('moduleMocker', () => {
});

it('mocks constant values', () => {
const metadata = moduleMocker.getMetadata(Symbol.for('bowties.are.cool'));
expect(metadata.value).toEqual(Symbol.for('bowties.are.cool'));
expect(moduleMocker.getMetadata('banana').value).toEqual('banana');
expect(moduleMocker.getMetadata(27).value).toEqual(27);
expect(moduleMocker.getMetadata(false).value).toEqual(false);
Expand Down
7 changes: 6 additions & 1 deletion packages/jest-mock/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ function getType(ref?: any): string|null {
return 'array';
} else if (isA('Object', ref)) {
return 'object';
} else if (isA('Number', ref) || isA('String', ref) || isA('Boolean', ref)) {
} else if (
isA('Number', ref) ||
isA('String', ref) ||
isA('Boolean', ref) ||
isA('Symbol', ref)
) {
return 'constant';
} else if (isA('Map', ref) || isA('WeakMap', ref) || isA('Set', ref)) {
return 'collection';
Expand Down

0 comments on commit 96934d2

Please sign in to comment.