source: imaps-frontend/node_modules/data-view-byte-offset/test/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 996 bytes
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var forEach = require('for-each');
5var v = require('es-value-fixtures');
6var inspect = require('object-inspect');
7
8var dataViewByteOffset = require('../');
9
10test('dataViewByteOffset', function (t) {
11 forEach(
12 // @ts-expect-error TS sucks at [].concat
13 // eslint-disable-next-line no-extra-parens
14 /** @type {[...typeof v.primitives, ...typeof v.objects]} */ ([].concat(v.primitives, v.objects)),
15 function (nonDV) {
16 t['throws'](function () { dataViewByteOffset(nonDV); }, TypeError, inspect(nonDV) + ' is not a DataView');
17 }
18 );
19
20 t.test('DataView', { skip: typeof DataView !== 'function' }, function (st) {
21 var ab = new ArrayBuffer(42);
22 var dv = new DataView(ab, 2);
23
24 st.equal(dataViewByteOffset(dv), 2, inspect(dv) + ' has the same byteOffset originally passed to the DataView');
25 st.equal(dataViewByteOffset(dv), dv.byteOffset, inspect(dv) + ' has the same byteOffset as the buffer’s byteOffset');
26
27 st.end();
28 });
29
30 t.end();
31});
Note: See TracBrowser for help on using the repository browser.