webpack/test/RawModule.unittest.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-01-18 22:27:19 +08:00
"use strict";
const RawModule = require("../lib/RawModule");
const RequestShortener = require("../lib/RequestShortener");
const path = require("path");
describe("RawModule", () => {
2018-01-24 20:17:21 +08:00
const source = "sourceStr attribute";
const identifier = "identifierStr attribute";
const readableIdentifier = "readableIdentifierStr attribute";
const myRawModule = new RawModule(source, identifier, readableIdentifier);
2017-01-18 22:27:19 +08:00
describe("identifier", () => {
2018-01-24 20:17:21 +08:00
it("returns value for identifierStr attribute", () => {
expect(myRawModule.identifier()).toBe("identifierStr attribute");
});
});
2017-01-18 22:27:19 +08:00
describe("size", () => {
2018-02-25 18:46:17 +08:00
it('returns value for sourceStr attribute"s length property', () => {
2017-01-18 22:27:19 +08:00
const sourceStrLength = myRawModule.sourceStr.length;
2018-01-24 20:17:21 +08:00
expect(myRawModule.size()).toBe(sourceStrLength);
});
});
2017-01-18 22:27:19 +08:00
describe("readableIdentifier", () => {
2018-02-25 18:46:17 +08:00
it(
'returns result of calling provided requestShortener"s shorten method ' +
"on readableIdentifierStr attribute",
2017-02-10 06:38:39 +08:00
() => {
const requestShortener = new RequestShortener(path.resolve());
2018-01-24 20:17:21 +08:00
expect(myRawModule.readableIdentifier(requestShortener)).toBeDefined();
2017-02-10 06:38:39 +08:00
}
);
});
});