react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / test / dedupe-nomap.js
80698 viewsvar browserify = require('../');1var test = require('tap').test;23test('identical content gets deduped and the row gets a "nomap" flag set when sourcemaps are turned on', function (t) {4t.plan(4)56var rows = [];7browserify({ debug: true })8.on('dep', [].push.bind(rows))9.require(require.resolve('./dup'), { entry: true })10.bundle(check);1112function check(err, src) {13if (err) return t.fail(err);14var nomappeds = rows.filter(function (x) { return x.nomap });15var nm = nomappeds[0];1617t.equal(rows.length, 3, 'packs 3 rows');18t.equal(nomappeds.length, 1, 'one of has nomapped flag set');19t.equal(20rows.filter(function (x) {21return x.id == nm.dedupeIndex22}).length,231,24'2 rows with the same hash as the duplicate exist'25);26t.similar(nm.source, /module\.exports.*=.*require\(.+\)$/, 'redirects duplicate to original via require call');27}28})2930test('identical content gets deduped and the row gets a "nomap" flag set when sourcemaps are turned off', function (t) {31t.plan(4)3233var rows = [];34browserify({ debug: false })35.on('dep', [].push.bind(rows))36.require(require.resolve('./dup'), { entry: true })37.bundle(check);3839function check(err, src) {40if (err) return t.fail(err);41var nomappeds = rows.filter(function (x) { return x.nomap });42var nm = nomappeds[0];4344t.equal(rows.length, 3, 'packs 3 rows');45t.equal(nomappeds.length, 1, 'one of has nomapped flag set');46t.equal(47rows.filter(function (x) {48return x.id == nm.dedupeIndex49}).length,501,51'2 rows with the same hash as the duplicate exist'52);53t.similar(nm.source, /module\.exports.*=.*require\(.+\)$/, 'redirects duplicate to original via require call');54}55})565758