source: imaps-frontend/node_modules/set-proto/test/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3var test = require('tape');
4
5var setProto = require('../');
6
7var isPrototypeOf = Object.prototype.isPrototypeOf;
8
9test('setProto', function (t) {
10 t.equal(typeof setProto, 'function', 'is a function');
11
12 t.test('can set', { skip: !setProto }, function (st) {
13 var obj = { a: 1 };
14 var proto = { b: 2 };
15
16 st.ok(isPrototypeOf.call(Object.prototype, obj), 'Object.prototype is isPrototypeOf obj');
17 st.notOk(isPrototypeOf.call(proto, obj), 'proto is not isPrototypeOf obj');
18 st.ok('a' in obj, 'a is in obj');
19 st.notOk('b' in obj, 'b is not in obj');
20
21 // eslint-disable-next-line no-extra-parens
22 st.equal(/** @type {NonNullable<typeof setProto>} */ (setProto)(obj, proto), obj, 'returns the object');
23
24 st.ok(isPrototypeOf.call(Object.prototype, obj), 'Object.prototype is isPrototypeOf obj');
25 st.ok(isPrototypeOf.call(proto, obj), 'proto is isPrototypeOf obj');
26 st.ok('a' in obj, 'a is in obj');
27 st.ok('b' in obj, 'b is in obj');
28
29 st.equal(Object.getPrototypeOf(obj), proto, 'sets the prototype');
30 st.end();
31 });
32
33 t.test('can not set', { skip: !!setProto }, function (st) {
34 st.equal(setProto, null);
35
36 st.end();
37 });
38
39 t.end();
40});
Note: See TracBrowser for help on using the repository browser.