Skip to content

Commit

Permalink
feat: 🎸 finish unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Apr 11, 2023
1 parent 8fb812b commit 7b84ba8
Show file tree
Hide file tree
Showing 30 changed files with 113 additions and 77 deletions.
5 changes: 3 additions & 2 deletions webpack-test/AbstractMethodError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const AbstractMethodError = require("../lib/AbstractMethodError");
// TODO: recover after we have this module
// const AbstractMethodError = require("../lib/AbstractMethodError");

describe("WebpackError", () => {
describe.skip("WebpackError", () => {
class Foo {
abstractMethod() {
return new AbstractMethodError();
Expand Down
3 changes: 2 additions & 1 deletion webpack-test/JavascriptParser.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// const JavascriptParser = require("../lib/javascript/JavascriptParser");

describe.skip("JavascriptParser", () => {

it("filtered", () => {})
return
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
/* eslint-disable no-inner-declarations */
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/LazySet.unittest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const LazySet = require("../lib/util/LazySet");
// TODO: recover
// const LazySet = require("../lib/util/LazySet");

describe("LazySet", () => {
describe.skip("LazySet", () => {
it("addAll", () => {
const a = new Set(["a"]);
const sut = new LazySet(a);
Expand Down
11 changes: 6 additions & 5 deletions webpack-test/LocalModulesHelpers.unittest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";

const {
addLocalModule,
getLocalModule
} = require("../lib/dependencies/LocalModulesHelpers");
// TODO: recover
// const {
// addLocalModule,
// getLocalModule
// } = require("../lib/dependencies/LocalModulesHelpers");

describe("LocalModulesHelpers", () => {
describe.skip("LocalModulesHelpers", () => {
describe("addLocalModule", () => {
it("returns a module var without special characters", () => {
const state = {
Expand Down
4 changes: 2 additions & 2 deletions webpack-test/ModuleDependencyError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const path = require("path");
const ModuleDependencyError = require("../lib/ModuleDependencyError");
// const ModuleDependencyError = require("../lib/ModuleDependencyError");

describe("ModuleDependencyError", () => {
describe.skip("ModuleDependencyError", () => {
let env;

beforeEach(() => {
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/MultiItemCache.unittest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use strict";

const Cache = require("../lib/Cache");
const { ItemCacheFacade, MultiItemCache } = require("../lib/CacheFacade");
// TODO: recover
// const Cache = require("../lib/Cache");
// const { ItemCacheFacade, MultiItemCache } = require("../lib/CacheFacade");

describe("MultiItemCache", () => {
describe.skip("MultiItemCache", () => {
it("Throws when getting items from an empty Cache", () => {
const multiItemCache = new MultiItemCache(generateItemCaches(0));
expect(() => multiItemCache.get(_ => _())).toThrowError();
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/MultiWatching.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const SyncHook = require("tapable").SyncHook;
const MultiWatching = require("../lib/MultiWatching");

// TODO: recover
// const MultiWatching = require("../lib/MultiWatching");
//
const createWatching = () => {
return {
invalidate: jest.fn(),
Expand All @@ -21,7 +22,7 @@ const createCompiler = () => {
return compiler;
};

describe("MultiWatching", () => {
describe.skip("MultiWatching", () => {
let watchings;
let compiler;
let myMultiWatching;
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/NullDependency.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const NullDependency = require("../lib/dependencies/NullDependency");

describe("NullDependency", () => {
// TODO: recover
// const NullDependency = require("../lib/dependencies/NullDependency");
//
describe.skip("NullDependency", () => {
let env;

beforeEach(() => (env = {}));
Expand Down
2 changes: 1 addition & 1 deletion webpack-test/ProfilingPlugin.unittest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");
// const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");

describe.skip("Profiling Plugin", () => {
it("should persist the passed output path", () => {
Expand Down
10 changes: 6 additions & 4 deletions webpack-test/RawModule.unittest.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";

const RawModule = require("../lib/RawModule");
const RequestShortener = require("../lib/RequestShortener");
// TODO: recover
// const RawModule = require("../lib/RawModule");
// const RequestShortener = require("../lib/RequestShortener");
const path = require("path");

describe("RawModule", () => {
describe.skip("RawModule", () => {
const source = "sourceStr attribute";
const identifier = "identifierStr attribute";
const readableIdentifier = "readableIdentifierStr attribute";
const myRawModule = new RawModule(source, identifier, readableIdentifier);
// TODO: recover this comment after we ahve RawModule
// const myRawModule = new RawModule(source, identifier, readableIdentifier);

describe("identifier", () => {
it("returns value for identifierStr attribute", () => {
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/RequestShortener.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

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

describe("RequestShortener", () => {
// TODO: recover
// const RequestShortener = require("../lib/RequestShortener");
//
describe.skip("RequestShortener", () => {
it("should create RequestShortener and shorten with ./ file in directory", () => {
const shortener = new RequestShortener("/foo/bar");
expect(shortener.shorten("/foo/bar/some.js")).toEqual("./some.js");
Expand Down
18 changes: 10 additions & 8 deletions webpack-test/RuntimeTemplate.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const RuntimeTemplate = require("../lib/RuntimeTemplate");
const RequestShortener = require("../lib/RequestShortener");

// TODO: recover
// const RuntimeTemplate = require("../lib/RuntimeTemplate");
// const RequestShortener = require("../lib/RequestShortener");
//
describe.skip("RuntimeTemplate.concatenation", () => {
it("no args", () => {
const runtimeTemplate = new RuntimeTemplate(
Expand Down Expand Up @@ -49,11 +50,12 @@ describe.skip("RuntimeTemplate.concatenation", () => {
});

describe("es6", () => {
const runtimeTemplate = new RuntimeTemplate(
undefined,
{ environment: { templateLiteral: true } },
new RequestShortener(__dirname)
);
// TODO: recover this comment after we have RuntimeTemplate
// const runtimeTemplate = new RuntimeTemplate(
// undefined,
// { environment: { templateLiteral: true } },
// new RequestShortener(__dirname)
// );

it("should prefer shorten variant #1", () => {
expect(runtimeTemplate.concatenation({ expr: 1 }, "a", { expr: 2 })).toBe(
Expand Down
4 changes: 3 additions & 1 deletion webpack-test/SemVer.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// satisfyRuntimeCode
// } = require("../lib/util/semver");

describe("SemVer", () => {
describe.skip("SemVer", () => {
it("filtered", () => {})
return
const createRuntimeFunction = runtimeCodeFunction => {
const runtimeFunction = runtimeCodeFunction({
basicFunction: (args, body) => `(${args}) => {\n${body.join("\n")}\n}`,
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/SortableSet.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const SortableSet = require("../lib/util/SortableSet");
// TODO: recover
// const SortableSet = require("../lib/util/SortableSet");

describe("util/SortableSet", () => {
describe.skip("util/SortableSet", () => {
it("Can be constructed like a normal Set", () => {
const sortableSet = new SortableSet([1, 1, 1, 1, 1, 4, 5, 2], () => {});
expect(Array.from(sortableSet)).toEqual([1, 4, 5, 2]);
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/Template.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const Template = require("../lib/Template");
// TODO: recover
// const Template = require("../lib/Template");

describe("Template", () => {
describe.skip("Template", () => {
it("should generate valid identifiers", () => {
expect(Template.toIdentifier("0abc-def9")).toBe("_0abc_def9");
});
Expand Down
7 changes: 4 additions & 3 deletions webpack-test/URLAbsoluteSpecifier.unittest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { getScheme, getProtocol } = require("../lib/util/URLAbsoluteSpecifier");
// TODO: recover
// const { getScheme, getProtocol } = require("../lib/util/URLAbsoluteSpecifier");

/**
* @type {Array<{specifier: string, expected: string|undefined}>}
Expand Down Expand Up @@ -66,15 +67,15 @@ const samples = [
}
];

describe("getScheme", () => {
describe.skip("getScheme", () => {
samples.forEach(({ specifier, expected }, i) => {
it(`should handle ${specifier}`, () => {
expect(getScheme(specifier)).toBe(expected);
});
});
});

describe("getProtocol", () => {
describe.skip("getProtocol", () => {
samples.forEach(({ specifier, expected }, i) => {
it(`should handle ${specifier}`, () => {
expect(getProtocol(specifier)).toBe(
Expand Down
4 changes: 3 additions & 1 deletion webpack-test/WasmHashes.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ const wasmHashes = {
};

for (const name of Object.keys(wasmHashes)) {
it("filtered", () => {})
continue
const { createHash, createReferenceHash, regExp } = wasmHashes[name]();

describe(name, () => {
describe.skip(name, () => {
const sizes = [
1,
2,
Expand Down
8 changes: 6 additions & 2 deletions webpack-test/WebpackError.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use strict";

const WebpackError = require("../lib/WebpackError");
// TODO: recover
// const WebpackError = require("../lib/WebpackError");

describe("WebpackError", () => {
// TODO: remove this class after we have real webpackError
class WebpackError {}

describe.skip("WebpackError", () => {
class CustomError extends WebpackError {
constructor(message) {
super();
Expand Down
2 changes: 2 additions & 0 deletions webpack-test/cleverMerge.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// } = require("../lib/util/cleverMerge");

describe.skip("cleverMerge", () => {
it("filtered", () => {})
return
const base = {
a1: [1],
a2: [1],
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/compareLocations.unittest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const { compareLocations } = require("../lib/util/comparators");
// TODO: recover
// const { compareLocations } = require("../lib/util/comparators");
const createPosition = overrides => {
return {
line: 10,
Expand All @@ -17,7 +18,7 @@ const createLocation = (start, end, index) => {
};
};

describe("compareLocations", () => {
describe.skip("compareLocations", () => {
describe("object location comparison", () => {
let a, b;

Expand Down
5 changes: 3 additions & 2 deletions webpack-test/compileBooleanMatcher.unittest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";

const { itemsToRegexp } = require("../lib/util/compileBooleanMatcher");
describe("itemsToRegexp", () => {
// TODO: recover
// const { itemsToRegexp } = require("../lib/util/compileBooleanMatcher");
describe.skip("itemsToRegexp", () => {
const expectCompiled = (name, input, fn) => {
it(`should compile ${name}`, () => {
const items = typeof input === "string" ? input.split(",") : input;
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/deterministicGrouping.unittest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const deterministicGrouping = require("../lib/util/deterministicGrouping");
// TODO: recover
// const deterministicGrouping = require("../lib/util/deterministicGrouping");

describe("deterministicGrouping", () => {
describe.skip("deterministicGrouping", () => {
const group = (items, minSize, maxSize) => {
return deterministicGrouping({
items: items.map((item, i) => [i, item]),
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/extractUrlAndGlobal.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const extractUrlAndGlobal = require("../lib/util/extractUrlAndGlobal");
// TODO: recover
// const extractUrlAndGlobal = require("../lib/util/extractUrlAndGlobal");

describe("extractUrlAndGlobal", () => {
describe.skip("extractUrlAndGlobal", () => {
it("should return jQuery", () => {
const result = extractUrlAndGlobal(
"jQuery@https://code.jquery.com/jquery-3.5.1.min.js"
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/formatLocation.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const formatLocation = require("../lib/formatLocation");
// TODO: recover
// const formatLocation = require("../lib/formatLocation");

describe("formatLocation", () => {
describe.skip("formatLocation", () => {
const testCases = [
{
name: "undefined",
Expand Down
5 changes: 3 additions & 2 deletions webpack-test/identifier.unittest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

const identifierUtil = require("../lib/util/identifier");
// TODO: recover
// const identifierUtil = require("../lib/util/identifier");

describe("util/identifier", () => {
describe.skip("util/identifier", () => {
describe("makePathsRelative", () => {
describe("given a context and a pathConstruct", () => {
it("computes the correct relative results for the path construct", () => {
Expand Down
17 changes: 9 additions & 8 deletions webpack-test/nonNumericOnlyHash.unittest.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
"use strict";

const nonNumericOnlyHash = require("../lib/util/nonNumericOnlyHash");
// TODO: recover
// const nonNumericOnlyHash = require("../lib/util/nonNumericOnlyHash");

it("hashLength=0", () => {
it.skip("hashLength=0", () => {
expect(nonNumericOnlyHash("111", 0)).toBe("");
});

it("abc", () => {
it.skip("abc", () => {
expect(nonNumericOnlyHash("abc", 10)).toBe("abc");
});

it("abc1", () => {
it.skip("abc1", () => {
expect(nonNumericOnlyHash("abc1", 3)).toBe("abc");
});

it("ab11", () => {
it.skip("ab11", () => {
expect(nonNumericOnlyHash("ab11", 3)).toBe("ab1");
});

it("0111", () => {
it.skip("0111", () => {
expect(nonNumericOnlyHash("0111", 3)).toBe("a11");
});

it("911a", () => {
it.skip("911a", () => {
expect(nonNumericOnlyHash("911a", 3)).toBe("d11");
});

it("511a", () => {
it.skip("511a", () => {
expect(nonNumericOnlyHash("511a", 3)).toBe("f11");
});
Loading

0 comments on commit 7b84ba8

Please sign in to comment.