blob: 1cb634b6f9a5dff7554c9cdb52ee8565b2e4cbe6 [file] [edit]
// Copyright (c) project authors. All rights reserved.
// Licensed under the MIT license.
// See LICENSE file in the project root for details.
import 'package:html/dom.dart';
import 'package:test/test.dart';
void main() {
group('querySelector descendant', () {
late Element el;
setUp(() {
el = Element.html('<div id="a" class="a"><div id="b"></div></div>');
});
test('descendant of type', () {
expect(el.querySelector('div div')?.id, 'b');
});
test('descendant of class', () {
expect(el.querySelector('.a div')?.id, 'b');
});
test('descendant of type and class', () {
expect(el.querySelector('div.a div')?.id, 'b');
});
test('empty :not() throws FormatException', () {
final isInvalidNotSelector = throwsA(
isA<FormatException>().having(
(e) => e.message,
'message',
"':not()' is not a valid selector",
),
);
expect(() => el.querySelector(':not()'), isInvalidNotSelector);
expect(() => el.querySelectorAll(':not()'), isInvalidNotSelector);
});
});
}