-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
126 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
/reports | ||
/dist | ||
/dist | ||
/cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"spec": "test/node.test.js" | ||
} | ||
"spec": ["test/node.test.?(c)js"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
// A JS file in order to be sure of the line and column numbers | ||
import { getCallId } from '../dist/index.js'; | ||
|
||
const { expect } = chai; | ||
|
||
describe('browser integration', () => { | ||
it('should give the correct location when called from a function', () => { | ||
function act() { | ||
return getCallId(); | ||
} | ||
const expected = { | ||
column: 20, | ||
line: 15 | ||
}; | ||
const actual = act(); | ||
expect(actual).deep.contains(expected); | ||
expect(actual.fileName).matches(/^http:\/\/localhost:\d+\/base\/test\/browser.test.js/); | ||
}); | ||
}); | ||
|
||
// A JS file in order to be sure of the line and column numbers | ||
import { getCallId } from '../dist/index.js'; | ||
|
||
const { expect } = chai; | ||
|
||
describe('browser integration', () => { | ||
it('should give the correct location when called from a function', () => { | ||
function act() { | ||
return getCallId(); | ||
} | ||
const expected = { | ||
column: 20, | ||
line: 15, | ||
}; | ||
const actual = act(); | ||
expect(actual).deep.contains(expected); | ||
expect(actual.fileName).matches( | ||
/^http:\/\/localhost:\d+\/base\/test\/browser.test.js/ | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { expect } = require('chai'); | ||
const { getCallId } = require('..'); | ||
|
||
// A JS file in order to be sure of the line and column numbers | ||
describe('node cjs', () => { | ||
it('should give the correct location when called from a function', () => { | ||
function act() { | ||
return getCallId(); | ||
} | ||
/** | ||
* @type {import('../../dist/call-id').CallId} | ||
*/ | ||
const expected = { | ||
fileName: __filename, | ||
column: 12, | ||
line: 18 | ||
}; | ||
expect(act()).deep.eq(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import { expect } from 'chai'; | ||
import { getCallId } from '../dist/get-call-id.js'; | ||
|
||
// A JS file in order to be sure of the line and column numbers | ||
describe('call-id integration', () => { | ||
it('should give the correct location when called from a function', () => { | ||
function act() { | ||
return getCallId(); | ||
} | ||
/** | ||
* @type {import('../../dist/call-id').CallId} | ||
*/ | ||
const expected = { | ||
fileName: new URL(import.meta.url).pathname, | ||
column: 12, | ||
line: 18 | ||
}; | ||
expect(act()).deep.eq(expected); | ||
}); | ||
}); | ||
import { expect } from 'chai'; | ||
import { getCallId } from '../dist/index.js'; | ||
|
||
// A JS file in order to be sure of the line and column numbers | ||
describe('node esm', () => { | ||
it('should give the correct location when called from a function', () => { | ||
function act() { | ||
return getCallId(); | ||
} | ||
/** | ||
* @type {import('../../dist/call-id').CallId} | ||
*/ | ||
const expected = { | ||
fileName: new URL(import.meta.url).pathname, | ||
column: 12, | ||
line: 18, | ||
}; | ||
expect(act()).deep.eq(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2015", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"declaration": true, | ||
"strict": true, | ||
"sourceMap": true, | ||
"module": "ES2015", | ||
}, | ||
"include": ["src"] | ||
} | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2015", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"declaration": true, | ||
"strict": true, | ||
"sourceMap": true, | ||
"module": "ES2015", | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"src", | ||
"test" | ||
] | ||
} | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"src", | ||
"test" | ||
] | ||
} |