first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

68
build/node_modules/inline-require/tests/test.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
const should = require('chai').should()
const path = require('path')
const exec = require('child_process').exec
const index = process.env.NODE_ENV == 'coverage' ? '../index.es' : '../index'
const inline = require(index)
describe('inline-require', () => {
it('should process local modules', (done) => {
inline(path.join(__dirname, 'local-dependencies.js'), (err, contents) => {
should.equal(err, null)
contents.should.not.match(/require\('\./)
done()
})
})
it('should not process global modules', (done) => {
inline(path.join(__dirname, 'global-dependency.js'), (err, contents) => {
should.equal(err, null)
contents.should.match(/require\('fs/)
done()
})
})
it('should preserve the types of inlined dependencies', (done) => {
inline(path.join(__dirname, 'local-dependencies.js'), (err, contents) => {
const mod = eval(contents)
mod.should.have.property('array')
mod.should.have.property('object')
mod.should.have.property('number')
mod.should.have.property('string')
mod.should.have.property('func')
mod.array.should.be.an('array').that.includes.all.members([1,2,3])
mod.object.should.be.an('object').that.deep.equals({ foo: 'foo' })
mod.number.should.be.a('number').that.equals(1)
mod.string.should.be.a('string').that.equals('foo')
mod.func.should.be.a('function')
mod.func().should.equal('foo')
done()
})
})
it('should return an error if improper arguments are provided', () => {
inline(null, err => err.should.be.an('Error') )
inline({}, err => err.should.be.an('Error') )
inline([], err => err.should.be.an('Error') )
})
it('should return an error if source file does not exist', (done) => {
inline('./bogus', (err) => {
err.should.be.an('Error')
done()
})
})
it('should return an error if a dependency does not exist', () => {
// handled by native module loader
})
it('should run on the command line', (done) => {
exec(`node ${index} ./local-dependencies.js`, { cwd: __dirname }, (err, stdout, stderr) => {
should.equal(err, null)
should.equal(stderr, '')
stdout.should.match(/const array = \[1,2,3\]/)
done()
})
})
})