This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
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
1 parent
dca9764
commit 9119cc1
Showing
3 changed files
with
54 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Testcase } from '@tests/utils/types' | ||
import type { SourceMapComment } from '@trext/types' | ||
import testSubject from '../source-mapping-url.util' | ||
|
||
/** | ||
* @file Unit Tests - sourceMappingURL | ||
* @module trext/utils/tests/unit/sourceMappingURL | ||
*/ | ||
|
||
describe('unit:utils/sourceMappingURL', () => { | ||
type Case = Testcase<SourceMapComment> & { | ||
filename: string | ||
ext: string | undefined | ||
} | ||
|
||
const cases: Case[] = [ | ||
{ | ||
expected: '//# sourceMappingURL=dog.interface.js', | ||
ext: undefined, | ||
filename: 'dog.interface.js' | ||
} | ||
] | ||
|
||
const name = "should return source map comment given ['$filename',$ext]" | ||
|
||
it.each<Case>(cases)(name, testcase => { | ||
// Arrange | ||
const { expected, ext, filename } = testcase | ||
|
||
// Act + Expect | ||
expect(testSubject(filename, ext)).toBe(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
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 @@ | ||
import { SourceMapComment } from '@trext/types' | ||
import path from 'path' | ||
|
||
/** | ||
* @file Utilities - sourceMappingURL | ||
* @module trext/utils/sourceMappingURL | ||
*/ | ||
|
||
/** | ||
* Returns a source map comment. | ||
* | ||
* @param {string} filename - Name of source file | ||
* @param {string} [ext] - Extension to remove | ||
* @return {SourceMapComment} Comment referencing a source map | ||
*/ | ||
const sourceMappingURL = (filename: string, ext?: string): SourceMapComment => { | ||
return `//# sourceMappingURL=${path.basename(filename, ext)}` | ||
} | ||
|
||
export default sourceMappingURL |