Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jan 23, 2020
1 parent 575c01d commit 0aef7ee
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 64 deletions.
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
"url": "http://gajus.com"
},
"ava": {
"babel": {
"compileAsTests": [
"test/helpers/**/*"
]
},
"files": [
"test/**/*"
],
"helpers": [
"test/helpers/**/*"
"test/surgeon/**/*"
],
"require": [
"@babel/register"
],
"sources": [
"src/**/*"
]
},
"dependencies": {
Expand All @@ -27,25 +26,26 @@
},
"description": "Declarative DOM extraction expression evaluator.",
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/node": "^7.7.0",
"@babel/plugin-transform-flow-strip-types": "^7.6.3",
"@babel/preset-env": "^7.7.1",
"@babel/register": "^7.7.0",
"ava": "^2.4.0",
"babel-plugin-istanbul": "^5.2.0",
"@ava/babel": "^1.0.0",
"@babel/cli": "^7.8.3",
"@babel/core": "^7.8.3",
"@babel/node": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/register": "^7.8.3",
"ava": "^3.0.0",
"babel-plugin-istanbul": "^6.0.0",
"babel-plugin-transform-export-default-name": "^2.0.4",
"coveralls": "^3.0.8",
"eslint": "^6.6.0",
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"eslint-config-canonical": "^18.1.0",
"flow-bin": "^0.112.0",
"flow-bin": "^0.116.1",
"flow-copy-source": "^2.0.9",
"husky": "^3.1.0",
"husky": "^4.2.0",
"lodash": "^4.17.15",
"nyc": "^14.1.1",
"semantic-release": "^15.13.31",
"sinon": "^7.5.0",
"nyc": "^15.0.0",
"semantic-release": "^16.0.3",
"sinon": "^8.1.1",
"sprintf-js": "^1.1.2"
},
"engines": {
Expand Down
26 changes: 16 additions & 10 deletions test/surgeon/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('ra: reads element attribute', (t): void => {
const query = 'select .foo | ra class';

t.true(x(query, subject) === 'foo');
t.is(x(query, subject), 'foo');
});

test('so: selects one element', (t): void => {
Expand All @@ -76,7 +76,7 @@ test('so: selects one element', (t): void => {

const query = 'so .foo | read property textContent';

t.true(x(query, subject) === 'foo 0');
t.is(x(query, subject), 'foo 0');
});

test('so: selects one element (multiple matches)', (t): void => {
Expand All @@ -91,9 +91,11 @@ test('so: selects one element (multiple matches)', (t): void => {

const query = 'so .foo | read property textContent';

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('so: select one element (no matches)', (t): void => {
Expand All @@ -105,9 +107,11 @@ test('so: select one element (no matches)', (t): void => {

const query = 'so .foo | read property textContent';

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('sm: selects many elements', (t): void => {
Expand All @@ -134,9 +138,11 @@ test('sm: selects many elements (no matches)', (t): void => {

const query = 'sm .foo | read property textContent';

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('sa: selects any elements', (t): void => {
Expand Down Expand Up @@ -178,7 +184,7 @@ test('saf: selects first out of any matches (multiple matches)', (t): void => {

const query = 'saf .foo | read property textContent';

t.true(x(query, subject) === 'foo 0');
t.is(x(query, subject), 'foo 0');
});

test('saf: selects first out of any matches (no matches)', (t): void => {
Expand All @@ -190,5 +196,5 @@ test('saf: selects first out of any matches (no matches)', (t): void => {

const query = 'saf .foo | read property textContent';

t.true(x(query, subject) === null);
t.is(x(query, subject), null);
});
12 changes: 8 additions & 4 deletions test/surgeon/queries/multiple-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ test('throws error if too few nodes are matched', (t): void => {
'select .foo {3,}',
];

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('throws error if too many nodes are matched', (t): void => {
Expand All @@ -109,7 +111,9 @@ test('throws error if too many nodes are matched', (t): void => {
'select .foo {0,2}',
];

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});
18 changes: 11 additions & 7 deletions test/surgeon/queries/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('does not mutate the parent node', (t) => {
// `s time | rdtc` removes the descending nodes, including <attributes>.
const query: DenormalizedQueryType = [
'so a',
/* eslint-disable sort-keys */
/* eslint-disable sort-keys-fix/sort-keys-fix */
{
time: 'so time | rdtc',
attributes: 'so attributes | rdtc',
Expand Down Expand Up @@ -72,7 +72,7 @@ test('removes nothing if no nodes are matched {0,1}', (t) => {

const query: DenormalizedQueryType = 'select .foo | remove .bar {0,1} | read property innerHTML';

t.true(trim(x(query, subject)) === '<div class="baz"></div>');
t.is(trim(x(query, subject)), '<div class="baz"></div>');
});

test('removes multiple elements {0,}', (t) => {
Expand All @@ -89,7 +89,7 @@ test('removes multiple elements {0,}', (t) => {

const query: DenormalizedQueryType = 'select .foo | remove .baz {0,} | read property innerHTML';

t.true(trim(x(query, subject)) === '<div class="bar"></div>');
t.is(trim(x(query, subject)), '<div class="bar"></div>');
});

test('throws error if no nodes are matched', (t): void => {
Expand All @@ -104,9 +104,11 @@ test('throws error if no nodes are matched', (t): void => {

const query: DenormalizedQueryType = 'select .foo | remove .qux | read property innerHTML';

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('throws error if more than one node is matched', (t): void => {
Expand All @@ -121,7 +123,9 @@ test('throws error if more than one node is matched', (t): void => {

const query: DenormalizedQueryType = 'select .foo | remove .bar | read property innerHTML';

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});
26 changes: 15 additions & 11 deletions test/surgeon/queries/single-match.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('extracts a single value (expression string)', (t): void => {

const query: DenormalizedQueryType = 'select .foo | read property textContent';

t.true(x(query, subject) === 'bar');
t.is(x(query, subject), 'bar');
});

test('short-circuits an expression if optional selector does not match anything', (t): void => {
Expand All @@ -29,7 +29,7 @@ test('short-circuits an expression if optional selector does not match anything'

const query: DenormalizedQueryType = 'select .bar {0,1} | read property textContent';

t.true(x(query, subject) === null);
t.is(x(query, subject), null);
});

test('extracts a single value (array of expressions)', (t): void => {
Expand All @@ -44,7 +44,7 @@ test('extracts a single value (array of expressions)', (t): void => {
'read property textContent',
];

t.true(x(query, subject) === 'bar');
t.is(x(query, subject), 'bar');
});

test('extracts a single value (quantifier max 1)', (t): void => {
Expand All @@ -59,7 +59,7 @@ test('extracts a single value (quantifier max 1)', (t): void => {
'read property textContent',
];

t.true(x(query, subject) === 'bar');
t.is(x(query, subject), 'bar');
});

test('throws error if no nodes are matched', (t): void => {
Expand All @@ -71,9 +71,11 @@ test('throws error if no nodes are matched', (t): void => {
'select .foo',
];

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

test('throws error if more than one node is matched', (t): void => {
Expand All @@ -88,9 +90,11 @@ test('throws error if more than one node is matched', (t): void => {
'select .foo',
];

t.throws((): void => {
const error = t.throws((): void => {
x(query, subject);
}, SelectSubroutineUnexpectedResultCountError);
});

t.true(error instanceof SelectSubroutineUnexpectedResultCountError);
});

// @todo Test with both evaluators.
Expand All @@ -103,7 +107,7 @@ test('reads childNodes', (t): void => {

const query: DenormalizedQueryType = 'select .foo | read property childNodes';

t.true(x(query, subject)[0].nodeValue === 'bar');
t.is(x(query, subject)[0].nodeValue, 'bar');
});

test('extracts a single value (expression string [foo*="bar"])', (t): void => {
Expand All @@ -116,7 +120,7 @@ test('extracts a single value (expression string [foo*="bar"])', (t): void => {
// eslint-disable-next-line quotes
const query: DenormalizedQueryType = `select '[foo*="bar"]' | read property textContent`;

t.true(x(query, subject) === 'bar');
t.is(x(query, subject), 'bar');
});

// @see https://github.com/fb55/css-select/issues/111
Expand All @@ -132,7 +136,7 @@ test.skip('extracts a single value (expression string `.foo:has(+.bar)`)', (t):
// eslint-disable-next-line quotes
const query: DenormalizedQueryType = `select '.foo:has(+.bar)' | read property textContent`;

t.true(x(query, subject) === 'foo');
t.is(x(query, subject), 'foo');
});

test('extracts a single value (using inline subroutine)', (t): void => {
Expand Down
6 changes: 4 additions & 2 deletions test/surgeon/subroutines/closestSubroutine.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ test('throws an error if node cannot be found', (t): void => {

const query: DenormalizedQueryType = 'select .baz | closest .foo | read property textContent';

t.throws(() => {
const error = t.throws(() => {
x(query, subject);
}, 'Cannot find a preceding node matching the provided CSS selector.');
});

t.is(error.message, 'Cannot find a preceding node matching the provided CSS selector.');
});
10 changes: 6 additions & 4 deletions test/surgeon/subroutines/formatSubroutine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import test from 'ava';
import formatSubroutine from '../../../src/subroutines/formatSubroutine';

test('throws an error if subject is not a string', (t): void => {
t.throws((): void => {
const error = t.throws((): void => {
// $FlowFixMe
formatSubroutine(123);
}, 'Input is not a string.');
});

t.is(error.message, 'Input is not a string.');
});

test('default format returns subject', (t): void => {
t.true(formatSubroutine('foo') === 'foo');
t.is(formatSubroutine('foo'), 'foo');
});

test('formats string using printf', (t): void => {
t.true(formatSubroutine('bar', ['foo%1$sbaz']) === 'foobarbaz');
t.is(formatSubroutine('bar', ['foo%1$sbaz']), 'foobarbaz');
});
12 changes: 8 additions & 4 deletions test/surgeon/subroutines/matchSubroutine.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ test('throws an error if invoked with invalid RegExp', (t): void => {
});

test('throws an error if regex does not define capturing groups', (t) => {
t.throws((): void => {
const error = t.throws((): void => {
matchSubroutine('foo', ['foo']);
}, 'Regular expression must define at least one capturing group.');
});

t.is(error.message, 'Regular expression must define at least one capturing group.');
});

test('returns InvalidValueSentinel when input cannot be matched', (t) => {
Expand All @@ -34,9 +36,11 @@ test('matches a single capturing group', (t) => {
});

test('throws an error when matching multiple capturing groups without sprintf template', (t) => {
t.throws((): void => {
const error = t.throws((): void => {
matchSubroutine('foobar', ['(foo)(bar)']);
}, 'Must define sprintf template when matching multiple groups.');
});

t.is(error.message, 'Must define sprintf template when matching multiple groups.');
});

test('formats multiple capturing group matches using sprintf', (t) => {
Expand Down

0 comments on commit 0aef7ee

Please sign in to comment.