html_checks v1.2.9
BaseTest
The purpose of this repository is to allow users to more easily test for the various elements in their html documents.
Directions
- Install the package
npm install html_checks
- In your html document, import the script (make sure to import it after your JQuery script, and before your javascript file)
<script src="./node_modules/html_checks/index.js"></script>
<script>
$(() => {
console.log("hello")
let el = ".yonas"
let love = $(".love")
let hasClass = html_checks.hasClass(el, "yonas")
let hasClassFalse = html_checks.hasClass(el, "no")
console.log('hasClassFalse:', hasClassFalse);
console.log('hasClass:', hasClass);
let hasIdTrue = html_checks.hasId(el, "yon")
console.log('hasIdTrue:', hasIdTrue);
let hasIdFalse = html_checks.hasId(el, "whatsup")
console.log('hasIdFalse:', hasIdFalse);
let hasAttrTrue = html_checks.hasAttr(el, "disabled")
console.log('hasAttrTrue:', hasAttrTrue);
let hasAttrFalse = html_checks.hasAttr(el, "no")
console.log('hasAttrFalse:', hasAttrFalse);
let hasDataTrue = html_checks.hasDataTest(el, "problem_id")
console.log('hasDataTrue:', hasDataTrue);
let hasDataFalse = html_checks.hasDataTest(el, "task_id")
console.log('hasDataFalse:', hasDataFalse);
let hasDataTrueTrue = html_checks.hasDataTest(el, "problem_id", 32)
console.log("🚀 ~ file: html_checks.js ~ line 76 ~ hasDataTrueTrue", hasDataTrueTrue)
let hasDataTrueTrue2 = html_checks.hasDataTest(el, "problem_id", "3")
console.log("🚀 ~ file: html_checks.js ~ line 78 ~ hasDataTrueTrue2", hasDataTrueTrue2)
let htmlTrue = html_checks.hasHTML(el, "<div>baller</div>")
console.log("🚀 ~ file: html_checks.js ~ line 80 ~ htmlTrue", htmlTrue)
let htmlFalse = html_checks.hasHTML(el, "whatthef")
console.log("🚀 ~ file: html_checks.js ~ line 82 ~ htmlFalse", htmlFalse)
let htmltext = html_checks.hasHTML(el, "ll")
console.log("🚀 ~ file: html_checks.js ~ line 84 ~ htmltext", htmltext)
let existTrue = html_checks.exists(el)
console.log("🚀 ~ file: html_checks.js ~ line 90 ~ existTrue", existTrue)
let existFalse = html_checks.exists($(".love"))
console.log("🚀 ~ file: html_checks.js ~ line 92 ~ existFalse", existFalse)
let visibleTrue = html_checks.visible(el)
console.log("🚀 ~ file: html_checks.js ~ line 91 ~ visibleTrue", visibleTrue)
let visibleFalse = html_checks.visible($(".noDisplay"))
console.log("🚀 ~ file: html_checks.js ~ line 93 ~ visibleFalse", visibleFalse)
let hasCSSFalse = html_checks.hasCSS(el, "color", "#6f57e5")
console.log("🚀 ~ file: html_checks.js ~ line 95 ~ hasCSSFalse", hasCSSFalse)
let hasCSSTrue = html_checks.hasCSS(el, "display", "flex")
console.log("🚀 ~ file: html_checks.js ~ line 97 ~ hasCSSTrue", hasCSSTrue)
let hasChildTrue = html_checks.hasChild(el, $(".supergrandchild"))
console.log("🚀 ~ file: html_checks.js ~ line 101 ~ hasChildTrue", hasChildTrue)
let ChildTrue1 = html_checks.hasChild(el, ".supergrandchild")
console.log("🚀 ~ file: html_checks.js ~ line 103 ~ ChildTrue1", ChildTrue1)
let hasChildFalse = html_checks.hasChild(el, ".what")
console.log("🚀 ~ file: html_checks.js ~ line 105 ~ hasChildFalse", hasChildFalse)
})
</script>
- Create javascript file - make sure to put all your jquery selectors after the instantiator - e.g.,
$(() => {
let firstTest = html_checks.hasClass($(".test"), ".red-text")
console.log("first test passed", firstTest)
})
- ~BaseTest(#module_html_checks.. BaseTest)
- new BaseTest()
- .checkElement(el) ⇒ boolean
- .STRING_HAS(one, two) ⇒ boolean
- .STRING_COUNT(type, item, amount) ⇒ boolean
- .STRING_ATLEAST(type, item, amount) ⇒ boolean
- .STRING_DOESNOTHAVE(string, item) ⇒ boolean
- .hasClass(element, classname) ⇒ boolean
- .hasId(element, id) ⇒ boolean
- .hasAttr(element, attribute) ⇒ boolean
- .hasDataTest(element, key, value) ⇒ boolean
- .hasHTML(element, html) ⇒ boolean
- .hasChild(element, child) ⇒ boolean
- .exists(element) ⇒ boolean
- .visible(element) ⇒ boolean
- .hasCSS(element, key, value) ⇒ boolean
new BaseTest()
let baseTest = new BaseTest()
html_checks.checkElement(el) ⇒ boolean
ensures that you can pass in jquery or string
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
el | any |
html_checks. STRING_HAS(one, two) ⇒ boolean
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-02-13
Param | Type |
---|---|
one | any |
two | any |
Example
const getHAS = html_checks.STRING_HAS("helllo", "lo")
console.log("🚀 ~ file: test.js ~ line 5 ~ getHAS", getHAS)
const getNeg = html_checks.STRING_HAS("hello", "z")
console.log("🚀 ~ file: test.js ~ line 7 ~ getNeg", getNeg)
html_checks. STRING_COUNT(type, item, amount) ⇒ boolean
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-02-13
Param | Type |
---|---|
type | any |
item | any |
amount | any |
Example
const getCount = html_checks.STRING_COUNT("hello hello", "llo", 2)
console.log("🚀 ~ file: test.js ~ line 7 ~ getCount", getCount)
const getNegC = html_checks.STRING_COUNT("hello", "z", 2)
console.log("🚀 ~ file: test.js ~ line 11 ~ getNegC", getNegC)
html_checks. STRING_ATLEAST(type, item, amount) ⇒ boolean
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-02-13
Param | Type |
---|---|
type | any |
item | any |
amount | any |
Example
const getAtLeast = html_checks.STRING_ATLEAST("hello", "l", 1)
console.log("🚀 ~ file: test.js ~ line 9 ~ gtAtLeast", getAtLeast)
const getAtLeastNeg = html_checks.STRING_ATLEAST("hello", "z", 1)
console.log("🚀 ~ file: test.js ~ line 16 ~ getAtLeastNeg", getAtLeastNeg)
html_checks. STRING_DOESNOTHAVE(string, item) ⇒ boolean
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-02-13
Param | Type |
---|---|
string | any |
item | any |
Example
const doesNotHave = html_checks.STRING_DOESNOTHAVE("hello", "z")
console.log("🚀 ~ file: test.js ~ line 11 ~ doesNotHave", doesNotHave)
const doesNotHaveNeg = html_checks.STRING_DOESNOTHAVE("hello", "ll")
console.log("🚀 ~ file: test.js ~ line 19 ~ doesNotHaveNeg", doesNotHaveNeg)
html_checks.hasClass(element, classname) ⇒ boolean
hasClass(element, classname)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
classname | any |
Example
let hasClass = html_checks.hasClass(el, "yonas")
let hasClassFalse = html_checks.hasClass(el, "no")
html_checks.hasId(element, id) ⇒ boolean
hasId(element, id)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
id | any |
Example
let hasIdTrue = html_checks.hasId(el, "yon")
console.log('hasIdTrue:', hasIdTrue);
let hasIdFalse = html_checks.hasId(el, "whatsup")
console.log('hasIdFalse:', hasIdFalse);
html_checks.hasAttr(element, attribute) ⇒ boolean
hasAttr(element, attribute)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
attribute | any |
Example
let hasAttrTrue = html_checks.hasAttr(el, "disabled")
console.log('hasAttrTrue:', hasAttrTrue);
let hasAttrFalse = html_checks.hasAttr(el, "no")
console.log('hasAttrFalse:', hasAttrFalse);
html_checks.hasDataTest(element, key, value) ⇒ boolean
hasDataTest(element, key, value = "")
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type | Default |
---|---|---|
element | any | |
key | any | |
value | any | " " |
Example
let hasDataTrue = html_checks.hasDataTest(el, "problem_id")
console.log('hasDataTrue:', hasDataTrue);
let hasDataFalse = html_checks.hasDataTest(el, "task_id")
console.log('hasDataFalse:', hasDataFalse);
let hasDataTrueTrue = html_checks.hasDataTest(el, "problem_id", 3)
console.log("🚀 ~ file: html_checks.js ~ line 76 ~ hasDataTrueTrue", hasDataTrueTrue)
let hasDataTrueTrue2 = html_checks.hasDataTest(el, "problem_id", "3")
console.log("🚀 ~ file: html_checks.js ~ line 78 ~ hasDataTrueTrue2", hasDataTrueTrue2)
html_checks.hasHTML(element, html) ⇒ boolean
hasHTML(element, html)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
html | any |
Example
let htmlTrue = html_checks.hasHTML(el, "<div>baller</div>")
console.log("🚀 ~ file: html_checks.js ~ line 80 ~ htmlTrue", htmlTrue)
let htmlFalse = html_checks.hasHTML(el, "whatthef")
console.log("🚀 ~ file: html_checks.js ~ line 82 ~ htmlFalse", htmlFalse)
let htmltext = html_checks.hasHTML(el, "ll")
console.log("🚀 ~ file: html_checks.js ~ line 84 ~ htmltext", htmltext)
html_checks.hasChild(element, child) ⇒ boolean
hasChild(element, child)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
child | any |
Example
let ChildTrue1 = html_checks.hasChild(el, ".supergrandchild")
console.log("🚀 ~ file: html_checks.js ~ line 103 ~ ChildTrue1", ChildTrue1)
let hasChildFalse = html_checks.hasChild(el, ".what")
console.log("🚀 ~ file: html_checks.js ~ line 105 ~ hasChildFalse", hasChildFalse)
html_checks.exists(element) ⇒ boolean
exists(element)
let existTrue = html_checks.exists(el)
console.log("🚀 ~ file: html_checks.js ~ line 90 ~ existTrue", existTrue)
let existFalse = html_checks.exists($(".love"))
console.log("🚀 ~ file: html_checks.js ~ line 92 ~ existFalse", existFalse)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
html_checks.visible(element) ⇒ boolean
visible(element)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
Example
let visibleTrue = html_checks.visible(el)
console.log("🚀 ~ file: html_checks.js ~ line 91 ~ visibleTrue", visibleTrue)
let visibleFalse = html_checks.visible($(".noDisplay"))
console.log("🚀 ~ file: html_checks.js ~ line 93 ~ visibleFalse", visibleFalse)
html_checks.hasCSS(element, key, value) ⇒ boolean
hasCSS(element, key, value)
let hasCSSFalse = html_checks.hasCSS(el, "color", "#6f57e5")
console.log("🚀 ~ file: html_checks.js ~ line 95 ~ hasCSSFalse", hasCSSFalse)
let hasCSSTrue = html_checks.hasCSS(el, "display", "flex")
console.log("🚀 ~ file: html_checks.js ~ line 97 ~ hasCSSTrue", hasCSSTrue)
Kind: instance method of BaseTest(#module_html_checks.. BaseTest)
Date: 2022-01-05
Param | Type |
---|---|
element | any |
key | any |
value | any |