source: trip-planner-front/node_modules/regexp.prototype.flags/test/shimmed.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1'use strict';
2
3require('../auto');
4
5var test = require('tape');
6var defineProperties = require('define-properties');
7var callBind = require('call-bind');
8
9var isEnumerable = Object.prototype.propertyIsEnumerable;
10var functionsHaveNames = require('functions-have-names')();
11var hasStrictMode = require('has-strict-mode')();
12
13var runTests = require('./tests');
14
15test('shimmed', function (t) {
16 var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
17
18 t.equal(descriptor.get.length, 0, 'RegExp#flags getter has a length of 0');
19
20 t.test('Function name', { skip: !functionsHaveNames }, function (st) {
21 st.match(descriptor.get.name, /^(get )?flags$/, 'RegExp#flasgs getter has name "flags"');
22 st.end();
23 });
24
25 t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
26 et.equal(false, isEnumerable.call(RegExp.prototype, 'flags'), 'RegExp#flags is not enumerable');
27 et.end();
28 });
29
30 t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
31 st['throws'](function () { return descriptor.get.call(undefined); }, TypeError, 'undefined is not an object');
32 st['throws'](function () { return descriptor.get.call(null); }, TypeError, 'null is not an object');
33 st.end();
34 });
35
36 t.test('has the correct descriptor', function (st) {
37 st.equal(descriptor.configurable, true);
38 st.equal(descriptor.enumerable, false);
39 st.equal(typeof descriptor.get, 'function');
40 st.equal(descriptor.set, undefined);
41 st.end();
42 });
43
44 runTests(callBind(descriptor.get), t);
45
46 t.end();
47});
Note: See TracBrowser for help on using the repository browser.