This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
reValuate/node_modules/metro-symbolicate/src.real/__tests__/SourceMetadataMapConsumer-test.js
2021-04-02 02:24:13 +03:00

87 lines
1.9 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+js_symbolication
* @format
*/
'use strict';
const SourceMetadataMapConsumer = require('../SourceMetadataMapConsumer.js');
describe('SourceMetadataMapConsumer', () => {
it('ignores metadata beyond the range of the sources array', () => {
const consumer = new SourceMetadataMapConsumer({
version: 3,
mappings: '',
sources: ['foo'],
names: [],
x_facebook_sources: [
null,
[
{
mappings: '',
names: [],
},
],
],
});
expect(consumer.toArray(['foo'])).toEqual([null]);
});
it('ignores metadata for a null source', () => {
const consumer = new SourceMetadataMapConsumer({
version: 3,
mappings: '',
sources: ['foo', null],
names: [],
x_facebook_sources: [
[
{
mappings: '',
names: [],
},
],
],
});
expect(consumer.toArray(['foo', null])).toEqual([
[
{
mappings: '',
names: [],
},
],
null,
]);
});
it('accepts metadata blob with null function map', () => {
const consumer = new SourceMetadataMapConsumer({
version: 3,
mappings: 'AAAA',
sources: ['foo'],
names: [],
x_facebook_sources: [[null]],
});
expect(consumer.functionNameFor({line: 1, column: 0, source: 'foo'})).toBe(
null,
);
});
it('accepts null metadata blob', () => {
const consumer = new SourceMetadataMapConsumer({
version: 3,
mappings: 'AAAA',
sources: ['foo'],
names: [],
x_facebook_sources: [null],
});
expect(consumer.functionNameFor({line: 1, column: 0, source: 'foo'})).toBe(
null,
);
});
});