type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
GET_PROPOSAL_REQUEST() { console.debug('GET_PROPOSAL_REQUEST'); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
MethodDeclaration
GET_PROPOSAL_SUCCESS() { console.debug('GET_PROPOSAL_SUCCESS'); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
MethodDeclaration
GET_PROPOSAL_FAILURE(_state, payload) { console.debug('GET_PROPOSAL_FAILURE', payload); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
MethodDeclaration
GET_POWER_REQUEST() { console.debug('GET_POWER_REQUEST'); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
MethodDeclaration
GET_POWER_SUCCESS() { console.debug('GET_POWER_SUCCESS'); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
MethodDeclaration
GET_POWER_FAILURE(_state, payload) { console.debug('GET_POWER_FAILURE', payload); }
build-finance/snapshot
src/store/modules/app.ts
TypeScript
ArrowFunction
() => { ngMocks.faster(); // the same TestBed for several its. // Because we want to test the pipe, we pass it as the first // parameter of MockBuilder. We can omit the second parameter, // because there are no dependencies. // Do not forget to return the promise of MockBuilder. beforeEach(() => MockBuilder(TargetPipe)); it('sorts strings', () => { const fixture = MockRender(`{{ values | target}}`, { values: ['1', '3', '2'], }); expect(fixture.nativeElement.innerHTML).toEqual('1, 2, 3'); }); it('reverses strings on param', () => { const fixture = MockRender(`{{ values | target:flag}}`, { flag: false, values: ['1', '3', '2'], }); expect(fixture.nativeElement.innerHTML).toEqual('3, 2, 1'); }); }
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
ArrowFunction
() => MockBuilder(TargetPipe)
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
ArrowFunction
() => { const fixture = MockRender(`{{ values | target}}`, { values: ['1', '3', '2'], }); expect(fixture.nativeElement.innerHTML).toEqual('1, 2, 3'); }
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
ArrowFunction
() => { const fixture = MockRender(`{{ values | target:flag}}`, { flag: false, values: ['1', '3', '2'], }); expect(fixture.nativeElement.innerHTML).toEqual('3, 2, 1'); }
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
ClassDeclaration
// A simple pipe that accepts an array of strings, sorts them, // and returns a joined string of the values. @Pipe({ name: 'target', }) class TargetPipe implements PipeTransform { public transform(value: string[], asc = true): string { let result = [...(value || [])].sort(); if (!asc) { result = result.reverse(); } return result.join(', '); } }
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
MethodDeclaration
public transform(value: string[], asc = true): string { let result = [...(value || [])].sort(); if (!asc) { result = result.reverse(); } return result.join(', '); }
Teamop/ng-mocks
examples/TestPipe/test.spec.ts
TypeScript
ArrowFunction
(props) => { const router = useRouter() return ( <Card className={styles.card} hoverable> <div className={styles.cardBody} onClick={()
moyu-developer/moyu-free-code
package/ui/pages/desktop/components/SearchTable/Card/index.tsx
TypeScript
ArrowFunction
(match, offset) => `<font color="#7af87a">${word.substr(offset, match.length)}</font>`
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
ArrowFunction
g => `<strong${g[1] === '1' ? '' : ' style="color: #DBA"'}>${Utils.escapeHTML(g[0])}</strong>`
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
ArrowFunction
w => w.length > 20
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
ArrowFunction
room => ({ label: "Hangman", permission: 'editroom', options: [ [`disabled`, room.settings.hangmanDisabled || 'hangman disable'], [`enabled`, !room.settings.hangmanDisabled || 'hangman enable'], ], })
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
choose(user: User, word: string) { if (user.id === this.creator) throw new Chat.ErrorMessage("You can't guess in your own hangman game."); const sanitized = word.replace(/[^A-Za-z ]/g, ''); const normalized = toID(sanitized); if (normalized.length < 1) { throw new Chat.ErrorMessage(`Use "/guess [letter]" to guess a letter, or "/guess [phrase]" to guess the entire Hangman phrase.`); } if (sanitized.length > 30) throw new Chat.ErrorMessage(`Guesses must be 30 or fewer letters – "${word}" is too long.`); for (const guessid of this.guesses) { if (normalized === toID(guessid)) throw new Chat.ErrorMessage(`Your guess "${word}" has already been guessed.`); } if (sanitized.length > 1) { if (!this.guessWord(sanitized, user.name)) { throw new Chat.ErrorMessage(`Your guess "${sanitized}" is invalid.`); } else { this.room.send(`${user.name} guessed "${sanitized}"!`); } } else { if (!this.guessLetter(sanitized, user.name)) { throw new Chat.ErrorMessage(`Your guess "${sanitized}" is not a valid letter.`); } } }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
guessLetter(letter: string, guesser: string) { letter = letter.toUpperCase(); if (this.guesses.includes(letter)) return false; if (this.word.toUpperCase().includes(letter)) { for (let i = 0; i < this.word.length; i++) { if (this.word[i].toUpperCase() === letter) { this.wordSoFar[i] = this.word[i]; } } if (!this.wordSoFar.includes('_')) { this.incorrectGuesses = -1; this.guesses.push(letter); this.letterGuesses.push(`${letter}1`); this.lastGuesser = guesser; this.finish(); return true; } this.letterGuesses.push(`${letter}1`); } else { this.incorrectGuesses++; this.letterGuesses.push(`${letter}0`); } this.guesses.push(letter); this.lastGuesser = guesser; this.update(); return true; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
guessWord(word: string, guesser: string) { const ourWord = toID(this.word); const guessedWord = toID(word); if (ourWord === guessedWord) { for (const [i, letter] of this.wordSoFar.entries()) { if (letter === '_') { this.wordSoFar[i] = this.word[i]; } } this.incorrectGuesses = -1; this.guesses.push(word); this.lastGuesser = guesser; this.finish(); return true; } else if (ourWord.length === guessedWord.length) { this.incorrectGuesses++; this.guesses.push(word); this.lastGuesser = guesser; this.update(); return true; } return false; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
hangingMan() { return `<img width="120" height="120" src="//${Config.routes.client}/fx/hangman${this.incorrectGuesses === -1 ? 7 : this.incorrectGuesses}.png" />`; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
generateWindow() { let result = 0; if (this.incorrectGuesses === maxMistakes) { result = 1; } else if (!this.wordSoFar.includes('_')) { result = 2; } const color = result === 1 ? 'red' : (result === 2 ? 'green' : 'blue'); const message = `${result === 1 ? 'Too bad! The mon has been hanged.' : (result === 2 ? 'The word has been guessed. Congratulations!' : 'Hangman')}`; let output = `<div class="broadcast-${color}">`; output += `<p style="text-align:left;font-weight:bold;font-size:10pt;margin:5px 0 0 15px">${message}</p>`; output += `<table><tr><td style="text-align:center;">${this.hangingMan()}</td><td style="text-align:center;width:100%;word-wrap:break-word">`; let wordString = this.wordSoFar.join(''); if (result === 1) { const word = this.word; wordString = wordString.replace( /_+/g, (match, offset) => `<font color="#7af87a">${word.substr(offset, match.length)}</font>` ); } if (this.hint) output += Utils.html`<div>(Hint: ${this.hint})</div>`; output += `<p style="font-weight:bold;font-size:12pt;letter-spacing:3pt">${wordString}</p>`; if (this.guesses.length) { if (this.letterGuesses.length) { output += 'Letters: ' + this.letterGuesses.map( g => `<strong${g[1] === '1' ? '' : ' style="color: #DBA"'}>${Utils.escapeHTML(g[0])}</strong>` ).join(', '); } if (result === 2) { output += Utils.html`<br />Winner: ${this.lastGuesser}`; } else if (this.guesses[this.guesses.length - 1].length === 1) { // last guess was a letter output += Utils.html` <small>&ndash; ${this.lastGuesser}</small>`; } else { output += Utils.html`<br />Guessed: ${this.guesses[this.guesses.length - 1]} ` + `<small>&ndash; ${this.lastGuesser}</small>`; } } output += '</td></tr></table></div>'; return output; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
display(user: User, broadcast = false) { if (broadcast) { this.room.add(`|uhtml|hangman${this.gameNumber}|${this.generateWindow()}`); } else { user.sendTo(this.room, `|uhtml|hangman${this.gameNumber}|${this.generateWindow()}`); } }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
update() { this.room.uhtmlchange(`hangman${this.gameNumber}`, this.generateWindow()); if (this.incorrectGuesses === maxMistakes) { this.finish(); } }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
end() { this.room.uhtmlchange(`hangman${this.gameNumber}`, '<div class="infobox">(The game of hangman was ended.)</div>'); this.room.add("The game of hangman was ended."); this.room.game = null; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
finish() { this.room.uhtmlchange(`hangman${this.gameNumber}`, '<div class="infobox">(The game of hangman has ended &ndash; scroll down to see the results)</div>'); this.room.add(`|html|${this.generateWindow()}`); this.room.game = null; }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
new(target, room, user, connection) { room = this.requireRoom(); const text = this.filter(target); if (target !== text) return this.errorReply("You are not allowed to use filtered words in hangmans."); const params = text.split(','); this.checkCan('minigame', null, room); if (room.settings.hangmanDisabled) return this.errorReply("Hangman is disabled for this room."); this.checkChat(); if (room.game) return this.errorReply(`There is already a game of ${room.game.title} in progress in this room.`); if (!params) return this.errorReply("No word entered."); const word = params[0].replace(/[^A-Za-z '-]/g, ''); if (word.replace(/ /g, '').length < 1) return this.errorReply("Enter a valid word"); if (word.length > 30) return this.errorReply("Phrase must be less than 30 characters."); if (word.split(' ').some(w => w.length > 20)) { return this.errorReply("Each word in the phrase must be less than 20 characters."); } if (!/[a-zA-Z]/.test(word)) return this.errorReply("Word must contain at least one letter."); let hint; if (params.length > 1) { hint = params.slice(1).join(',').trim(); if (hint.length > 150) return this.errorReply("Hint too long."); } const game = new Hangman(room, user, word, hint); room.game = game; game.display(user, true); this.modlog('HANGMAN'); return this.addModAction(`A game of hangman was started by ${user.name} – use /guess to play!`); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
guess(target, room, user) { this.parse(`/choose ${target}`); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
end(target, room, user) { room = this.requireRoom(); this.checkCan('minigame', null, room); this.checkChat(); const game = this.requireGame(Hangman); game.end(); this.modlog('ENDHANGMAN'); return this.privateModAction(`The game of hangman was ended by ${user.name}.`); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
disable(target, room, user) { room = this.requireRoom(); this.checkCan('gamemanagement', null, room); if (room.settings.hangmanDisabled) { return this.errorReply("Hangman is already disabled."); } room.settings.hangmanDisabled = true; room.saveSettings(); return this.sendReply("Hangman has been disabled for this room."); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
enable(target, room, user) { room = this.requireRoom(); this.checkCan('gamemanagement', null, room); if (!room.settings.hangmanDisabled) { return this.errorReply("Hangman is already enabled."); } delete room.settings.hangmanDisabled; room.saveSettings(); return this.sendReply("Hangman has been enabled for this room."); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
display(target, room, user) { room = this.requireRoom(); const game = this.requireGame(Hangman); if (!this.runBroadcast()) return; room.update(); game.display(user, this.broadcasting); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
MethodDeclaration
''(target, room, user) { return this.parse('/help hangman'); }
SmashChamp/SmashChamp.github.io
server/chat-plugins/hangman.ts
TypeScript
FunctionDeclaration
async function main() { const [dir, all, id] = cliArguments(); const { img, num: length } = await xkdc(id); await ensureDir(dir); const kia = spinner( `Downloading ${all ? `${length} ` : ""}comic${all ? "s" : ""}...`, ); kia.start(); if (all) { const dp = Array.from({ length }); for (let index = 0; index < length; index++) { if (index == 404) continue; // little xkcd author bad joke const { img, num } = await xkdc(index); dp.push(download(img, `${dir}/${num}_${filenameFromURL(img)}`)); } await Promise.all(dp); } else { await download(img, `${dir}/${length}_${filenameFromURL(img)}`); } kia.succeed(); }
UltiRequiem/xkcd
cli.ts
TypeScript
ArrowFunction
(): ReactElement => ( <div id='main'> <Table /> </div>
Sergih28/setup-comparator
src/components/Main/index.tsx
TypeScript
ArrowFunction
data => { if (data.isSuccessfully) { res.status(HttpStatus.OK).end(data.message); } res.status(HttpStatus.BAD_REQUEST).end(data.message); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
ArrowFunction
isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Successfully'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
ArrowFunction
data => { if (data) { res.status(HttpStatus.MOVED_PERMANENTLY).end('https://myside/callback?access_token=' + data); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
ArrowFunction
isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Reset password is sent to your email'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
ClassDeclaration
@Controller('user') export class UserController { constructor(private readonly _userService: UserService) {} @Get('') showLoginPage() { return 'login page'; } @Post('register') async register(@Body() body, @Res() res) { this._userService.signUp(body).then(data => { if (data.isSuccessfully) { res.status(HttpStatus.OK).end(data.message); } res.status(HttpStatus.BAD_REQUEST).end(data.message); }); } @Post('change-password') async changePassword(@Body() body, @Res() res) { await this._userService.changePassword(body).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Successfully'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); } @Post('delete') async delete(@Body() body: Login, @Res() res) { await this._userService.delete(body).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Successfully'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); } @Post('login') async login(@Body() body: Login, @Query() client: ClientInfo, @Res() res) { await this._userService.login(body, client).then(data => { if (data) { res.status(HttpStatus.MOVED_PERMANENTLY).end('https://myside/callback?access_token=' + data); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); } @Post('reset-password') async resetPassword(@Body() body: any, @Res() res) { await this._userService.resetPassword(body.email).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Reset password is sent to your email'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); } }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Get('') showLoginPage() { return 'login page'; }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('register') async register(@Body() body, @Res() res) { this._userService.signUp(body).then(data => { if (data.isSuccessfully) { res.status(HttpStatus.OK).end(data.message); } res.status(HttpStatus.BAD_REQUEST).end(data.message); }); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('change-password') async changePassword(@Body() body, @Res() res) { await this._userService.changePassword(body).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Successfully'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('delete') async delete(@Body() body: Login, @Res() res) { await this._userService.delete(body).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Successfully'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('login') async login(@Body() body: Login, @Query() client: ClientInfo, @Res() res) { await this._userService.login(body, client).then(data => { if (data) { res.status(HttpStatus.MOVED_PERMANENTLY).end('https://myside/callback?access_token=' + data); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('reset-password') async resetPassword(@Body() body: any, @Res() res) { await this._userService.resetPassword(body.email).then(isSuccess => { if (isSuccess) { res.status(HttpStatus.OK).end('Reset password is sent to your email'); } res.status(HttpStatus.BAD_REQUEST).end('Failed'); }); }
sang-dang/Identity-server
src/user/user.controller.ts
TypeScript
InterfaceDeclaration
export interface Transformer { /** 正向的转换函数 */ from?: (schema: any) => any; /** 反向的转换函数 */ to?: (schema: any) => any; /** 反向的转换函数 */ fromSetting?: (schema: any) => any; /** 反向的转换函数 */ toSetting?: (schema: any) => any; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface ExtraButton { /** 按钮文案 */ text: string; /** 点击回调 */ onClick?: (event: any) => void; [key: string]: any; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface ControlButton { /** 按钮文案 */ text?: string; /** 点击回调 */ onClick?: (event: any, schema: any) => void; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface SettingWidget { /** 按钮生成的 schema 的 key 值 */ name: string; /** 在左侧栏按钮展示文案 */ text: string; /** 在左侧栏按钮展示图标 */ icon?: string | ReactNode; /** 如果是基本组件,这个字段注明它对应的 widgets */ widget?: string; /** 组件对应的 schema 片段 */ schema?: any; /** 组件的配置信息,使用 form-render 的 schema 来描述 */ setting?: any; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface Setting { /** 最外层的分组名称 */ title: string; /** 每个组件的配置,在左侧栏是一个按钮 */ widgets: SettingWidget[]; show?: boolean; useCommon?: boolean; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface FRGeneratorProps { getId?: (name: string) => string; /** 隐藏组件 ID */ hideId?: boolean; /** 固定 id */ fixedName?: boolean; /** 组件删除控制 */ canDelete?: boolean | Function; /** 默认一进入编辑器展示的表单对应的 schema */ defaultValue?: any; /** 自定义 schema 到 form-render 的 schema 的双向转换函数 */ transformer?: Transformer; /** 编辑区顶部的自定义按钮 */ extraButtons?: (ExtraButton | boolean | string)[]; /** 选中项操作按钮 */ controlButtons?: (ControlButton | boolean | Function)[]; /** 左右侧栏配置 */ settings?: Setting[]; /** 通用配置 */ commonSettings?: any; /** 全局配置 */ globalSettings?: any; /** 自定义组件 */ widgets?: any; /** 配置栏自定义组件 */ settingsWidgets?: any; /** 组件和 schema 的映射规则 */ mapping?: any; /** 配置表单校验 */ validation?: boolean; fieldRender?: ( schema?: any, widgetProps?: any, children?: ReactNode, originNode?: ReactNode ) => ReactNode; fieldWrapperRender?: ( schema?: any, isSelected?: boolean, children?: ReactNode, originNode?: ReactNode ) => ReactNode; elementRender?: ( schema?: any, widgetProps?: SettingWidget, originNode?: ReactNode ) => ReactNode; /** 表单 data 变化回调 */ onChange?: (data: any) => void; /** 表单 schema 变化回调 */ onSchemaChange?: (schema: any) => void; /** 画布组件选择回调 */ onCanvasSelect?: (schema: any) => void; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface SettingsProps { /** 自定义组件 */ widgets?: any; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface CanvasProps { /** 画布组件选择回调 */ onCanvasSelect?: (schema: any) => void; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface SidebarProps { /** 固定 id */ fixedName?: boolean; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
InterfaceDeclaration
export interface Generator extends ForwardRefExoticComponent< FRGeneratorProps & RefAttributes<HTMLElement> > { Provider: FC<FRGeneratorProps>; Settings: FC<SettingsProps>; Canvas: FC<CanvasProps>; Sidebar: FC<SidebarProps>; }
yangdy-buji/form-render
tools/schema-generator/src/index.d.ts
TypeScript
ClassDeclaration
@Component({ selector: 'home', templateUrl: './components/home/home.html', styleUrls: ['./components/home/home.css'], directives: [ExpensesListComponent, ExpenseFormComponent] }) export class HomeCmp { expenseService:ExpenseService; constructor(expenseService:ExpenseService) { this.expenseService = expenseService; } }
kiwikern/expra
app/components/home/home.ts
TypeScript
FunctionDeclaration
function createArrayFormWith2Items() { const contentForm = createForm([ createField({ id: 4, properties: createProperties('Array'), partitioning: 'invariant', nested: [ createNestedField({ id: 41, properties: createProperties('String') }), createNestedField({ id: 42, properties: createProperties('String', { defaultValue: 'Default' }), isDisabled: true }), ], }), ]); const array = contentForm.get('field4')!.get('iv') as FieldArrayForm; contentForm.load({ field4: { iv: [{ nested41: 'Text1', }, { nested41: 'Text2', }], }, }); return { contentForm, array }; }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
FunctionDeclaration
function expectLength(array: FieldArrayForm, length: number) { expect(array.form.controls.length).toBe(length); expect(array.items.length).toBe(length); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
FunctionDeclaration
function expectForm(parent: AbstractControl, path: string, test: { invalid?: boolean; disabled?: boolean; value?: any }) { const form = parent.get(path); if (form) { for (const key in test) { if (test.hasOwnProperty(key)) { const a = form[key]; const e = test[key]; expect(a).toBe(e, `Expected ${key} of ${path} to be <${e}>, but found <${a}>.`); } } } else { expect(form).not.toBeNull(`Expected to find form ${path}, but form not found.`); } }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
FunctionDeclaration
function createForm(fields: RootFieldDto[], fieldRules: FieldRule[] = [], schemas: { [id: string]: SchemaDto } = {}) { return new EditContentForm(languages, createSchema({ fields, fieldRules }), schemas, {}, 0); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const language = new LanguageDto('en', 'English'); const fieldInvariant = createField({ properties: createProperties('Number'), partitioning: 'invariant' }); const fieldLocalized = createField({ properties: createProperties('Number') }); const fieldAssets = createField({ properties: createProperties('Assets') }); it('should resolve image url and filename from referenced asset', () => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithImageAndFileName = createField({ properties: createProperties('Assets', { previewMode: 'ImageAndFileName' }) }); const result = getContentValue(content, language, assetWithImageAndFileName); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: new HtmlValue('<img src="url/to/13?width=50&height=50" /> <span>file13</span>') }); }); it('should resolve image url only from referenced asset', () => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithImage = createField({ properties: createProperties('Assets', { previewMode: 'Image' }) }); const result = getContentValue(content, language, assetWithImage); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: new HtmlValue('<img src="url/to/13?width=50&height=50" />') }); }); it('should resolve filename only from referenced asset', () => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithFileName = createField({ properties: createProperties('Assets', { previewMode: 'FileName' }) }); const result = getContentValue(content, language, assetWithFileName); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: 'file13' }); }); it('should resolve filename from referenced asset', () => { const content: any = { referenceData: { field1: { en: ['file13'], }, }, }; const result = getContentValue(content, language, fieldAssets); expect(result).toEqual({ value: ['file13'], formatted: 'file13' }); }); it('should not image url if not found', () => { const content: any = { referenceData: { field1: { en: null, }, }, }; const result = getContentValue(content, language, fieldAssets); expect(result).toEqual({ value: '-', formatted: '-' }); }); it('should resolve string field from references value', () => { const content: any = { referenceData: { field1: { iv: '13', }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: '13', formatted: '13' }); }); it('should resolve invariant field from references value', () => { const content: any = { referenceData: { field1: { iv: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: '13', formatted: '13' }); }); it('should resolve localized field from references value', () => { const content: any = { referenceData: { field1: { en: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: '13', formatted: '13' }); }); it('should return default value if reference field not found', () => { const content: any = { referenceData: { field1: { iv: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: '-', formatted: '-' }); }); it('should resolve invariant field', () => { const content: any = { data: { field1: { iv: 13, }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: 13, formatted: '13' }); }); it('should resolve localized field', () => { const content: any = { data: { field1: { en: 13, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: 13, formatted: '13' }); }); it('should return default values if field not found', () => { const content: any = { data: { other: { en: 13, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: undefined, formatted: '' }); }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithImageAndFileName = createField({ properties: createProperties('Assets', { previewMode: 'ImageAndFileName' }) }); const result = getContentValue(content, language, assetWithImageAndFileName); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: new HtmlValue('<img src="url/to/13?width=50&height=50" /> <span>file13</span>') }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithImage = createField({ properties: createProperties('Assets', { previewMode: 'Image' }) }); const result = getContentValue(content, language, assetWithImage); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: new HtmlValue('<img src="url/to/13?width=50&height=50" />') }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: ['url/to/13', 'file13'], }, }, }; const assetWithFileName = createField({ properties: createProperties('Assets', { previewMode: 'FileName' }) }); const result = getContentValue(content, language, assetWithFileName); expect(result).toEqual({ value: ['url/to/13', 'file13'], formatted: 'file13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: ['file13'], }, }, }; const result = getContentValue(content, language, fieldAssets); expect(result).toEqual({ value: ['file13'], formatted: 'file13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: null, }, }, }; const result = getContentValue(content, language, fieldAssets); expect(result).toEqual({ value: '-', formatted: '-' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { iv: '13', }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: '13', formatted: '13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { iv: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: '13', formatted: '13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { en: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: '13', formatted: '13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { referenceData: { field1: { iv: { en: '13', }, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: '-', formatted: '-' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { data: { field1: { iv: 13, }, }, }; const result = getContentValue(content, language, fieldInvariant); expect(result).toEqual({ value: 13, formatted: '13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { data: { field1: { en: 13, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: 13, formatted: '13' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const content: any = { data: { other: { en: 13, }, }, }; const result = getContentValue(content, language, fieldLocalized); expect(result).toEqual({ value: undefined, formatted: '' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const partitions = new PartitionConfig(languages); it('should return invariant partitions', () => { const result = partitions.getAll(createField({ id: 3, properties: createProperties('String'), partitioning: 'invariant' })); expect(result).toEqual([ { key: 'iv', isOptional: false }, ]); }); it('should return language partitions', () => { const result = partitions.getAll(createField({ id: 3, properties: createProperties('String') })); expect(result).toEqual([ { key: 'en', isOptional: false }, { key: 'de', isOptional: true }, ]); }); it('should return partition for language', () => { const result = partitions.get(languages[1]); expect(result).toEqual({ key: 'de', isOptional: true }); }); it('should return partition for no language', () => { const result = partitions.get(); expect(result).toEqual({ key: 'iv', isOptional: false }); }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const result = partitions.getAll(createField({ id: 3, properties: createProperties('String'), partitioning: 'invariant' })); expect(result).toEqual([ { key: 'iv', isOptional: false }, ]); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const result = partitions.getAll(createField({ id: 3, properties: createProperties('String') })); expect(result).toEqual([ { key: 'en', isOptional: false }, { key: 'de', isOptional: true }, ]); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const result = partitions.get(languages[1]); expect(result).toEqual({ key: 'de', isOptional: true }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const result = partitions.get(); expect(result).toEqual({ key: 'iv', isOptional: false }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 1, properties: createProperties('String') }), createField({ id: 2, properties: createProperties('String'), isDisabled: true }), ]); expectForm(contentForm.form, 'field1', { disabled: false }); expectForm(contentForm.form, 'field2', { disabled: true }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 3, properties: createProperties('String', { isRequired: true }) }), ]); expectForm(contentForm.form, 'field3.en', { invalid: true }); expectForm(contentForm.form, 'field3.de', { invalid: false }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 1, properties: createProperties('Number'), partitioning: 'invariant' }), createField({ id: 2, properties: createProperties('Number'), partitioning: 'invariant' }), ], [{ field: 'field1', action: 'Require', condition: 'ctx.value < 100', }]); contentForm.setContext({ value: 50 }); const field1 = contentForm.get('field1')!.get('iv'); expect(field1!.form.valid).toBeFalsy(); contentForm.setContext({ value: 120 }); expect(field1!.form.valid).toBeTruthy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 1, properties: createProperties('Number'), partitioning: 'invariant' }), createField({ id: 2, properties: createProperties('Number'), partitioning: 'invariant' }), ], [{ field: 'field1', action: 'Require', condition: 'data.field2.iv < 100', }]); const field1 = contentForm.get('field1')!.get('iv'); const field2 = contentForm.get('field2'); expect(field1!.form.valid).toBeFalsy(); contentForm.load({ field2: { iv: 120, }, }); expect(field1!.form.valid).toBeTruthy(); field2?.get('iv')!.form.setValue(99); expect(field1!.form.valid).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 1, properties: createProperties('Number'), partitioning: 'invariant' }), createField({ id: 2, properties: createProperties('Number'), partitioning: 'invariant' }), ], [{ field: 'field1', action: 'Disable', condition: 'data.field2.iv > 100', }]); const field1 = contentForm.get('field1'); const field1_iv = contentForm.get('field1')!.get('iv'); const field2 = contentForm.get('field2'); expect(field1!.form.disabled).toBeFalsy(); contentForm.load({ field1: { iv: 120, }, field2: { iv: 120, }, }); expect(field1!.form.disabled).toBeTruthy(); expect(field1_iv!.form.disabled).toBeTruthy(); field2?.get('iv')!.form.setValue(99); expect(field1!.form.disabled).toBeFalsy(); expect(field1_iv!.form.disabled).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 1, properties: createProperties('Number'), partitioning: 'invariant' }), createField({ id: 2, properties: createProperties('Number'), partitioning: 'invariant' }), ], [{ field: 'field1', action: 'Hide', condition: 'data.field2.iv > 100', }]); const field1 = contentForm.get('field1'); const field1_iv = contentForm.get('field1')!.get('iv'); const field2 = contentForm.get('field2'); expect(field1!.hidden).toBeFalsy(); contentForm.load({ field1: { iv: 120, }, field2: { iv: 120, }, }); expect(field1!.hidden).toBeTruthy(); expect(field1_iv!.hidden).toBeTruthy(); field2?.get('iv')!.form.setValue(99); expect(field1!.hidden).toBeFalsy(); expect(field1_iv!.hidden).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 4, properties: createProperties('Array'), partitioning: 'invariant', nested: [ createNestedField({ id: 41, properties: createProperties('Number') }), createNestedField({ id: 42, properties: createProperties('Number') }), ], }), ], [{ field: 'field4.nested42', action: 'Disable', condition: 'itemData.nested41 > 100', }]); const array = contentForm.get(complexSchema.fields[3])!.get(languages[0]) as FieldArrayForm; contentForm.load({ field4: { iv: [{ nested41: 120, nested42: 120, }, { nested41: 99, nested42: 99, }], }, }); expect(array.get(0)!.get('nested42')!.form.disabled).toBeTruthy(); expect(array.get(1)!.get('nested42')!.form.disabled).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 4, properties: createProperties('Array'), partitioning: 'invariant', nested: [ createNestedField({ id: 41, properties: createProperties('Number') }), createNestedField({ id: 42, properties: createProperties('Number') }), ], }), ], [{ field: 'field4.nested42', action: 'Hide', condition: 'itemData.nested41 > 100', }]); const array = contentForm.get(complexSchema.fields[3])!.get(languages[0]) as FieldArrayForm; contentForm.load({ field4: { iv: [{ nested41: 120, nested42: 120, }, { nested41: 99, nested42: 99, }], }, }); expect(array.get(0)!.get('nested42')!.hidden).toBeTruthy(); expect(array.get(1)!.get('nested42')!.hidden).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const componentId = MathHelper.guid(); const component = createSchema({ id: 2, fields: [ createField({ id: 1, properties: createProperties('String'), partitioning: 'invariant', }), ], fieldRules: [{ field: 'field1', action: 'Hide', condition: 'data.field1 > 100', }], }); const contentForm = createForm([ createField({ id: 4, properties: createProperties('Components'), partitioning: 'invariant', }), ], [], { [componentId]: component, }); const array = contentForm.get(complexSchema.fields[3])!.get(languages[0]) as FieldArrayForm; contentForm.load({ field4: { iv: [{ schemaId: componentId, field1: 120, }, { schemaId: componentId, field1: 99, }], }, }); // Should hide fields. expect(array.get(0)!.get('field1')!.hidden).toBeTruthy(); expect(array.get(1)!.get('field1')!.hidden).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const componentId = MathHelper.guid(); const component = createSchema({ id: 1, fields: [ createField({ id: 11, properties: createProperties('String', { defaultValue: 'Initial', }), partitioning: 'invariant', }), createField({ id: 12, properties: createProperties('Number', { defaultValue: 12, }), partitioning: 'invariant', }), ], }); const contentForm = createForm([ createField({ id: 4, properties: createProperties('Component'), partitioning: 'invariant', }), ], [], { [componentId]: component, }); contentForm.load({}); // Should be undefined by default. expect(contentForm.value).toEqual({ field4: { iv: undefined, }, }); (contentForm.get('field4')?.get('iv') as ComponentForm).selectSchema(componentId); // Should add field from component. expect(contentForm.value).toEqual({ field4: { iv: { schemaId: componentId, field11: 'Initial', field12: 12, }, }, }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const component1Id = MathHelper.guid(); const component1 = createSchema({ id: 1, fields: [ createField({ id: 11, properties: createProperties('String'), partitioning: 'invariant', }), ], }); const component2Id = MathHelper.guid(); const component2 = createSchema({ id: 2, fields: [ createField({ id: 21, properties: createProperties('String'), partitioning: 'invariant', }), ], }); const contentForm = createForm([ createField({ id: 4, properties: createProperties('Component'), partitioning: 'invariant', }), ], [], { [component1Id]: component1, [component2Id]: component2, }); contentForm.load({}); // Should be undefined by default. expect(contentForm.value).toEqual({ field4: { iv: undefined, }, }); contentForm.load({ field4: { iv: { schemaId: component1Id, }, }, }); // Should add field from component1. expect(contentForm.value).toEqual({ field4: { iv: { schemaId: component1Id, field11: null, }, }, }); contentForm.load({ field4: { iv: { schemaId: component2Id, }, }, }); // Should add field from component1. expect(contentForm.value).toEqual({ field4: { iv: { schemaId: component2Id, field21: null, }, }, }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const componentId = MathHelper.guid(); const component = createSchema({ id: 1, fields: [ createField({ id: 11, properties: createProperties('String'), partitioning: 'invariant', }), ], }); const contentForm = createForm([ createField({ id: 4, properties: createProperties('Component'), partitioning: 'invariant', }), ], [], { [componentId]: component, }); contentForm.load({ field4: { iv: { schemaId: 'invalid', }, }, }); // Should ignore invalid id. expect(contentForm.value).toEqual({ field4: { iv: {}, }, }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { contentForm, array } = createArrayFormWith2Items(); contentForm.load({ field4: { iv: [{ nested41: 'Text', }], }, }); const nestedItem = array.form.get([0])!; expectLength(array, 1); expectForm(nestedItem, 'nested41', { disabled: false, value: 'Text' }); expectForm(nestedItem, 'nested42', { disabled: true, value: null }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { array } = createArrayFormWith2Items(); array.addItem(); const nestedItem = array.form.get([2])!; expectLength(array, 3); expectForm(nestedItem, 'nested41', { disabled: false, value: null }); expectForm(nestedItem, 'nested42', { disabled: true, value: 'Default' }); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { array } = createArrayFormWith2Items(); array.sort([array.get(1), array.get(0)]); expectLength(array, 2); expect(array.form.value).toEqual([{ nested41: 'Text2', nested42: null }, { nested41: 'Text1', nested42: null }]); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { array } = createArrayFormWith2Items(); array.removeItemAt(0); expectLength(array, 1); expect(array.form.value).toEqual([{ nested41: 'Text2', nested42: null }]); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { array } = createArrayFormWith2Items(); array.setValue([]); expectLength(array, 0); expect(array.form.value).toEqual([]); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const { array } = createArrayFormWith2Items(); array.unset(); expectLength(array, 0); expect(array.form.value).toEqual(undefined); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const contentForm = createForm([ createField({ id: 4, properties: createProperties('Array'), partitioning: 'invariant' }), ]); const nestedForm = contentForm.form.get('field4.iv') as FormArray; expect(nestedForm.controls.length).toBe(0); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const simpleForm = createForm([ createField({ id: 1, properties: createProperties('String'), partitioning: 'invariant' }), ]); const hasChanged = simpleForm.hasChanges({ field1: { iv: 'other' } }); expect(hasChanged).toBeTruthy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript
ArrowFunction
() => { const simpleForm = createForm([ createField({ id: 1, properties: createProperties('String'), partitioning: 'invariant' }), ]); const hasChanged = simpleForm.hasChanges({ field1: { iv: null } }); expect(hasChanged).toBeFalsy(); }
MartijnDijkgraaf/squidex
frontend/src/app/shared/state/contents.forms.spec.ts
TypeScript