Skip to content

Commit

Permalink
use makerelative method in test
Browse files Browse the repository at this point in the history
  • Loading branch information
timse committed Apr 3, 2017
1 parent 385769b commit 6441a35
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions test/RecordIdsPlugin.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* globals describe, before, it */
"use strict";

const should = require("should");
Expand All @@ -7,19 +8,6 @@ const webpack = require("../lib/webpack");

const RecordIdsPlugin = require("../lib/RecordIdsPlugin");

const looksLikeAbsolutePath = (maybeAbsolutePath) => /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);

function makeRelative(compiler, identifier) {
const context = compiler.context;
return identifier.split("|")
.map(str => str.split("!")
.map(str => str.split(" ")
.map(str => looksLikeAbsolutePath(str) ? path.relative(context, str) : str)
.join(" "))
.join("!"))
.join("|");
}

describe("RecordIdsPlugin", () => {

let compiler;
Expand All @@ -46,7 +34,7 @@ describe("RecordIdsPlugin", () => {
for(let i = 0; i < compilation.modules.length; i++) {
try {
should.exist(compilation.modules[i].portableId);
compilation.modules[i].portableId.should.equal(makeRelative(compiler, compilation.modules[i].identifier()));
compilation.modules[i].portableId.should.equal(RecordIdsPlugin.makeRelative(compiler.context, compilation.modules[i].identifier()));
} catch(e) {
done(e);
pass = false;
Expand Down

0 comments on commit 6441a35

Please sign in to comment.