source: frontend/node_modules/es-shim-unscopables/test/with.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* eslint no-restricted-syntax: 0, no-with: 0, strict: 0 */
2
3var test = require('tape');
4
5var shimUnscopables = require('../');
6
7test('`with` statement', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (t) {
8 // @ts-expect-error this variable is declared in case unscopables doesn't work
9 var entries;
10 // @ts-expect-error this variable is declared in case unscopables doesn't work
11 var concat;
12 // @ts-expect-error `with` unsupported
13 with ([]) {
14 t.equal(concat, Array.prototype.concat, 'concat is dynamically bound');
15 t.notEqual(entries, Array.prototype.entries, 'entries is not dynamically bound');
16 }
17
18 /** @type {Record<PropertyKey, unknown>} */
19 var obj = {
20 foo: 1,
21 bar: 2
22 };
23 // @ts-expect-error this variable is declared in case unscopables doesn't work
24 var foo;
25 // @ts-expect-error this variable is declared in case unscopables doesn't work
26 var bar;
27 obj[Symbol.unscopables] = { foo: true };
28 // @ts-expect-error `with` unsupported
29 with (obj) {
30 t.equal(foo, undefined);
31 t.equal(bar, obj.bar);
32 }
33
34 shimUnscopables('concat');
35
36 // @ts-expect-error `with` unsupported
37 with ([]) {
38 t.notEqual(concat, Array.prototype.concat, 'concat is no longer dynamically bound');
39 t.notEqual(entries, Array.prototype.entries, 'entries is still not dynamically bound');
40 }
41
42 t.end();
43});
Note: See TracBrowser for help on using the repository browser.