本文整理匯總了TypeScript中document.Document._compute_patch_since_json方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Document._compute_patch_since_json方法的具體用法?TypeScript Document._compute_patch_since_json怎麽用?TypeScript Document._compute_patch_since_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類document.Document
的用法示例。
在下文中一共展示了Document._compute_patch_since_json方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("computes patch for models added during construction", () => {
const d = new Document()
expect(d.roots().length).to.equal(0)
expect(Object.keys(d._all_models).length).to.equal(0)
const root1 = new ModelWithConstructTimeChanges()
// change it so it doesn't match what initialize() does
root1.foo = 3
root1.child = null
d.add_root(root1)
const json = d.to_json_string()
const parsed = JSON.parse(json)
parsed.version = js_version
const copy = Document.from_json_string(JSON.stringify(parsed))
const patch = Document._compute_patch_since_json(JSON.parse(json), copy)
expect(patch.events.length).to.equal(2)
expect(root1.foo).to.equal(3)
expect(root1.child).to.equal(null)
d.apply_json_patch(patch)
expect(root1.foo).to.equal(4)
expect(root1.child).to.be.an.instanceof(AnotherModel)
})