2121 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222 * SOFTWARE.
2323 */
24+ import { vi , expect } from 'vitest'
25+ import type { MockInstance } from 'vitest'
2426import type { BaseTheme } from '@instructure/shared-types'
25- import { expect } from '@instructure/ui-test-utils'
2627import { ThemeRegistry } from '../ThemeRegistry'
2728const defaultRegistry = ThemeRegistry . getRegistry ( )
2829
@@ -40,17 +41,33 @@ const baseTheme = {
4041}
4142
4243describe ( 'ThemeRegistry' , ( ) => {
44+ let consoleWarningMock : ReturnType < typeof vi . spyOn >
45+ let consoleErrorMock : ReturnType < typeof vi . spyOn >
46+
4347 beforeEach ( ( ) => {
4448 ThemeRegistry . clearRegistry ( )
49+
50+ // Mocking console to prevent test output pollution
51+ consoleWarningMock = vi
52+ . spyOn ( console , 'warn' )
53+ . mockImplementation ( ( ) => { } ) as MockInstance
54+ consoleErrorMock = vi
55+ . spyOn ( console , 'error' )
56+ . mockImplementation ( ( ) => { } ) as MockInstance
4557 } )
58+
4659 afterEach ( ( ) => {
4760 ThemeRegistry . setRegistry ( defaultRegistry )
61+
62+ consoleWarningMock . mockRestore ( )
63+ consoleErrorMock . mockRestore ( )
4864 } )
65+
4966 it ( 'should instantiate registry correctly' , async ( ) => {
5067 const registry = ThemeRegistry . getRegistry ( )
5168
52- expect ( registry ) . to . not . be . empty ( )
53- expect ( registry ) . to . eql ( {
69+ expect ( registry ) . not . toEqual ( { } )
70+ expect ( registry ) . toEqual ( {
5471 currentThemeKey : null ,
5572 themes : { } ,
5673 registered : [ ]
@@ -69,9 +86,9 @@ describe('ThemeRegistry', () => {
6986 ThemeRegistry . registerTheme ( theme as unknown as BaseTheme )
7087 const registry = ThemeRegistry . getRegistry ( )
7188
72- expect ( registry . registered ) . to . contain ( theme . key )
73- expect ( registry . themes ) . to . have . key ( theme . key )
74- expect ( registry . themes [ theme . key ] ) . to . not . be . empty ( )
89+ expect ( registry . registered ) . toContain ( theme . key )
90+ expect ( Object . keys ( registry . themes ) ) . toContain ( theme . key )
91+ expect ( registry . themes [ theme . key ] ) . not . toEqual ( { } )
7592 } )
7693
7794 it ( 'should be able to get the current theme' , async ( ) => {
@@ -90,8 +107,8 @@ describe('ThemeRegistry', () => {
90107
91108 const registry = ThemeRegistry . getRegistry ( )
92109
93- expect ( registry . currentThemeKey ) . to . be . eq ( theme . key )
94- expect ( ThemeRegistry . getCurrentTheme ( ) ) . to . be . eql ( registeredTheme )
110+ expect ( registry . currentThemeKey ) . toBe ( theme . key )
111+ expect ( ThemeRegistry . getCurrentTheme ( ) ) . toEqual ( registeredTheme )
95112 } )
96113
97114 it ( 'should be able to override themes with ".use()"' , async ( ) => {
@@ -115,7 +132,7 @@ describe('ThemeRegistry', () => {
115132 }
116133 }
117134 } )
118- expect ( ThemeRegistry . getCurrentTheme ( ) ?. colors ?. primitives ?. white ) . to . be . eq (
135+ expect ( ThemeRegistry . getCurrentTheme ( ) ?. colors ?. primitives ?. white ) . toBe (
119136 'blue'
120137 )
121138 } )
@@ -130,6 +147,6 @@ describe('ThemeRegistry', () => {
130147 theme as unknown as BaseTheme
131148 )
132149 registeredTheme . use ( )
133- } ) . to . throw ( Error )
150+ } ) . toThrow ( Error )
134151 } )
135152} )
0 commit comments