Skip to content

Commit

Permalink
test: increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jan 17, 2017
1 parent 1ec01ad commit 5652281
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
20 changes: 20 additions & 0 deletions test/utilities/getAttributeSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @flow

import test from 'ava';
import {
NotFoundError
} from '../../src';
import getAttributeSelector from '../../src/utilities/getAttributeSelector';

test('returns the attribute selector', (t): void => {
t.deepEqual(getAttributeSelector('a@href'), {
attributeName: 'href',
expression: '@href'
});
});

test('throws an error if the attribute selector is not present', (t): void => {
t.throws(() => {
getAttributeSelector('a');
}, NotFoundError);
});
20 changes: 20 additions & 0 deletions test/utilities/getPropertySelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @flow

import test from 'ava';
import {
NotFoundError
} from '../../src';
import getPropertySelector from '../../src/utilities/getPropertySelector';

test('returns the property selector', (t): void => {
t.deepEqual(getPropertySelector('a@.textContent'), {
expression: '@.textContent',
propertyName: 'textContent'
});
});

test('throws an error if the property selector is not present', (t): void => {
t.throws(() => {
getPropertySelector('a');
}, NotFoundError);
});
4 changes: 2 additions & 2 deletions test/utilities/getQuantifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../src';
import getQuantifier from '../../src/utilities/getQuantifier';

test('returns the quantifier', (t): void => {
test('returns the quantifier expression', (t): void => {
t.deepEqual(getQuantifier('{1,1}'), {
accessor: null,
expression: '{1,1}',
Expand Down Expand Up @@ -45,7 +45,7 @@ test('returns the quantifier', (t): void => {
});
});

test('throws an error if a quantifier is not present', (t): void => {
test('throws an error if the quantifier expression is not present', (t): void => {
t.throws(() => {
getQuantifier('');
}, NotFoundError);
Expand Down
12 changes: 12 additions & 0 deletions test/utilities/hasAttributeSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow

import test from 'ava';
import hasAttributeSelector from '../../src/utilities/hasAttributeSelector';

test('returns true if the attribute selector is present', (t): void => {
t.true(hasAttributeSelector('a@href') === true);
});

test('returns false if the attribute selector is not present', (t): void => {
t.true(hasAttributeSelector('a') === false);
});
12 changes: 12 additions & 0 deletions test/utilities/hasPropertySelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow

import test from 'ava';
import hasPropertySelector from '../../src/utilities/hasPropertySelector';

test('returns true if the property selector is present', (t): void => {
t.true(hasPropertySelector('a@.href') === true);
});

test('returns false if the property selector is not present', (t): void => {
t.true(hasPropertySelector('a') === false);
});
4 changes: 2 additions & 2 deletions test/utilities/hasQuantifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import test from 'ava';
import hasQuantifier from '../../src/utilities/hasQuantifier';

test('returns true if quantifier is present', (t): void => {
test('returns true if the quantifier expression is present', (t): void => {
t.true(hasQuantifier('{1}') === true);
t.true(hasQuantifier('{1,}') === true);
t.true(hasQuantifier('{0,1}') === true);
Expand All @@ -12,6 +12,6 @@ test('returns true if quantifier is present', (t): void => {
t.true(hasQuantifier('{0,1}[0]') === true);
});

test('returns false if quantifier is not present', (t): void => {
test('returns false if the quantifier expression is not present', (t): void => {
t.true(hasQuantifier('.foo') === false);
});

0 comments on commit 5652281

Please sign in to comment.