-
-
Notifications
You must be signed in to change notification settings - Fork 21
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 #352 from angrykoala/dev
2.0.0
- Loading branch information
Showing
126 changed files
with
4,545 additions
and
3,768 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
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 |
---|---|---|
|
@@ -59,3 +59,4 @@ typings/ | |
|
||
ncp/ | ||
.DS_Store | ||
dist/ |
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
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 @@ | ||
declare module 'compositer'; |
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 @@ | ||
declare module 'is-class'; |
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
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,11 @@ | ||
declare namespace WendigoUtils { | ||
function isVisible(element: HTMLElement): boolean; | ||
function queryElement(selector: string | HTMLElement): HTMLElement; | ||
function queryAll(selector: string | HTMLElement): Array<HTMLElement>; | ||
function xPathQuery(xPath: string): Array<HTMLElement>; | ||
function getStyles(element: string | HTMLElement): { [s: string]: string }; | ||
function mockDate(timestamp: number, freeze: boolean): void; | ||
function clearDateMock(): void; | ||
function findCssPath(node: HTMLElement): string; | ||
function findXPath(node: HTMLElement): string; | ||
} |
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,87 @@ | ||
import { rejectAssertion } from '../../utils/assert_utils'; | ||
import { isNumber } from '../../utils/utils'; | ||
import { WendigoSelector } from '../../types'; | ||
|
||
enum CountCase { | ||
equal = "equal", | ||
atLeast = "atLeast", | ||
atMost = "atMost", | ||
both = "both" | ||
} | ||
|
||
interface CountConfig { | ||
equal?: number; | ||
atLeast?: number; | ||
atMost?: number; | ||
} | ||
|
||
export function parseCountInput(count: CountConfig | number): CountConfig { | ||
let result: CountConfig; | ||
if (isNumber(count)) { | ||
result = { | ||
equal: Number(count) | ||
}; | ||
} else result = count; | ||
return result; | ||
} | ||
|
||
export function getCountCase(count: CountConfig): CountCase | null { | ||
let countCase: CountCase | null = null; | ||
if (isNumber(count.equal)) { | ||
countCase = CountCase.equal; | ||
} else { | ||
if (isNumber(count.atLeast)) { | ||
countCase = CountCase.atLeast; | ||
} | ||
if (isNumber(count.atMost)) { | ||
countCase = countCase ? CountCase.both : CountCase.atMost; | ||
} | ||
} | ||
return countCase; | ||
} | ||
|
||
export function makeAssertion(selector: WendigoSelector, countData: CountConfig, countCase: CountCase, elementsFound: number, msg?: string): Promise<void> { | ||
switch (countCase) { | ||
case CountCase.equal: | ||
return equalAssertion(countData, elementsFound, msg, selector); | ||
case CountCase.atLeast: | ||
return atLeastAssertion(countData, elementsFound, msg, selector); | ||
case CountCase.atMost: | ||
return atMostAssertion(countData, elementsFound, msg, selector); | ||
case CountCase.both: | ||
return bothAssertion(countData, elementsFound, msg, selector); | ||
} | ||
} | ||
|
||
async function equalAssertion(countData: CountConfig, elementsFound: number, msg: string | undefined, selector: WendigoSelector): Promise<void> { | ||
const expected = Number(countData.equal); | ||
if (elementsFound !== expected) { | ||
if (!msg) msg = `Expected selector "${selector}" to find exactly ${countData.equal} elements, ${elementsFound} found`; | ||
return rejectAssertion("assert.elements", msg, elementsFound, expected); | ||
} | ||
} | ||
|
||
async function atLeastAssertion(countData: CountConfig, elementsFound: number, msg: string | undefined, selector: WendigoSelector): Promise<void> { | ||
const expected = Number(countData.atLeast); | ||
if (elementsFound < expected) { | ||
if (!msg) msg = `Expected selector "${selector}" to find at least ${countData.atLeast} elements, ${elementsFound} found`; | ||
return rejectAssertion("assert.elements", msg); | ||
} | ||
} | ||
|
||
async function atMostAssertion(countData: CountConfig, elementsFound: number, msg: string | undefined, selector: WendigoSelector): Promise<void> { | ||
const expected = Number(countData.atMost); | ||
if (elementsFound > expected) { | ||
if (!msg) msg = `Expected selector "${selector}" to find up to ${countData.atMost} elements, ${elementsFound} found`; | ||
return rejectAssertion("assert.elements", msg); | ||
} | ||
} | ||
|
||
async function bothAssertion(countData: CountConfig, elementsFound: number, msg: string | undefined, selector: WendigoSelector): Promise<void> { | ||
const most = Number(countData.atMost); | ||
const least = Number(countData.atLeast); | ||
if (elementsFound < least || elementsFound > most) { | ||
if (!msg) msg = `Expected selector "${selector}" to find between ${countData.atLeast} and ${countData.atMost} elements, ${elementsFound} found`; // eslint-disable-line max-len | ||
return rejectAssertion("assert.elements", msg); | ||
} | ||
} |
Oops, something went wrong.