@@ -25,10 +25,14 @@ describe("login", () => {
25
25
// Create a fake element and set the attribute
26
26
const mockElement = document . createElement ( "input" )
27
27
mockElement . setAttribute ( "id" , "base" )
28
- mockElement . setAttribute (
29
- "data-settings" ,
30
- '{"base":"./hello-world","csStaticBase":"./static/development/Users/jp/Dev/code-server","logLevel":2,"disableTelemetry":false,"disableUpdateCheck":false}' ,
31
- )
28
+ const expected = {
29
+ base : "./hello-world" ,
30
+ csStaticBase : "./static/development/Users/jp/Dev/code-server" ,
31
+ logLevel : 2 ,
32
+ disableTelemetry : false ,
33
+ disableUpdateCheck : false ,
34
+ }
35
+ mockElement . setAttribute ( "data-settings" , JSON . stringify ( expected ) )
32
36
document . body . appendChild ( mockElement )
33
37
spy . mockImplementation ( ( ) => mockElement )
34
38
// Load file
@@ -38,32 +42,4 @@ describe("login", () => {
38
42
expect ( el ?. value ) . toBe ( "/hello-world" )
39
43
} )
40
44
} )
41
-
42
- describe ( "there is no element with id 'base'" , ( ) => {
43
- let initialDom : Document
44
- beforeEach ( ( ) => {
45
- const dom = new JSDOM ( )
46
- initialDom = dom . window . document
47
- global . document = dom . window . document
48
-
49
- const location : LocationLike = {
50
- pathname : "/healthz" ,
51
- origin : "http://localhost:8080" ,
52
- }
53
-
54
- global . location = location as Location
55
- } )
56
- afterEach ( ( ) => {
57
- // Reset the global.document
58
- global . document = undefined as any as Document
59
- global . location = undefined as any as Location
60
- } )
61
-
62
- it ( "should not change the DOM" , ( ) => {
63
- // Load file
64
- require ( "../../../src/browser/pages/login" )
65
- const currentDom = global . document
66
- expect ( initialDom ) . toBe ( currentDom )
67
- } )
68
- } )
69
45
} )
0 commit comments