Răsfoiți Sursa

test(runtime-vapor): add unit test for config.performance (#234)

Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
XiaoDong 2 ani în urmă
părinte
comite
bc04592ca9
1 a modificat fișierele cu 22 adăugiri și 0 ștergeri
  1. 22 0
      packages/runtime-vapor/__tests__/apiCreateVaporApp.spec.ts

+ 22 - 0
packages/runtime-vapor/__tests__/apiCreateVaporApp.spec.ts

@@ -310,4 +310,26 @@ describe('api: createVaporApp', () => {
       ).toHaveBeenWarned()
     })
   })
+
+  describe('config.performance', () => {
+    afterEach(() => {
+      window.performance.clearMeasures()
+    })
+
+    test('with performance enabled', () => {
+      const { app, mount } = define({}).create()
+
+      app.config.performance = true
+      mount()
+      expect(window.performance.getEntries()).lengthOf(2)
+    })
+
+    test('with performance disabled', () => {
+      const { app, mount } = define({}).create()
+
+      app.config.performance = false
+      mount()
+      expect(window.performance.getEntries()).lengthOf(0)
+    })
+  })
 })