-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jindy
committed
Sep 15, 2022
1 parent
6fb5575
commit 3715784
Showing
113 changed files
with
4,106 additions
and
876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`codegen > element 1`] = ` | ||
"const { toDisplayString: _toDisplayString,createElementVNode: _createElementVNode } = Vue | ||
return function render(_ctx,_cache){return _createElementVNode('div',null,'hi,' + _toDisplayString(_ctx.message))}" | ||
`; | ||
|
||
exports[`codegen > interpolation 1`] = ` | ||
"const { toDisplayString: _toDisplayString } = Vue | ||
return function render(_ctx,_cache){return _toDisplayString(_ctx.message)}" | ||
`; | ||
|
||
exports[`codegen > string 1`] = ` | ||
" | ||
return function render(_ctx,_cache){return 'hi'}" | ||
`; | ||
|
||
exports[`codegen element 1`] = ` | ||
"const { toDisplayString: _toDisplayString,createElementVNode: _createElementVNode } = Vue | ||
return function render(_ctx,_cache){return _createElementVNode('div',null,'hi,' + _toDisplayString(_ctx.message))}" | ||
`; | ||
|
||
exports[`codegen interpolation 1`] = ` | ||
"const { toDisplayString: _toDisplayString } = Vue | ||
return function render(_ctx,_cache){return _toDisplayString(_ctx.message)}" | ||
`; | ||
|
||
exports[`codegen string 1`] = ` | ||
" | ||
return function render(_ctx,_cache){return 'hi'}" | ||
`; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@guide-mini-vue/compiler-core", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@guide-mini-vue/shared": "workspace:^1.0.0" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { vi } from "vitest"; | ||
import { reactive } from "../src/reactive"; | ||
import { computed } from "../src/computed"; | ||
|
||
describe("computed", () => { | ||
it("happy path", () => { | ||
const user = reactive({ | ||
age: 1, | ||
}); | ||
|
||
const age = computed(() => { | ||
return user.age; | ||
}); | ||
|
||
expect(age.value).toBe(1); | ||
}); | ||
|
||
it("should computed lazily", () => { | ||
const value = reactive({ foo: 1 }); | ||
const getter = vi.fn(() => { | ||
return value.foo; | ||
}); | ||
const cValue = computed(getter); | ||
|
||
// lazy | ||
expect(getter).not.toHaveBeenCalled(); | ||
|
||
expect(cValue.value).toBe(1); | ||
expect(getter).toHaveBeenCalledTimes(1); | ||
|
||
cValue.value; | ||
expect(getter).toHaveBeenCalledTimes(1); | ||
|
||
value.foo = 2; | ||
expect(getter).toHaveBeenCalledTimes(1); | ||
|
||
expect(cValue.value).toBe(2); | ||
expect(getter).toHaveBeenCalledTimes(2); | ||
|
||
cValue.value; | ||
expect(getter).toHaveBeenCalledTimes(2); | ||
}); | ||
}); |
Oops, something went wrong.