-
Notifications
You must be signed in to change notification settings - Fork 435
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
1 parent
26dd321
commit 0b7aac3
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/sanity/src/_internal/cli/util/__tests__/shouldAutoUpdate.test.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,40 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
import {type CliConfig} from '@sanity/cli' | ||
|
||
import {type BuildSanityStudioCommandFlags} from '../../actions/build/buildAction' | ||
import {shouldAutoUpdate} from '../shouldAutoUpdate' | ||
|
||
describe('shouldAutoUpdate', () => { | ||
it('should return true when flags["auto-updates"] is true', () => { | ||
const flags: BuildSanityStudioCommandFlags = {'auto-updates': true} | ||
expect(shouldAutoUpdate({flags})).toBe(true) | ||
}) | ||
|
||
it('should return false when flags["auto-updates"] is false', () => { | ||
const flags: BuildSanityStudioCommandFlags = {'auto-updates': false} | ||
expect(shouldAutoUpdate({flags})).toBe(false) | ||
}) | ||
|
||
it('should return true when cliConfig.autoUpdates is true and flags["auto-updates"] is not set', () => { | ||
const flags: BuildSanityStudioCommandFlags = {} | ||
const cliConfig: CliConfig = {autoUpdates: true} | ||
expect(shouldAutoUpdate({flags, cliConfig})).toBe(true) | ||
}) | ||
|
||
it('should return false when cliConfig.autoUpdates is false and flags["auto-updates"] is not set', () => { | ||
const flags: BuildSanityStudioCommandFlags = {} | ||
const cliConfig: CliConfig = {autoUpdates: false} | ||
expect(shouldAutoUpdate({flags, cliConfig})).toBe(false) | ||
}) | ||
|
||
it('should return false when both flags["auto-updates"] and cliConfig.autoUpdates are not set', () => { | ||
const flags: BuildSanityStudioCommandFlags = {} | ||
expect(shouldAutoUpdate({flags})).toBe(false) | ||
}) | ||
|
||
it('should prioritize flags over cliConfig when both are set', () => { | ||
const flags: BuildSanityStudioCommandFlags = {'auto-updates': false} | ||
const cliConfig: CliConfig = {autoUpdates: true} | ||
expect(shouldAutoUpdate({flags, cliConfig})).toBe(false) | ||
}) | ||
}) |