How to use the fontoxpath/selectors/Specificity function in fontoxpath

To help you get started, we’ve selected a few fontoxpath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FontoXML / fontoxpath / test / specs / selectors / operators / UnionOperator.tests.js View on Github external
import Specificity from 'fontoxpath/selectors/Specificity';
import Union from 'fontoxpath/selectors/operators/Union';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('Union.equals()', () => {
	it('returns true if compared with itself', () => {
		const unionOperator1 = new Union([equalSelector, equalSelector]),
			unionOperator2 = unionOperator1;
		chai.assert.isTrue(unionOperator1.equals(unionOperator2));
		chai.assert.isTrue(unionOperator2.equals(unionOperator1));
	});

	it('it returns true if compared with an equal other Union', () => {
github FontoXML / fontoxpath / test / specs / selectors / quantified / QuantifiedExpression.tests.js View on Github external
import FunctionCall from 'fontoxpath/selectors/functions/FunctionCall';
import NamedFunctionRef from 'fontoxpath/selectors/NamedFunctionRef';
import QuantifiedExpression from 'fontoxpath/selectors/quantified/QuantifiedExpression';
import Specificity from 'fontoxpath/selectors/Specificity';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('QuantifiedExpression.equals()', () => {
	it('returns true if compared with itself', () => {
		const quantifiedExpr1 = new QuantifiedExpression('every', [
				['x', new FunctionCall(new NamedFunctionRef('true', 0), [])]
			], equalSelector),
			quantifiedExpr2 = quantifiedExpr1;
		chai.assert.isTrue(quantifiedExpr1.equals(quantifiedExpr2));
		chai.assert.isTrue(quantifiedExpr2.equals(quantifiedExpr1));
	});

	it('it returns true if compared with an equal other QuantifiedExpression', () => {
		const quantifiedExpr1 = new QuantifiedExpression('every', [
				['x', new FunctionCall(new NamedFunctionRef('true', 0), [])]
github FontoXML / fontoxpath / test / specs / selectors / axes / ChildAxis.tests.js View on Github external
import ChildAxis from 'fontoxpath/selectors/axes/ChildAxis';
import Specificity from 'fontoxpath/selectors/Specificity';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('ChildAxis.equals()', () => {
	it('returns true if compared with itself', () => {
		const child1 = new ChildAxis(equalSelector),
			child2 = child1;
		chai.assert.isTrue(child1.equals(child2));
		chai.assert.isTrue(child2.equals(child1));
	});

	it('returns true if compared with an equal other ChildAxis', () => {
github FontoXML / fontoxpath / test / specs / selectors / maps / MapConstructor.tests.js View on Github external
import Specificity from 'fontoxpath/selectors/Specificity';
import MapConstructor from 'fontoxpath/selectors/maps/MapConstructor';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('MapConstructor.equals()', () => {
	it('returns true if compared with itself', () => {
		const map1 = new MapConstructor([{ key: equalSelector, value: equalSelector }]),
			map2 = map1;
		chai.assert.isTrue(map1.equals(map2));
		chai.assert.isTrue(map2.equals(map1));
	});

	it('returns true if compared with an equal other MapConstructor', () => {
github FontoXML / fontoxpath / test / specs / selectors / operators / boolean / NotOperator.tests.js View on Github external
import Specificity from 'fontoxpath/selectors/Specificity';
import NotOperator from 'fontoxpath/selectors/operators/boolean/NotOperator';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('NotOperator.equals()', () => {
	it('is equal if compared with itself', () => {
		const not1 = new NotOperator(equalSelector),
			not2 = not1;
		chai.expect(not1.equals(not2)).to.equal(true);
		chai.expect(not2.equals(not1)).to.equal(true);
	});

	it('is equal if compared with an equal other NotOperator', () => {
github FontoXML / fontoxpath / test / specs / selectors / operators / boolean / OrOperator.tests.js View on Github external
import Specificity from 'fontoxpath/selectors/Specificity';
import OrOperator from 'fontoxpath/selectors/operators/boolean/OrOperator';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true),
		getBucket: sinon.stub().returns(null)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false),
		getBucket: sinon.stub().returns(null)
	};

describe('OrOperator.equals()', () => {
	it('returns true if compared with itself', () => {
		const or1 = new OrOperator([equalSelector, equalSelector]),
			or2 = or1;
		chai.assert.isTrue(or1.equals(or2));
		chai.assert.isTrue(or2.equals(or1));
	});
github FontoXML / fontoxpath / test / specs / selectors / axes / AncestorAxis.tests.js View on Github external
import AncestorAxis from 'fontoxpath/selectors/axes/AncestorAxis';
import Specificity from 'fontoxpath/selectors/Specificity';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('AncestorAxis.equals()', () => {
	it('returns true if compared with itself', () => {
		const ancestor1 = new AncestorAxis(equalSelector),
			ancestor2 = ancestor1;
		chai.assert.isTrue(ancestor1.equals(ancestor2));
		chai.assert.isTrue(ancestor2.equals(ancestor1));
	});

	it('returns true if compared with an equal other AncestorAxis', () => {
github FontoXML / fontoxpath / test / specs / selectors / axes / ParentAxis.tests.js View on Github external
import ParentAxis from 'fontoxpath/selectors/axes/ParentAxis';
import Specificity from 'fontoxpath/selectors/Specificity';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('ParentAxis.equals()', () => {
	it('returns true if compared with itself', () => {
		const parent1 = new ParentAxis(equalSelector),
			parent2 = parent1;
		chai.assert.isTrue(parent1.equals(parent2));
		chai.assert.isTrue(parent2.equals(parent1));
	});

	it('returns true if compared with an equal other ParentAxis', () => {
		const parent1 = new ParentAxis(equalSelector),
			parent2 = new ParentAxis(equalSelector);
		chai.assert.isTrue(parent1.equals(parent2));
		chai.assert.isTrue(parent2.equals(parent1));
github FontoXML / fontoxpath / test / specs / selectors / operators / numeric / Unary.tests.js View on Github external
import Unary from 'fontoxpath/selectors/operators/numeric/Unary';
import Specificity from 'fontoxpath/selectors/Specificity';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('Unary.equals()', () => {
	it('returns true if compared with itself', () => {
		const unary1 = new Unary('+', equalSelector),
			unary2 = unary1;
		chai.assert.isTrue(unary1.equals(unary2));
		chai.assert.isTrue(unary2.equals(unary1));
	});

	it('it returns true if compared with an equal other Unary', () => {
github FontoXML / fontoxpath / test / specs / selectors / arrays / ArrayConstructor.tests.js View on Github external
import Specificity from 'fontoxpath/selectors/Specificity';
import ArrayConstructor from 'fontoxpath/selectors/arrays/ArrayConstructor';

const equalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(true)
	},
	unequalSelector = {
		specificity: new Specificity({}),
		equals: sinon.stub().returns(false)
	};

describe('ArrayConstructor.equals()', () => {
	it('returns true if compared with itself', () => {
		const array1 = new ArrayConstructor('square', [equalSelector]),
			array2 = array1;
		chai.assert.isTrue(array1.equals(array2));
		chai.assert.isTrue(array2.equals(array1));
	});

	it('returns true if compared with an equal other ArrayConstructor', () => {