Phase 1 PWA: prayer times, qibla, quran, hijri, tasbih, 99 names
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var v = require('es-value-fixtures');
|
||||
|
||||
var Get = require('../Get');
|
||||
|
||||
test('Get', function (t) {
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { return Get('a', 'a'); },
|
||||
TypeError,
|
||||
'Throws a TypeError if `O` is not an Object'
|
||||
);
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { return Get({ 7: 7 }, 7); },
|
||||
TypeError,
|
||||
'Throws a TypeError if `P` is not a property key'
|
||||
);
|
||||
|
||||
var sentinel = {};
|
||||
|
||||
t.test('Symbols', { skip: !v.hasSymbols }, function (st) {
|
||||
var sym = Symbol('sym');
|
||||
var obj = /** @type {Record<symbol, unknown>} */ ({});
|
||||
obj[sym] = sentinel;
|
||||
|
||||
st.equal(Get(obj, sym), sentinel, 'returns property `P` if it exists on object `O`');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.equal(Get({ a: sentinel }, 'a'), sentinel, 'returns property `P` if it exists on object `O`');
|
||||
t.equal(
|
||||
// @ts-expect-error
|
||||
Get({}, 'a'),
|
||||
undefined,
|
||||
'returns undefined if property `P` does not exist on object `O`'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var forEach = require('for-each');
|
||||
var v = require('es-value-fixtures');
|
||||
var debug = require('object-inspect');
|
||||
|
||||
var GetMethod = require('../GetMethod');
|
||||
|
||||
test('GetMethod', function (t) {
|
||||
forEach(v.nonPropertyKeys, function (nonPropertyKey) {
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { return GetMethod({}, nonPropertyKey); },
|
||||
TypeError,
|
||||
debug(nonPropertyKey) + ' is not a Property Key'
|
||||
);
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { return GetMethod({ 7: 7 }, 7); },
|
||||
TypeError,
|
||||
'Throws a TypeError if `P` is not a property key'
|
||||
);
|
||||
|
||||
t.equal(GetMethod({}, 'a'), undefined, 'returns undefined if property is undefined');
|
||||
t.equal(GetMethod({ a: null }, 'a'), undefined, 'returns undefined if property is null');
|
||||
t.equal(GetMethod({ a: undefined }, 'a'), undefined, 'returns undefined if property is undefined');
|
||||
|
||||
var obj = { a: function () {} };
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { GetMethod({ a: 'b' }, 'a'); },
|
||||
TypeError,
|
||||
'throws a TypeError if property exists and is not callable'
|
||||
);
|
||||
|
||||
t.equal(GetMethod(obj, 'a'), obj.a, 'returns property if it is callable');
|
||||
|
||||
t.end();
|
||||
});
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var $defineProperty = require('es-define-property');
|
||||
var mockProperty = require('mock-property');
|
||||
|
||||
var GetV = require('../GetV');
|
||||
|
||||
test('GetV', function (t) {
|
||||
t['throws'](
|
||||
function () { return GetV({ 7: 7 }, 7); },
|
||||
TypeError,
|
||||
'Throws a TypeError if `P` is not a property key'
|
||||
);
|
||||
|
||||
var obj = { a: function () {} };
|
||||
t.equal(GetV(obj, 'a'), obj.a, 'returns property if it exists');
|
||||
t.equal(GetV(obj, 'b'), undefined, 'returns undefined if property does not exist');
|
||||
|
||||
t.test(
|
||||
'getter observability of the receiver',
|
||||
{ skip: !$defineProperty || !Object.isExtensible(Number.prototype) },
|
||||
function (st) {
|
||||
/** @type {unknown[]} */
|
||||
var receivers = [];
|
||||
|
||||
st.teardown(mockProperty(/** @type {Record<PropertyKey, unknown>} */ (/** @type {unknown} */ (Number.prototype)), 'foo', {
|
||||
get: /** @this {number | Number} */ function () {
|
||||
receivers.push(this);
|
||||
}
|
||||
}));
|
||||
|
||||
GetV(42, 'foo');
|
||||
GetV(Object(42), 'foo');
|
||||
|
||||
st.deepEqual(receivers, [42, Object(42)]);
|
||||
|
||||
st.end();
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var forEach = require('for-each');
|
||||
var v = require('es-value-fixtures');
|
||||
var debug = require('object-inspect');
|
||||
|
||||
var isPropertyKey = require('../isPropertyKey');
|
||||
|
||||
/** @import { PropertyKey } from '../isPropertyKey' */
|
||||
|
||||
test('isPropertyKey', function (t) {
|
||||
forEach(v.nonPropertyKeys, function (nonPropertyKey) {
|
||||
t.equal(isPropertyKey(nonPropertyKey), false, debug(nonPropertyKey) + ' is not a Property Key');
|
||||
});
|
||||
|
||||
var propertyKeys = /** @type {PropertyKey[]} */ ([]).concat(
|
||||
v.strings,
|
||||
v.hasSymbols ? v.symbols : []
|
||||
);
|
||||
forEach(propertyKeys, function (propertyKey) {
|
||||
t.equal(isPropertyKey(propertyKey), true, debug(propertyKey) + ' is a Property Key');
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user