File

src/exported-tests/component-tests.ts

Index

Properties
Methods

Constructor

constructor(configs: object)
Parameters :
Name Type Optional
configs object No

Properties

Static defaults
Type : object
Default value : { selectors: { root: "" }, classes: {} }
settings
Type : any
Default value : {}
tests
Type : any[]
Default value : []

Methods

getComponent
getComponent(fragment, selector)
Parameters :
Name Optional
fragment No
selector No
Returns : any
getTests
getTests(tests)
Parameters :
Name Optional
tests No
Returns : any
import merge from "lodash-es/merge";

function isObject(val) {
	if (val === null) {
		return false;
	}
	return typeof val === "function" || typeof val === "object";
}

class ComponentTests {
	static defaults = {
		selectors: {
			root: ""
		},
		classes: {}
	};
	settings: any = {};
	tests: any[] = [];

	constructor(configs = {}) {
		this.settings = merge({}, ComponentTests.defaults, configs);
	}

	getTests(tests) {
		if (isObject(tests)) {
			return Object.keys(tests).map(i => tests[i]);
		}
		return tests;
	}

	getComponent(fragment, selector) {
		const root = fragment.querySelector(selector);
		return root;
	}
}

export default ComponentTests;

results matching ""

    No results matching ""