-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(compass): Add renderer test for theme (#2774)
- Loading branch information
Showing
4 changed files
with
97 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@mongodb-js/mocha-config-compass/compass-plugin'); |
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 |
---|---|---|
|
@@ -46,4 +46,4 @@ module.exports = { | |
enableDarkTheme, | ||
disableDarkTheme, | ||
loadTheme | ||
} | ||
}; |
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,92 @@ | ||
const { expect } = require('chai'); | ||
const sinon = require('sinon'); | ||
|
||
const { | ||
enableDarkTheme, | ||
disableDarkTheme, | ||
loadTheme | ||
} = require('./theme'); | ||
|
||
describe('theme', function() { | ||
let appRegistryEmitSpy; | ||
|
||
beforeEach(function() { | ||
appRegistryEmitSpy = sinon.fake(); | ||
|
||
global.hadronApp = { | ||
appRegistry: { | ||
emit: appRegistryEmitSpy | ||
} | ||
}; | ||
}); | ||
|
||
describe('#enableDarkTheme', function() { | ||
it('should set the dark theme on the global hadron app', function() { | ||
expect(global.hadronApp.theme).to.equal(undefined); | ||
|
||
enableDarkTheme(); | ||
|
||
expect(global.hadronApp.theme).to.equal('Dark'); | ||
}); | ||
|
||
it('should emit the dark theme to the app registry', function() { | ||
expect(appRegistryEmitSpy.callCount).to.equal(0); | ||
|
||
enableDarkTheme(); | ||
|
||
expect(appRegistryEmitSpy.callCount).to.equal(1); | ||
expect(appRegistryEmitSpy.firstCall.args[0]).to.equal('darkmode-enable'); | ||
expect(global.hadronApp.theme).to.equal('Dark'); | ||
}); | ||
}); | ||
|
||
describe('#disableDarkTheme', function() { | ||
it('should set the light theme on the global hadron app', function() { | ||
expect(global.hadronApp.theme).to.equal(undefined); | ||
|
||
disableDarkTheme(); | ||
|
||
expect(global.hadronApp.theme).to.equal('Light'); | ||
}); | ||
|
||
it('should emit disable dark theme to the app registry', function() { | ||
expect(appRegistryEmitSpy.callCount).to.equal(0); | ||
|
||
disableDarkTheme(); | ||
|
||
expect(appRegistryEmitSpy.callCount).to.equal(1); | ||
expect(appRegistryEmitSpy.firstCall.args[0]).to.equal('darkmode-disable'); | ||
expect(global.hadronApp.theme).to.equal('Light'); | ||
}); | ||
}); | ||
|
||
describe('#loadTheme', function() { | ||
it('should set the dark theme on the app registry', function() { | ||
expect(global.hadronApp.theme).to.equal(undefined); | ||
|
||
loadTheme('DARK'); | ||
|
||
expect(global.hadronApp.theme).to.equal('Dark'); | ||
expect(appRegistryEmitSpy.firstCall.args[0]).to.equal('darkmode-enable'); | ||
expect(appRegistryEmitSpy.callCount).to.equal(1); | ||
}); | ||
|
||
it('should set the light theme on the app registry', function() { | ||
expect(appRegistryEmitSpy.callCount).to.equal(0); | ||
|
||
loadTheme('LIGHT'); | ||
|
||
expect(appRegistryEmitSpy.callCount).to.equal(1); | ||
expect(appRegistryEmitSpy.firstCall.args[0]).to.equal('darkmode-disable'); | ||
expect(global.hadronApp.theme).to.equal('Light'); | ||
}); | ||
|
||
it('should set the theme on the app registry with os theme', function() { | ||
expect(appRegistryEmitSpy.callCount).to.equal(0); | ||
|
||
loadTheme('OS_THEME'); | ||
|
||
expect(appRegistryEmitSpy.callCount).to.equal(1); | ||
}) | ||
}); | ||
}); |