Skip to content

Commit

Permalink
fix: fix typo and add tests for weak map/set
Browse files Browse the repository at this point in the history
  • Loading branch information
janvennemann authored and sgtcoolguy committed Oct 3, 2019
1 parent 7f19662 commit bc9faba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Expand Up @@ -196,11 +196,11 @@ export function isUint32Array(value) {
}

export function isWeakMap(value) {
return checkPrototype(value, 'WekMap');
return checkPrototype(value, 'WeakMap');
}

export function isWeakSet(value) {
return checkPrototype(value, 'WekSet');
return checkPrototype(value, 'WeakSet');
}

// @todo isWebAssemblyCompiledModule
24 changes: 24 additions & 0 deletions tests/Resources/util.test.js
Expand Up @@ -1496,6 +1496,30 @@ describe.only('util', () => {
})
});

describe('#isWeakMap()', () => {
it('should return true for built-in WeakMap', () => {
const map = new WeakMap();
util.types.isWeakMap(map).to.be.true;
});

it('should return false for other values', () => {
util.types.isWeakMap({}).to.be.false;
util.types.isWeakMap(new Map()).to.be.false;
})
});

describe('#isWeakSet()', () => {
it('should return true for built-in WeakSet', () => {
const map = new WeakSet();
util.types.isWeakSet(map).to.be.true;
});

it('should return false for other values', () => {
util.types.isWeakSet({}).to.be.false;
util.types.isWeakSet(new Set()).to.be.false;
})
});

describe('Typed Arrays', () => {
it('should correctly check typed arrays', () => {
should(!util.types.isUint8Array({ [Symbol.toStringTag]: 'Uint8Array' })).be.true;
Expand Down

0 comments on commit bc9faba

Please sign in to comment.