File

src/checkbox/checkbox-exported-tests.ts

Extends

ComponentTests

Index

Properties
Methods

Constructor

constructor(configs)
Parameters :
Name Optional
configs No

Properties

Static defaults
Type : object
Default value : { selectors: { root: "" }, classes: {} }
Inherited from ComponentTests
Defined in ComponentTests:11
settings
Type : any
Default value : {}
Inherited from ComponentTests
Defined in ComponentTests:17
tests
Type : any[]
Default value : []
Inherited from ComponentTests
Defined in ComponentTests:18

Methods

structure
structure()
Returns : {}
getComponent
getComponent(fragment, selector)
Inherited from ComponentTests
Defined in ComponentTests:31
Parameters :
Name Optional
fragment No
selector No
Returns : any
getTests
getTests(tests)
Inherited from ComponentTests
Defined in ComponentTests:24
Parameters :
Name Optional
tests No
Returns : any
import { expect } from "chai";
import merge from "lodash-es/merge";
import ComponentTests from "../exported-tests/component-tests";

const defaults = {
	selectors: {
		root: "cds-checkbox",
		input: "input"
	}
};

class CheckboxExportedTests extends ComponentTests {
	constructor(configs) {
		super(merge({}, defaults, configs));
		this.tests = this.tests.concat(this.structure());
	}

	structure() {
		const tests = [
			{
				name: "initially be unchecked, be checked on click",
				getActual: fragment =>
					new Promise(resolve => {
						const component = this.getComponent(
							fragment,
							`${this.settings.selectors.root} ${this.settings.selectors.input}`
						);
						const initialState = component.checked;
						component.click();
						const afterClickState = component.checked;
						resolve({
							initialState,
							afterClickState
						});
					}),
					runComparison: results => {
					// tslint:disable-next-line
					expect(results.initialState).to.be.false;
					// tslint:disable-next-line
					expect(results.afterClickState).to.be.true;
				}
			}
		];
		return [{
			name: "Basic checkbox tests",
			tests: this.getTests(tests)
		}];
	}
}

export default CheckboxExportedTests;

results matching ""

    No results matching ""