source: imaps-frontend/node_modules/data-view-buffer/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: 959 bytes
Line 
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 dataViewBuffer = require('../');
9
10test('dataViewBuffer', 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 () { dataViewBuffer(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(1);
22 var dv = new DataView(ab);
23
24 st.equal(dataViewBuffer(dv), ab, inspect(dv) + ' has the same buffer originally passed to the DataView');
25 st.equal(dataViewBuffer(dv), dv.buffer, inspect(dv) + ' has the same buffer as its own buffer property');
26
27 st.end();
28 });
29
30 t.end();
31});
Note: See TracBrowser for help on using the repository browser.