From 2089481afa82c98ec9f5dfab56854b9baf592c21 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 4 Aug 2020 14:09:29 -0500 Subject: [PATCH] text(legacy): remove legacy context/connect prop tests --- src/runtime/test/connect.spec.tsx | 40 -------------- src/runtime/test/context.spec.tsx | 75 -------------------------- src/runtime/test/legacy-props.spec.tsx | 24 --------- src/runtime/test/queue.spec.tsx | 38 +------------ 4 files changed, 1 insertion(+), 176 deletions(-) delete mode 100644 src/runtime/test/connect.spec.tsx delete mode 100644 src/runtime/test/context.spec.tsx delete mode 100644 src/runtime/test/legacy-props.spec.tsx diff --git a/src/runtime/test/connect.spec.tsx b/src/runtime/test/connect.spec.tsx deleted file mode 100644 index 74ffe7f5868..00000000000 --- a/src/runtime/test/connect.spec.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { newSpecPage } from '@stencil/core/testing'; -import { Component, Method, Prop } from '@stencil/core'; - -describe('connect', () => { - it('should return proxy', async () => { - @Component({ - tag: 'cmp-controller', - }) - class CmpController { - @Method() - create(opts: any) { - return opts; - } - } - - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ connect: 'cmp-controller' }) controller: any; - - @Method() - open(opts: any) { - return this.controller.create(opts); - } - } - - const { root, waitForChanges } = await newSpecPage({ - components: [CmpController, CmpA], - html: ``, - }); - - const promise = root.open(123); - - await waitForChanges(); - await waitForChanges(); - - expect(await promise).toEqual(123); - }); -}); diff --git a/src/runtime/test/context.spec.tsx b/src/runtime/test/context.spec.tsx deleted file mode 100644 index 5fc4879d9c4..00000000000 --- a/src/runtime/test/context.spec.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { newSpecPage } from '@stencil/core/testing'; -import { Component, Prop, readTask, writeTask } from '@stencil/core'; -import { QueueApi } from '../../declarations'; - -describe('context', () => { - it('should return default values of context', async () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ context: 'window' }) win: Window; - @Prop({ context: 'document' }) doc: Document; - @Prop({ context: 'isServer' }) isServer: boolean; - @Prop({ context: 'isPrerender' }) isPrerender: boolean; - @Prop({ context: 'isClient' }) isClient: boolean; - @Prop({ context: 'resourcesUrl' }) resourcesUrl: string; - @Prop({ context: 'publicPath' }) publicPath: string; - @Prop({ context: 'queue' }) queue: QueueApi; - } - const { win, doc, rootInstance } = await newSpecPage({ - components: [CmpA], - html: ``, - }); - - expect(rootInstance.win).toEqual(win); - expect(rootInstance.doc).toEqual(doc); - expect(rootInstance.isServer).toEqual(false); - expect(rootInstance.isPrerender).toEqual(false); - expect(rootInstance.isClient).toEqual(true); - expect(rootInstance.resourcesUrl).toEqual('/'); - expect(rootInstance.publicPath).toEqual('/'); - expect(rootInstance.queue.write).toEqual(writeTask); - expect(rootInstance.queue.read).toEqual(readTask); - expect(rootInstance.queue.tick).not.toBeUndefined(); - }); - - it('should replace default values of context', async () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ context: 'resourcesUrl' }) resourcesUrl: boolean; - @Prop({ context: 'publicPath' }) publicPath: boolean; - } - const { rootInstance } = await newSpecPage({ - components: [CmpA], - html: ``, - context: { - resourcesUrl: '/blabla', - publicPath: '/blubblub', - }, - }); - expect(rootInstance.resourcesUrl).toEqual('/blabla'); - expect(rootInstance.publicPath).toEqual('/blubblub'); - }); - - it('should extend context', async () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ context: 'value' }) value: number; - @Prop({ context: 'unknown' }) unknown: any; - } - const { rootInstance } = await newSpecPage({ - components: [CmpA], - html: ``, - context: { - value: 1234, - }, - }); - expect(rootInstance.value).toEqual(1234); - expect(rootInstance.unknown).toEqual(undefined); - }); -}); diff --git a/src/runtime/test/legacy-props.spec.tsx b/src/runtime/test/legacy-props.spec.tsx deleted file mode 100644 index 50cb32d51b9..00000000000 --- a/src/runtime/test/legacy-props.spec.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, Prop } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -describe('legacy props', () => { - it('load context and connect', async () => { - @Component({ tag: 'cmp-a' }) - class CmpA { - @Prop({ connect: 'ion-menu-controller' }) menuController: any; - @Prop({ context: 'isServer' }) isServer: boolean; - render() { - return `${this.isServer}-${typeof this.menuController}`; - } - } - - const { root } = await newSpecPage({ - components: [CmpA], - html: ``, - }); - - expect(root).toEqualHtml(` - false-object - `); - }); -}); diff --git a/src/runtime/test/queue.spec.tsx b/src/runtime/test/queue.spec.tsx index 80a8c4cce6f..afc969ce0ec 100644 --- a/src/runtime/test/queue.spec.tsx +++ b/src/runtime/test/queue.spec.tsx @@ -1,5 +1,5 @@ import { newSpecPage } from '@stencil/core/testing'; -import { Component, Method, Prop, readTask, writeTask } from '@stencil/core'; +import { Component, Method, readTask, writeTask } from '@stencil/core'; describe('queue', () => { it('should execute tasks in the right order', async () => { @@ -29,40 +29,4 @@ describe('queue', () => { expect(log).toEqual(' read1 read2 read3 write1 write2'); }); - - it('should replace default values of context', async () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ context: 'resourcesUrl' }) resourcesUrl: boolean; - } - const { rootInstance } = await newSpecPage({ - components: [CmpA], - html: ``, - context: { - resourcesUrl: '/blabla', - }, - }); - expect(rootInstance.resourcesUrl).toEqual('/blabla'); - }); - - it('should extend context', async () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA { - @Prop({ context: 'value' }) value: number; - @Prop({ context: 'unknown' }) unknown: any; - } - const { rootInstance } = await newSpecPage({ - components: [CmpA], - html: ``, - context: { - value: 1234, - }, - }); - expect(rootInstance.value).toEqual(1234); - expect(rootInstance.unknown).toEqual(undefined); - }); });