@@ -9,10 +9,10 @@ import * as getTimeOfDayModule from './fixtures/get-time-of-day.js';
9
9
10
10
// Suite
11
11
// -----------------------------------------------------------------------------
12
- describe ( `Example Tests` , function ( ) {
12
+ describe ( `Example Tests` , function ( ) {
13
13
// Tests
14
14
// ---------------------------------------------------------------------------
15
- describe ( 'Jest & JSDOM basics' , function ( ) {
15
+ describe ( 'Jest & JSDOM basics' , function ( ) {
16
16
test ( 'dom manipulation (jsdom)' , ( ) => {
17
17
const testText = 'This is a test' ;
18
18
const testHTML = `<h1>Test</h1><p>${ testText } </p>` ;
@@ -53,7 +53,7 @@ describe(`Example Tests`, function() {
53
53
} ) ;
54
54
} ) ;
55
55
56
- describe ( 'Fake Timers' , function ( ) {
56
+ describe ( 'Fake Timers' , function ( ) {
57
57
// jest version issue
58
58
// test('data & time', () => {
59
59
// jest.useFakeTimers();
@@ -63,7 +63,7 @@ describe(`Example Tests`, function() {
63
63
// });
64
64
} ) ;
65
65
66
- describe ( 'Mocks & Spies' , function ( ) {
66
+ describe ( 'Mocks & Spies' , function ( ) {
67
67
test ( 'mock import/require dependency using jest.fn()' , ( ) => {
68
68
const testModule = require ( './fixtures/get-time-of-day.js' ) ;
69
69
const { greet : testGreet } = require ( './fixtures/greet.js' ) ;
@@ -82,7 +82,7 @@ describe(`Example Tests`, function() {
82
82
83
83
jest . doMock ( mockModulePath , ( ) => ( {
84
84
__esModule : true ,
85
- getTimeOfDay : jest . fn ( ( ) => 'night' )
85
+ getTimeOfDay : jest . fn ( ( ) => 'night' ) ,
86
86
} ) ) ;
87
87
88
88
const mockGetTimeOfDay = require ( mockModulePath ) . getTimeOfDay ;
@@ -116,4 +116,19 @@ describe(`Example Tests`, function() {
116
116
expect ( greeting ) . toBe ( `Good night, John!` ) ;
117
117
} ) ;
118
118
} ) ;
119
+
120
+ describe ( 'Verify Special Changes Test Case' , function ( ) {
121
+ test ( 'document.querySelector with id=pure number' , ( ) => {
122
+ const testText = 'This is a test' ;
123
+ const testHTML = `<div id=24><p>${ testText } </p></div>` ;
124
+
125
+ // Inject HTML
126
+ document . body . innerHTML = testHTML ;
127
+ expect ( ( ) => {
128
+ document . querySelector ( '#24' ) ;
129
+ } ) . toThrow ( DOMException ) ;
130
+
131
+ expect ( document . querySelector ( "[id='24']" ) . textContent ) . toBe ( testText ) ;
132
+ } ) ;
133
+ } ) ;
119
134
} ) ;
0 commit comments