This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/papercraft/openjscad/node_modules/w3c-blob/test.js

59 lines
1.3 KiB
JavaScript

var test = require('tape')
if(process.browser) {
browser()
} else {
node()
}
function node() {
var Blob = (require)('./index')
, Buffer = (require)('buffer').Buffer
test('works as expected with strings', function(assert) {
var str = '\u022au\u2323'
assert.equal(new Blob([str]).size, 6)
assert.end()
})
test('works as expected with array buffers', function(assert) {
var size = Math.random() * 1024 | 1
, ab = new ArrayBuffer(size)
assert.equal(new Blob([ab]).size, size)
assert.end()
})
test('works as expected with typed arrays', function(assert) {
var size = Math.random() * 1024 | 1
, ab = new Uint8Array(size)
assert.equal(new Blob([ab]).size, size)
assert.end()
})
test('works as expected with buffers', function(assert) {
var size = Math.random() * 1024 | 1
, ab = new Buffer(size)
assert.equal(new Blob([ab]).size, size)
assert.end()
})
}
function browser() {
var Blob = require('./browser')
test('works as expected', function(assert) {
var b = new Blob(['asdf'], {type: 'text/plain'})
try {
var URL = (global.URL || global.webkitURL || global.MozURL || global.msURL || global.MSURL)
assert.equal(typeof URL.createObjectURL(b), 'string')
} catch(e) {
assert.fail('did not work')
}
assert.end()
})
}