-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
export default { | ||
coreMiddleware: ['status'], | ||
|
||
urllib: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default null; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
fn() {} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function fn() { | ||
console.log(fn); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
map: | ||
a: 1 | ||
b: 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default null; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default { a: 1 }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = { a: 1 }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 0; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default { a: 1 }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default {} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { strict as assert } from 'node:assert'; | ||
import mm from 'mm'; | ||
import { createApp, Application, getFilepath } from '../utils.js'; | ||
|
||
describe('test/loader/load_file.test.ts', () => { | ||
let app: Application; | ||
afterEach(mm.restore); | ||
afterEach(() => app.close()); | ||
|
||
it.only('should load file', async () => { | ||
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (ubuntu-latest, 18.19.0)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (ubuntu-latest, 22)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (ubuntu-latest, 20)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (ubuntu-latest, 18)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (macos-latest, 18.19.0)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (macos-latest, 22)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (macos-latest, 18)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (macos-latest, 20)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (windows-latest, 18.19.0)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (windows-latest, 22)
Check warning on line 10 in test/loader/load_file.test.ts GitHub Actions / Node.js / Test (windows-latest, 18)
|
||
app = createApp('load_file'); | ||
const exports = await app.loader.loadFile(getFilepath('load_file/obj.js')); | ||
assert.deepEqual(exports, { a: 1 }); | ||
const exports2 = await app.loader.loadFile(getFilepath('load_file/obj')); | ||
assert.deepEqual(exports2, { a: 1 }); | ||
}); | ||
|
||
it('should load file when exports is function', async () => { | ||
app = createApp('load_file'); | ||
const exports = await app.loader.loadFile(getFilepath('load_file/function.js'), 1, 2); | ||
assert.deepEqual(exports, [ 1, 2 ]); | ||
}); | ||
|
||
it('should throw with filepath when file syntax error', async () => { | ||
await assert.rejects(async () => { | ||
app = createApp('syntaxerror'); | ||
await app.loader.loadCustomApp(); | ||
}, /error: Unexpected end of input/); | ||
}); | ||
|
||
it('should load custom file', async () => { | ||
app = createApp('load_file'); | ||
let result = (await app.loader.loadFile(getFilepath('load_file/no-js.yml'))).toString(); | ||
if (process.platform === 'win32') { | ||
result = result.replace(/\r\n/g, '\n'); | ||
} | ||
assert.equal(result, '---\nmap:\n a: 1\n b: 2'); | ||
}); | ||
}); |