Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"source-map": "~0.5.3"
},
"devDependencies": {
"tap": "~0.7.0",
"nave": "~0.5.0"
"tap": "~5.4.5",
"nave": "^3.5.2"
},
"keywords": [
"source",
Expand Down
25 changes: 14 additions & 11 deletions test/inline-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('generated mappings', function (t) {
var gen = generator()
.addGeneratedMappings('foo.js', foo)

t.deepEqual(
t.same(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change? deepEqual should still apply.
Not sure what same does and had a hard time finding the tap docs.

Copy link
Collaborator Author

@legobeat legobeat Feb 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gen._mappings()
, [ { generatedLine: 1,
generatedColumn: 0,
Expand Down Expand Up @@ -66,7 +66,7 @@ test('generated mappings', function (t) {
, 'generates correct mappings'
)

t.deepEqual(
t.same(
JSON.parse(decode(gen.base64Encode()))
, {"version":3,"file":"","sources":["foo.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA","sourceRoot":""}
, 'encodes generated mappings'
Expand All @@ -84,7 +84,7 @@ test('generated mappings', function (t) {
.addGeneratedMappings('foo.js', foo)
.addGeneratedMappings('bar.js', bar)

t.deepEqual(
t.same(
gen._mappings()
, [ { generatedLine: 1,
generatedColumn: 0,
Expand Down Expand Up @@ -136,7 +136,7 @@ test('generated mappings', function (t) {
name: null } ]
, 'generates correct mappings'
)
t.deepEqual(
t.same(
JSON.parse(decode(gen.base64Encode()))
, {"version":3,"file":"","sources":["foo.js","bar.js"],"names":[],"mappings":"ACAA,ADAA;ACCA,ADAA;ACCA,ADAA;AACA;AACA","sourceRoot": ""}
, 'encodes generated mappings'
Expand All @@ -151,7 +151,7 @@ test('generated mappings', function (t) {

t.test('one line source', function (t) {
var gen = generator().addGeneratedMappings('one-liner.js', 'console.log("line one");')
t.deepEqual(
t.same(
gen._mappings()
, [ { generatedLine: 1,
generatedColumn: 0,
Expand All @@ -169,7 +169,7 @@ test('generated mappings', function (t) {
.addGeneratedMappings('foo.js', foo, { line: 20 })
.addGeneratedMappings('bar.js', bar, { line: 23, column: 22 })

t.deepEqual(
t.same(
gen._mappings()
, [ { generatedLine: 21,
generatedColumn: 0,
Expand Down Expand Up @@ -222,13 +222,14 @@ test('generated mappings', function (t) {
, 'generates correct mappings'
)

t.deepEqual(
t.same(
JSON.parse(decode(gen.base64Encode()))
, {"version":3,"file":"","sources":["foo.js","bar.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,sBCHA;ADIA,sBCHA;sBACA", "sourceRoot": ""}
, 'encodes generated mappings with offset'
)
t.end()
})
t.end()
})

test('given mappings, with one having no original', function (t) {
Expand All @@ -246,7 +247,7 @@ test('given mappings, with one having no original', function (t) {
, { generated: { line: 8, column: 30 } }
])

t.deepEqual(
t.same(
gen._mappings()
, [ { generatedLine: 5,
generatedColumn: 10,
Expand All @@ -268,7 +269,7 @@ test('given mappings, with one having no original', function (t) {
name: null } ]
, 'adds correct mappings'
)
t.deepEqual(
t.same(
JSON.parse(decode(gen.base64Encode()))
, {"version":3,"file":"","sources":["foo.js","bar.js"],"names":[],"mappings":";;;;UACG;;oBCIH;8B", sourceRoot: ""}
, 'encodes generated mappings'
Expand All @@ -286,7 +287,7 @@ test('given mappings, with one having no original', function (t) {
.addMappings('foo.js', [{ original: { line: 2, column: 3 } , generated: { line: 5, column: 10 } }], { line: 5 })
.addMappings('bar.js', [{ original: { line: 6, column: 0 } , generated: { line: 7, column: 20 } }, { generated: { line: 8, column: 30 } }], { line: 9, column: 3 })

t.deepEqual(
t.same(
gen._mappings()
, [ { generatedLine: 10,
generatedColumn: 10,
Expand All @@ -308,13 +309,14 @@ test('given mappings, with one having no original', function (t) {
name: null } ]
, 'adds correct mappings'
)
t.deepEqual(
t.same(
JSON.parse(decode(gen.base64Encode()))
, {"version":3,"file":"","sources":["foo.js","bar.js"],"names":[],"mappings":";;;;;;;;;UACG;;;;;;uBCIH;iC", sourceRoot: ""}
, 'encodes mappings with offset'
)
t.end()
})
t.end()
});

test('inline mapping url with charset opt', function(t){
Expand Down Expand Up @@ -342,4 +344,5 @@ test('inline mapping url with charset opt', function(t){

t.end();
});
t.end()
});
13 changes: 7 additions & 6 deletions test/source-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('generated mappings', function (t) {
.addGeneratedMappings('foo.js', foo)
.addSourceContent('foo.js', foo)

t.deepEqual(
t.same(
gen.toJSON()
, { "version": 3,
"file": "",
Expand Down Expand Up @@ -69,7 +69,7 @@ test('generated mappings', function (t) {
.addGeneratedMappings('bar.js', bar)
.addSourceContent('bar.js', bar)

t.deepEqual(
t.same(
gen.toJSON()
, { "version": 3,
"file": "",
Expand All @@ -88,7 +88,7 @@ test('generated mappings', function (t) {
, 'includes source content for both files'
)

t.deepEqual(
t.same(
decode(gen.base64Encode())
, '{"version":3,"sources":["foo.js","bar.js"],"names":[],"mappings":"ACAA,ADAA;ACCA,ADAA;ACCA,ADAA;AACA;AACA","file":"","sourceRoot":"","sourcesContent":["function foo() {\\n var hello = \'hello\';\\n var world = \'world\';\\n console.log(\'%s %s\', hello, world);\\n}","function bar() {\\n console.log(\'yes?\');\\n}"]}'
, 'encodes generated mappings including source content'
Expand All @@ -107,7 +107,7 @@ test('generated mappings', function (t) {
.addGeneratedMappings('bar.js', bar)
.addSourceContent('bar.js', bar)

t.deepEqual(
t.same(
gen.toJSON()
, { "version": 3,
"file": "",
Expand All @@ -123,7 +123,7 @@ test('generated mappings', function (t) {
, 'includes source content for the file with source content and [null] for the other file'
)

t.deepEqual(
t.same(
decode(gen.base64Encode())
, '{"version":3,"sources":["foo.js","bar.js"],"names":[],"mappings":"ACAA,ADAA;ACCA,ADAA;ACCA,ADAA;AACA;AACA","file":"","sourceRoot":"","sourcesContent":[null,"function bar() {\\n console.log(\'yes?\');\\n}"]}'
, 'encodes generated mappings including source content'
Expand All @@ -140,7 +140,8 @@ test('generated mappings', function (t) {
var gen = generator()
.addGeneratedMappings('empty.js', '')
.addSourceContent('empty.js', '')
t.deepEqual(gen.toJSON()["sourcesContent"], [""])
t.same(gen.toJSON()["sourcesContent"], [""])
t.end()
});
t.end()
})