-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Showing
28 changed files
with
270 additions
and
290 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
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
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
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export const dataSourceCreator = () => ({}) as any; | ||
export const dataSourceCreator = () => | ||
({ | ||
dataSourceMap: {}, | ||
reloadDataSource: () => {}, | ||
}) as any; |
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
This file was deleted.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
packages/renderer-core/__tests__/parts/code-runtime/codeScope.spec.ts
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,46 @@ | ||
import { describe, it, expect, beforeAll } from 'vitest'; | ||
import { ICodeScope, CodeScope } from '../../../src/parts/code-runtime'; | ||
|
||
describe('codeScope', () => { | ||
let scope: ICodeScope; | ||
|
||
beforeAll(() => { | ||
scope = new CodeScope({}); | ||
}); | ||
|
||
it('should inject a new value', () => { | ||
scope.inject('username', 'Alice'); | ||
expect(scope.value).toEqual({ username: 'Alice' }); | ||
}); | ||
|
||
it('should not overwrite an existing value without force', () => { | ||
scope.inject('username', 'Bob'); | ||
expect(scope.value).toEqual({ username: 'Alice' }); | ||
}); | ||
|
||
it('should overwrite an existing value with force', () => { | ||
scope.inject('username', 'Bob', true); | ||
expect(scope.value).toEqual({ username: 'Bob' }); | ||
}); | ||
|
||
it('should set new value without replacing existing values', () => { | ||
scope.setValue({ age: 25 }); | ||
expect(scope.value).toEqual({ username: 'Bob', age: 25 }); | ||
}); | ||
|
||
it('should set new value and replace all existing values', () => { | ||
scope.setValue({ loggedIn: true }, true); | ||
expect(scope.value).toEqual({ loggedIn: true }); | ||
}); | ||
|
||
it('should create a child scope with initial values', () => { | ||
const childScope = scope.createChild({ sessionId: 'abc123' }); | ||
expect(childScope.value).toEqual({ loggedIn: true, sessionId: 'abc123' }); | ||
}); | ||
|
||
it('should set new values in the child scope without affecting the parent scope', () => { | ||
const childScope = scope.createChild({ theme: 'dark' }); | ||
expect(childScope.value).toEqual({ loggedIn: true, sessionId: 'abc123', theme: 'dark' }); | ||
expect(scope.value).toEqual({ loggedIn: true }); | ||
}); | ||
}); |
Oops, something went wrong.