This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jarrodldavis/bugfix/template-tags
Add support for <template> tags
- Loading branch information
Showing
4 changed files
with
100 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,67 @@ | ||
import purgehtml from "./../index.js" | ||
import { TEST_1_CONTENT, TEST_1_TAG, TEST_1_CLASS, TEST_1_ID } from "./data" | ||
import { TEST_2_CONTENT, TEST_2_TAG, TEST_2_CLASS, TEST_2_ID } from "./data" | ||
|
||
describe("purgehtml", () => { | ||
it("finds tag selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_TAG) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
describe("from a normal html document", () => { | ||
it("finds tag selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_TAG) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds classes selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_CLASS) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
it("finds classes selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_CLASS) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds id selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_ID) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
it("finds id selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
for (let item of TEST_1_ID) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds all selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
const selectors = [...TEST_1_TAG, ...TEST_1_CLASS, ...TEST_1_ID] | ||
for (let item of selectors) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
}); | ||
|
||
describe("from a template tag", () => { | ||
it("finds tag selectors", () => { | ||
const received = purgehtml.extract(TEST_2_CONTENT) | ||
for (let item of TEST_2_TAG) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds classes selectors", () => { | ||
const received = purgehtml.extract(TEST_2_CONTENT) | ||
for (let item of TEST_2_CLASS) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds id selectors", () => { | ||
const received = purgehtml.extract(TEST_2_CONTENT) | ||
for (let item of TEST_2_ID) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
|
||
it("finds all selectors", () => { | ||
const received = purgehtml.extract(TEST_1_CONTENT) | ||
const selectors = [...TEST_1_TAG, ...TEST_1_CLASS, ...TEST_1_ID] | ||
for (let item of selectors) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
it("finds all selectors", () => { | ||
const received = purgehtml.extract(TEST_2_CONTENT) | ||
const selectors = [...TEST_2_TAG, ...TEST_2_CLASS, ...TEST_2_ID] | ||
for (let item of selectors) { | ||
expect(received.includes(item)).toBe(true) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
testEnvironment: "node" | ||
} |