Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/__fixtures__/curriculum-helpers-javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ const arrowFunction = `const myFunc = name => console.log("Name")`;

const destructuredArgsFunctionDeclaration = `function printFruits({a, b},c = 1, ...rest) {`;

// eslint-disable-next-line no-template-curly-in-string
const jsCodeTemplateCurlyComment = "const v = /*a*/`/*b*/${/*c*/12}`";

// eslint-disable-next-line no-template-curly-in-string
const jsCodeTemplateCurlyNoComments = "const v = `/*b*/${12}`";

const testValues = {
jsCodeWithSingleAndMultLineComments,
jsCodeWithSingleAndMultLineCommentsRemoved,
Expand All @@ -81,6 +87,8 @@ const testValues = {
letFunction,
arrowFunction,
destructuredArgsFunctionDeclaration,
jsCodeTemplateCurlyComment,
jsCodeTemplateCurlyNoComments
};

export default testValues;
7 changes: 7 additions & 0 deletions lib/__tests__/curriculum-helper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const {
jsCodeWithNoArgCall,
jsCodeWithArgCall,
jsCodeWithCommentedCall,
jsCodeTemplateCurlyComment,
jsCodeTemplateCurlyNoComments
} = jsTestValues;

describe("RandomMocker", () => {
Expand Down Expand Up @@ -107,6 +109,11 @@ describe("removeJSComments", () => {
it("does not remove a url found in JS code", () => {
expect(removeJSComments(jsCodeWithUrl)).toBe(jsCodeWithUrlUnchanged);
});

it("returns a string with no comments in template expressions", () =>
{
expect(removeJSComments(jsCodeTemplateCurlyComment)).toBe(jsCodeTemplateCurlyNoComments);
})
});

describe("removeCssComments", () => {
Expand Down
Loading