+
K
注: 以下の翻訳の正確性は検証されていません。AIPを利用して英語版の原文から機械的に翻訳されたものです。
Objects.create() を使ってモックオブジェクトを作成し、定義できます。これは通常の関数と同じように使えます。作成したモックオブジェクトは、ユニットテストを書く際に使用できます。以下に例を示します。
Objects.create()
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 import { MyFunctions } from ".." import { Objects, ExampleDataAirport } from "@foundry/ontology-api"; describe("example test suite", () => { const myFunctions = new MyFunctions(); test("test created objects", () => { const JFK = Objects.create().exampleDataAirport("JFK Test"); JFK.displayAirportName = "John F. Kennedy International"; expect(myFunctions.getAirportName(JFK)).toEqual("John F. Kennedy International"); }); });
1 2 3 4 5 6 7 8 9 10 11 12 13
import { MyFunctions } from ".." import { Objects, ExampleDataAirport } from "@foundry/ontology-api"; describe("example test suite", () => { const myFunctions = new MyFunctions(); test("test created objects", () => { const JFK = Objects.create().exampleDataAirport("JFK Test"); JFK.displayAirportName = "John F. Kennedy International"; expect(myFunctions.getAirportName(JFK)).toEqual("John F. Kennedy International"); }); });
参考までに、上記の例では Jest の構文 expect(...).toEqual(...) ↗ を使用しています。
expect(...).toEqual(...)