From fe8814379ea5f7b67de099771679a16216217f33 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 18 May 2023 15:50:12 -0600 Subject: [PATCH 1/3] WIP: TS tests for UpdateData --- .../test/unit/lite-api/types.test.ts | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 packages/firestore/test/unit/lite-api/types.test.ts diff --git a/packages/firestore/test/unit/lite-api/types.test.ts b/packages/firestore/test/unit/lite-api/types.test.ts new file mode 100644 index 00000000000..55d6b28d3b5 --- /dev/null +++ b/packages/firestore/test/unit/lite-api/types.test.ts @@ -0,0 +1,343 @@ +/** + * @license + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0x00 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0x00 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect } from 'chai'; + +import { + UpdateData +} from '../../../src/lite-api/reference'; +import { hardAssert } from '../../../src/util/assert'; + +type MyUnion = string | number; + +type NestedObject = { + boo: boolean, + str: string, + num: number, + nul: null, + und: undefined, + customUnion: MyUnion +} + + +describe.only('UpdateData - v9', () => { + type MyServerType = { + // primitive types + boo: boolean, + str: string, + num: number, + nul: null, + und: undefined, + + // custom types + customUnion: MyUnion, + customObject: NestedObject, + + // nested objects + nested: { + bar: { + boo: boolean, + str: string, + anotherLayer: { + boo: boolean, + str: string, + } + }, + baz: { + boo: boolean, + str: string, + anotherLayer: { + boo: boolean, + str: string, + } + } + }, + + // index signatures nested 1 layer deep + indexed: { + [name: string]: { + desc: boolean, + num: number + } + }, + + // TODO v10 - index signatures nested 2 layers deep + + // property with dots in the name + 'property.with.dots': boolean + } + + it("Supports properties with primitive types", () => { + let testData : UpdateData; + testData = { + boo: true, + str: "string", + num: 2, + nul: null, + und: undefined + }; + + testData = { + // @ts-expect-error + boo: "string", + // @ts-expect-error + str: 1, + // @ts-expect-error + num: "string", + // @ts-expect-error + nul: "string", + // @ts-expect-error + und: "string", + }; + + expect(true).to.be.true; + }); + + it("Supports properties with custom types", () => { + let testData : UpdateData; + testData = { + customUnion: "string", + customObject: { + boo: true, + str: "string", + num: 2, + nul: null, + und: undefined, + customUnion: 1, + } + }; + + testData = { + // @ts-expect-error + customUnion: true, + + // @ts-expect-error + customObject: true + }; + + testData = { + customObject: { + // @ts-expect-error + boo: "string", + // @ts-expect-error + str: 1, + // @ts-expect-error + num: "string", + // @ts-expect-error + nul: "string", + // @ts-expect-error + und: "string", + } + }; + + expect(true).to.be.true; + }); + + describe("given properties with dots", () => { + it("preserves the value type", () => { + let testData: UpdateData; + + // Allows values of expected type + testData = { + 'property.with.dots': true + }; + + // Errors on values of unexpected type + testData = { + // @ts-expect-error + 'property.with.dots': 1 + }; + + expect(true).to.be.true; + }); + + it("does not allow matching a sub-string|path", () => { + let testData: UpdateData; + + testData = { + // @ts-expect-error + 'property.with': true + }; + + expect(true).to.be.true; + }); + }) + + describe("given nested objects (no index properties)", () => { + it("supports object replacement at each layer (with partial)", () => { + let testData: UpdateData; + testData = { + nested: {} + }; + + testData = { + nested: { + bar: {}, + baz: {} + } + }; + + testData = { + nested: { + bar: { + boo: true, + str: "string" + }, + baz: { + str: "string" + } + } + }; + + testData = { + nested: { + bar: { + boo: true, + str: "string", + anotherLayer: { + boo: false, + str: "another string" + } + } + } + }; + + expect(true).to.be.true; + }); + + it("preserves value types at each layer", () => { + let testData: UpdateData; + testData = { + // @ts-expect-error + nested: true + }; + + testData = { + nested: { + bar: { + // @ts-expect-error + str: true, + // @ts-expect-error + anotherLayer: true + }, + baz: { + anotherLayer: { + // @ts-expect-error + boo: "string value" + } + } + } + }; + + expect(true).to.be.true; + }); + + it("does not allow properties that were not on the original type", () => { + let testData: UpdateData; + testData = { + // @ts-expect-error + unknown: true + }; + + testData = { + nested: { + // @ts-expect-error + unknown: true + } + }; + + expect(true).to.be.true; + }); + + it("preserves value types for dot notation", () => { + let testData: UpdateData; + + // 2 layers with dot notation + + // preserves type + testData = { + 'nested.bar': {}, + 'nested.baz': {}, + }; + + // preserves properties of nested objects + testData = { + 'nested.bar': { + boo: true, + str: "string", + anotherLayer: { + boo: false, + str: "string", + } + }, + 'nested.baz': { + boo: true + } + }; + + // preserves type - failure + testData = { + // @ts-expect-error + 'nested.bar': false, + // @ts-expect-error + 'nested.baz': "string", + }; + + // preserves properties of nested objects - failure + testData = { + 'nested.bar': { + // @ts-expect-error + boo: "string" + } + }; + + // 3 layers with dot notation + + // preserves type + testData = { + 'nested.bar.boo': true, + 'nested.bar.anotherLayer': {}, + }; + + // preserves properties of nested objects + testData = { + 'nested.bar.anotherLayer': { + boo: false, + str: "string" + } + }; + + // preserves type - failure + testData = { + // @ts-expect-error + 'nested.bar.anotherLayer': true, + // @ts-expect-error + 'nested.baz.anotherLayer': "string", + }; + + // preserves properties of nested objects - failure + testData = { + 'nested.bar.anotherLayer': { + // @ts-expect-error + boo: "string" + }, + }; + + expect(true).to.be.true; + }); + }); + +}); From de6475a85e82f0bc60adcb0383fd074c4ebcaf99 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 22 May 2023 12:58:05 -0600 Subject: [PATCH 2/3] Test cleanup for v9 --- .../test/unit/lite-api/types.test.ts | 341 ++++++++++++------ 1 file changed, 224 insertions(+), 117 deletions(-) diff --git a/packages/firestore/test/unit/lite-api/types.test.ts b/packages/firestore/test/unit/lite-api/types.test.ts index 55d6b28d3b5..cea6ebc8a07 100644 --- a/packages/firestore/test/unit/lite-api/types.test.ts +++ b/packages/firestore/test/unit/lite-api/types.test.ts @@ -19,49 +19,51 @@ import { expect } from 'chai'; import { UpdateData } from '../../../src/lite-api/reference'; -import { hardAssert } from '../../../src/util/assert'; -type MyUnion = string | number; - -type NestedObject = { - boo: boolean, - str: string, - num: number, - nul: null, - und: undefined, - customUnion: MyUnion -} - - -describe.only('UpdateData - v9', () => { - type MyServerType = { +// A union type for testing +type MyUnionType = string | number; + +// An object type for testing +interface MyObjectType { + booleanProperty: boolean, + stringProperty: string, + numberProperty: number, + nullProperty: null, + undefinedProperty: undefined, + unionProperty: MyUnionType +}; + +// v9 tests cover scenarios that worked in +// Web SDK version v9. +describe('UpdateData - v9', () => { + interface MyV9ServerType { // primitive types - boo: boolean, - str: string, - num: number, - nul: null, - und: undefined, + booleanProperty: boolean, + stringProperty: string, + numberProperty: number, + nullProperty: null, + undefinedProperty: undefined, // custom types - customUnion: MyUnion, - customObject: NestedObject, + unionProperty: MyUnionType, + objectProperty: MyObjectType, // nested objects nested: { bar: { - boo: boolean, - str: string, + booleanProperty: boolean, + stringProperty: string, anotherLayer: { - boo: boolean, - str: string, + booleanProperty: boolean, + stringProperty: string, } }, baz: { - boo: boolean, - str: string, + booleanProperty: boolean, + stringProperty: string, anotherLayer: { - boo: boolean, - str: string, + booleanProperty: boolean, + stringProperty: string, } } }, @@ -69,77 +71,75 @@ describe.only('UpdateData - v9', () => { // index signatures nested 1 layer deep indexed: { [name: string]: { - desc: boolean, - num: number + booleanProperty: boolean, + numberProperty: number } }, - // TODO v10 - index signatures nested 2 layers deep - // property with dots in the name 'property.with.dots': boolean - } + }; it("Supports properties with primitive types", () => { - let testData : UpdateData; - testData = { - boo: true, - str: "string", - num: 2, - nul: null, - und: undefined + let _ : UpdateData; + _ = { + booleanProperty: true, + stringProperty: "string", + numberProperty: 2, + nullProperty: null, + undefinedProperty: undefined }; - testData = { + _ = { // @ts-expect-error - boo: "string", + booleanProperty: "string", // @ts-expect-error - str: 1, + stringProperty: 1, // @ts-expect-error - num: "string", + numberProperty: "string", // @ts-expect-error - nul: "string", + nullProperty: "string", // @ts-expect-error - und: "string", + undefinedProperty: "string", }; expect(true).to.be.true; }); it("Supports properties with custom types", () => { - let testData : UpdateData; - testData = { - customUnion: "string", - customObject: { - boo: true, - str: "string", - num: 2, - nul: null, - und: undefined, - customUnion: 1, + let _ : UpdateData; + _ = { + unionProperty: "string", + objectProperty: { + booleanProperty: true, + stringProperty: "string", + numberProperty: 2, + nullProperty: null, + undefinedProperty: undefined, + unionProperty: 1, } }; - testData = { + _ = { // @ts-expect-error - customUnion: true, + unionProperty: true, // @ts-expect-error - customObject: true + objectProperty: true }; - testData = { - customObject: { + _ = { + objectProperty: { // @ts-expect-error - boo: "string", + booleanProperty: "string", // @ts-expect-error - str: 1, + stringProperty: 1, // @ts-expect-error - num: "string", + numberProperty: "string", // @ts-expect-error - nul: "string", + nullProperty: "string", // @ts-expect-error - und: "string", + undefinedProperty: "string", } }; @@ -148,15 +148,15 @@ describe.only('UpdateData - v9', () => { describe("given properties with dots", () => { it("preserves the value type", () => { - let testData: UpdateData; + let _: UpdateData; // Allows values of expected type - testData = { + _ = { 'property.with.dots': true }; // Errors on values of unexpected type - testData = { + _ = { // @ts-expect-error 'property.with.dots': 1 }; @@ -165,51 +165,49 @@ describe.only('UpdateData - v9', () => { }); it("does not allow matching a sub-string|path", () => { - let testData: UpdateData; - - testData = { + const _: UpdateData = { // @ts-expect-error 'property.with': true }; expect(true).to.be.true; }); - }) + }); - describe("given nested objects (no index properties)", () => { + describe("given nested objects without index properties", () => { it("supports object replacement at each layer (with partial)", () => { - let testData: UpdateData; - testData = { + let _: UpdateData; + _ = { nested: {} }; - testData = { + _ = { nested: { bar: {}, baz: {} } }; - testData = { + _ = { nested: { bar: { - boo: true, - str: "string" + booleanProperty: true, + stringProperty: "string" }, baz: { - str: "string" + stringProperty: "string" } } }; - testData = { + _ = { nested: { bar: { - boo: true, - str: "string", + booleanProperty: true, + stringProperty: "string", anotherLayer: { - boo: false, - str: "another string" + booleanProperty: false, + stringProperty: "another string" } } } @@ -218,25 +216,25 @@ describe.only('UpdateData - v9', () => { expect(true).to.be.true; }); - it("preserves value types at each layer", () => { - let testData: UpdateData; - testData = { + it("errors for unexpected value types at each layer", () => { + let _: UpdateData; + _ = { // @ts-expect-error nested: true }; - testData = { + _ = { nested: { bar: { // @ts-expect-error - str: true, + stringProperty: true, // @ts-expect-error anotherLayer: true }, baz: { anotherLayer: { // @ts-expect-error - boo: "string value" + booleanProperty: "string value" } } } @@ -246,13 +244,13 @@ describe.only('UpdateData - v9', () => { }); it("does not allow properties that were not on the original type", () => { - let testData: UpdateData; - testData = { + let _: UpdateData; + _ = { // @ts-expect-error unknown: true }; - testData = { + _ = { nested: { // @ts-expect-error unknown: true @@ -263,33 +261,34 @@ describe.only('UpdateData - v9', () => { }); it("preserves value types for dot notation", () => { - let testData: UpdateData; + let _: UpdateData; // 2 layers with dot notation // preserves type - testData = { + _ = { 'nested.bar': {}, 'nested.baz': {}, }; - // preserves properties of nested objects - testData = { + // preserves properties of nested objects referenced + // with dot notation + _ = { 'nested.bar': { - boo: true, - str: "string", + booleanProperty: true, + stringProperty: "string", anotherLayer: { - boo: false, - str: "string", + booleanProperty: false, + stringProperty: "string", } }, 'nested.baz': { - boo: true + booleanProperty: true } }; // preserves type - failure - testData = { + _ = { // @ts-expect-error 'nested.bar': false, // @ts-expect-error @@ -297,31 +296,31 @@ describe.only('UpdateData - v9', () => { }; // preserves properties of nested objects - failure - testData = { + _ = { 'nested.bar': { // @ts-expect-error - boo: "string" + booleanProperty: "string" } }; // 3 layers with dot notation // preserves type - testData = { - 'nested.bar.boo': true, + _ = { + 'nested.bar.booleanProperty': true, 'nested.bar.anotherLayer': {}, }; // preserves properties of nested objects - testData = { + _ = { 'nested.bar.anotherLayer': { - boo: false, - str: "string" + booleanProperty: false, + stringProperty: "string" } }; // preserves type - failure - testData = { + _ = { // @ts-expect-error 'nested.bar.anotherLayer': true, // @ts-expect-error @@ -329,11 +328,119 @@ describe.only('UpdateData - v9', () => { }; // preserves properties of nested objects - failure - testData = { + _ = { 'nested.bar.anotherLayer': { // @ts-expect-error - boo: "string" + booleanProperty: "string" + }, + }; + + expect(true).to.be.true; + }); + }); + + describe("given nested objects with index properties", () => { + it("supports object replacement at each layer (with partial)", () => { + let _: UpdateData; + _ = { + indexed: {} + }; + + _ = { + indexed: { + bar: {}, + baz: {} + } + }; + + _ = { + indexed: { + bar: { + booleanProperty: true, + }, + baz: { + numberProperty: 1 + } + } + }; + + expect(true).to.be.true; + }); + + it("errors for unexpected value types at each layer", () => { + let _: UpdateData; + _ = { + // @ts-expect-error + indexed: true + }; + + _ = { + indexed: { + bar: { + // @ts-expect-error + stringProperty: true, + } + } + }; + + expect(true).to.be.true; + }); + + it("does not allow properties that were not on the original type", () => { + const _: UpdateData = { + indexed: { + foo: { + // @ts-expect-error + unknown: 1 + }, + bar: { + numberProperty: 2, + // @ts-expect-error + something: "string val" + } + } + }; + + expect(true).to.be.true; + }); + + it("preserves value types for dot notation", () => { + let _: UpdateData; + + // 2 layers with dot notation + + // preserves type + _ = { + 'indexed.bar': {}, + 'indexed.baz': {}, + }; + + // preserves properties of nested objects referenced + // with dot notation + _ = { + 'indexed.bar': { + booleanProperty: true, + numberProperty: 1 }, + 'indexed.baz': { + booleanProperty: true + } + }; + + // preserves type - failure + _ = { + // @ts-expect-error + 'indexed.bar': false, + // @ts-expect-error + 'indexed.baz': "string", + }; + + // preserves properties of nested objects - failure + _ = { + 'indexed.bar': { + // @ts-expect-error + booleanProperty: "string" + } }; expect(true).to.be.true; From 84d5cad37e3a03991cde912973b5bcaaaaf20701 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 30 Jun 2023 06:37:17 -0600 Subject: [PATCH 3/3] Run prettier. --- .../test/unit/lite-api/types.test.ts | 173 +++++++++--------- 1 file changed, 85 insertions(+), 88 deletions(-) diff --git a/packages/firestore/test/unit/lite-api/types.test.ts b/packages/firestore/test/unit/lite-api/types.test.ts index cea6ebc8a07..cfe0a20d90f 100644 --- a/packages/firestore/test/unit/lite-api/types.test.ts +++ b/packages/firestore/test/unit/lite-api/types.test.ts @@ -16,75 +16,73 @@ */ import { expect } from 'chai'; -import { - UpdateData -} from '../../../src/lite-api/reference'; +import { UpdateData } from '../../../src/lite-api/reference'; // A union type for testing type MyUnionType = string | number; // An object type for testing interface MyObjectType { - booleanProperty: boolean, - stringProperty: string, - numberProperty: number, - nullProperty: null, - undefinedProperty: undefined, - unionProperty: MyUnionType -}; + booleanProperty: boolean; + stringProperty: string; + numberProperty: number; + nullProperty: null; + undefinedProperty: undefined; + unionProperty: MyUnionType; +} // v9 tests cover scenarios that worked in // Web SDK version v9. describe('UpdateData - v9', () => { interface MyV9ServerType { // primitive types - booleanProperty: boolean, - stringProperty: string, - numberProperty: number, - nullProperty: null, - undefinedProperty: undefined, + booleanProperty: boolean; + stringProperty: string; + numberProperty: number; + nullProperty: null; + undefinedProperty: undefined; // custom types - unionProperty: MyUnionType, - objectProperty: MyObjectType, + unionProperty: MyUnionType; + objectProperty: MyObjectType; // nested objects nested: { bar: { - booleanProperty: boolean, - stringProperty: string, + booleanProperty: boolean; + stringProperty: string; anotherLayer: { - booleanProperty: boolean, - stringProperty: string, - } - }, + booleanProperty: boolean; + stringProperty: string; + }; + }; baz: { - booleanProperty: boolean, - stringProperty: string, + booleanProperty: boolean; + stringProperty: string; anotherLayer: { - booleanProperty: boolean, - stringProperty: string, - } - } - }, + booleanProperty: boolean; + stringProperty: string; + }; + }; + }; // index signatures nested 1 layer deep indexed: { [name: string]: { - booleanProperty: boolean, - numberProperty: number - } - }, + booleanProperty: boolean; + numberProperty: number; + }; + }; // property with dots in the name - 'property.with.dots': boolean - }; + 'property.with.dots': boolean; + } - it("Supports properties with primitive types", () => { - let _ : UpdateData; + it('Supports properties with primitive types', () => { + let _: UpdateData; _ = { booleanProperty: true, - stringProperty: "string", + stringProperty: 'string', numberProperty: 2, nullProperty: null, undefinedProperty: undefined @@ -92,31 +90,31 @@ describe('UpdateData - v9', () => { _ = { // @ts-expect-error - booleanProperty: "string", + booleanProperty: 'string', // @ts-expect-error stringProperty: 1, // @ts-expect-error - numberProperty: "string", + numberProperty: 'string', // @ts-expect-error - nullProperty: "string", + nullProperty: 'string', // @ts-expect-error - undefinedProperty: "string", + undefinedProperty: 'string' }; expect(true).to.be.true; }); - it("Supports properties with custom types", () => { - let _ : UpdateData; + it('Supports properties with custom types', () => { + let _: UpdateData; _ = { - unionProperty: "string", + unionProperty: 'string', objectProperty: { booleanProperty: true, - stringProperty: "string", + stringProperty: 'string', numberProperty: 2, nullProperty: null, undefinedProperty: undefined, - unionProperty: 1, + unionProperty: 1 } }; @@ -131,23 +129,23 @@ describe('UpdateData - v9', () => { _ = { objectProperty: { // @ts-expect-error - booleanProperty: "string", + booleanProperty: 'string', // @ts-expect-error stringProperty: 1, // @ts-expect-error - numberProperty: "string", + numberProperty: 'string', // @ts-expect-error - nullProperty: "string", + nullProperty: 'string', // @ts-expect-error - undefinedProperty: "string", + undefinedProperty: 'string' } }; expect(true).to.be.true; }); - describe("given properties with dots", () => { - it("preserves the value type", () => { + describe('given properties with dots', () => { + it('preserves the value type', () => { let _: UpdateData; // Allows values of expected type @@ -164,8 +162,8 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("does not allow matching a sub-string|path", () => { - const _: UpdateData = { + it('does not allow matching a sub-string|path', () => { + const _: UpdateData = { // @ts-expect-error 'property.with': true }; @@ -174,8 +172,8 @@ describe('UpdateData - v9', () => { }); }); - describe("given nested objects without index properties", () => { - it("supports object replacement at each layer (with partial)", () => { + describe('given nested objects without index properties', () => { + it('supports object replacement at each layer (with partial)', () => { let _: UpdateData; _ = { nested: {} @@ -192,10 +190,10 @@ describe('UpdateData - v9', () => { nested: { bar: { booleanProperty: true, - stringProperty: "string" + stringProperty: 'string' }, baz: { - stringProperty: "string" + stringProperty: 'string' } } }; @@ -204,10 +202,10 @@ describe('UpdateData - v9', () => { nested: { bar: { booleanProperty: true, - stringProperty: "string", + stringProperty: 'string', anotherLayer: { booleanProperty: false, - stringProperty: "another string" + stringProperty: 'another string' } } } @@ -216,7 +214,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("errors for unexpected value types at each layer", () => { + it('errors for unexpected value types at each layer', () => { let _: UpdateData; _ = { // @ts-expect-error @@ -234,7 +232,7 @@ describe('UpdateData - v9', () => { baz: { anotherLayer: { // @ts-expect-error - booleanProperty: "string value" + booleanProperty: 'string value' } } } @@ -243,7 +241,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("does not allow properties that were not on the original type", () => { + it('does not allow properties that were not on the original type', () => { let _: UpdateData; _ = { // @ts-expect-error @@ -260,7 +258,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("preserves value types for dot notation", () => { + it('preserves value types for dot notation', () => { let _: UpdateData; // 2 layers with dot notation @@ -268,7 +266,7 @@ describe('UpdateData - v9', () => { // preserves type _ = { 'nested.bar': {}, - 'nested.baz': {}, + 'nested.baz': {} }; // preserves properties of nested objects referenced @@ -276,10 +274,10 @@ describe('UpdateData - v9', () => { _ = { 'nested.bar': { booleanProperty: true, - stringProperty: "string", + stringProperty: 'string', anotherLayer: { booleanProperty: false, - stringProperty: "string", + stringProperty: 'string' } }, 'nested.baz': { @@ -292,14 +290,14 @@ describe('UpdateData - v9', () => { // @ts-expect-error 'nested.bar': false, // @ts-expect-error - 'nested.baz': "string", + 'nested.baz': 'string' }; // preserves properties of nested objects - failure _ = { 'nested.bar': { // @ts-expect-error - booleanProperty: "string" + booleanProperty: 'string' } }; @@ -308,14 +306,14 @@ describe('UpdateData - v9', () => { // preserves type _ = { 'nested.bar.booleanProperty': true, - 'nested.bar.anotherLayer': {}, + 'nested.bar.anotherLayer': {} }; // preserves properties of nested objects _ = { 'nested.bar.anotherLayer': { booleanProperty: false, - stringProperty: "string" + stringProperty: 'string' } }; @@ -324,23 +322,23 @@ describe('UpdateData - v9', () => { // @ts-expect-error 'nested.bar.anotherLayer': true, // @ts-expect-error - 'nested.baz.anotherLayer': "string", + 'nested.baz.anotherLayer': 'string' }; // preserves properties of nested objects - failure _ = { 'nested.bar.anotherLayer': { // @ts-expect-error - booleanProperty: "string" - }, + booleanProperty: 'string' + } }; expect(true).to.be.true; }); }); - describe("given nested objects with index properties", () => { - it("supports object replacement at each layer (with partial)", () => { + describe('given nested objects with index properties', () => { + it('supports object replacement at each layer (with partial)', () => { let _: UpdateData; _ = { indexed: {} @@ -356,7 +354,7 @@ describe('UpdateData - v9', () => { _ = { indexed: { bar: { - booleanProperty: true, + booleanProperty: true }, baz: { numberProperty: 1 @@ -367,7 +365,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("errors for unexpected value types at each layer", () => { + it('errors for unexpected value types at each layer', () => { let _: UpdateData; _ = { // @ts-expect-error @@ -378,7 +376,7 @@ describe('UpdateData - v9', () => { indexed: { bar: { // @ts-expect-error - stringProperty: true, + stringProperty: true } } }; @@ -386,7 +384,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("does not allow properties that were not on the original type", () => { + it('does not allow properties that were not on the original type', () => { const _: UpdateData = { indexed: { foo: { @@ -396,7 +394,7 @@ describe('UpdateData - v9', () => { bar: { numberProperty: 2, // @ts-expect-error - something: "string val" + something: 'string val' } } }; @@ -404,7 +402,7 @@ describe('UpdateData - v9', () => { expect(true).to.be.true; }); - it("preserves value types for dot notation", () => { + it('preserves value types for dot notation', () => { let _: UpdateData; // 2 layers with dot notation @@ -412,7 +410,7 @@ describe('UpdateData - v9', () => { // preserves type _ = { 'indexed.bar': {}, - 'indexed.baz': {}, + 'indexed.baz': {} }; // preserves properties of nested objects referenced @@ -432,19 +430,18 @@ describe('UpdateData - v9', () => { // @ts-expect-error 'indexed.bar': false, // @ts-expect-error - 'indexed.baz': "string", + 'indexed.baz': 'string' }; // preserves properties of nested objects - failure _ = { 'indexed.bar': { // @ts-expect-error - booleanProperty: "string" + booleanProperty: 'string' } }; expect(true).to.be.true; }); }); - });