-
Notifications
You must be signed in to change notification settings - Fork 53
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
952c749
commit 7babb70
Showing
3 changed files
with
95 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,112 @@ | ||
describe('DevTools Author Settings panel', function (){ | ||
var panel; | ||
|
||
|
||
var panel, storage; | ||
|
||
/** Global modules & chrome.* API stubs */ | ||
beforeAll(function(){ | ||
panel = window.panel; | ||
ga = window.ga; | ||
$ = document.querySelectorAll.bind(document); | ||
storage = chrome.storage.sync; | ||
panel = window.panel; | ||
storage = chrome.storage.sync; | ||
}); | ||
|
||
|
||
/** panel.init */ | ||
it('should GET theme.json via AJAX', function(){ | ||
spyOn(XMLHttpRequest.prototype, 'open').and.callThrough(); | ||
spyOn(XMLHttpRequest.prototype, 'send'); | ||
|
||
|
||
panel.init(); | ||
|
||
expect(panel).toBeDefined(); | ||
expect(XMLHttpRequest.prototype.open).toHaveBeenCalled(); | ||
}); | ||
|
||
/** panel.setTheme */ | ||
it('should set devtools-theme to storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
var event = { | ||
target: { | ||
options: [ | ||
{ | ||
value: '3024', | ||
text: '3024' | ||
} | ||
], | ||
selectedIndex: 0 | ||
}, | ||
type: 'change', | ||
bubbles: true, | ||
cancelable: false | ||
}; | ||
|
||
var theme = panel.setTheme(event); | ||
|
||
expect(panel.setTheme).toBeDefined(); | ||
expect(storage.set.calledWith({ 'devtools-theme': '3024' })).toBe(true); | ||
expect(theme).toEqual('3024'); | ||
}); | ||
|
||
it('should get devtools-theme from storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
/** panel.getTheme */ | ||
it('should return devtools-theme from storage or default', function(){ | ||
var themeJSON = [ | ||
{ "name": "Default", "colors": [] }, | ||
{ "name": "3024", "colors": [] }, | ||
{ "name": "Monokai", "colors": [] }, | ||
]; | ||
|
||
expect(panel.getTheme).toBeDefined(); | ||
expect(panel.getTheme()).toEqual('3024'); | ||
expect(storage.set.calledWith({ 'devtools-theme': '3024' })).toBe(true); | ||
expect(panel.getTheme(themeJSON, 'monokai')).toEqual('Monokai'); | ||
}); | ||
|
||
/** panel.setFontFamily */ | ||
it('should set devtools-fontFamily to storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
var event = { | ||
target: { | ||
value: 'Hack' | ||
}, | ||
type: 'change', | ||
bubbles: true, | ||
cancelable: false | ||
}; | ||
|
||
var fontFamily = panel.setFontFamily(event); | ||
|
||
expect(panel.setFontFamily).toBeDefined(); | ||
expect(storage.set.calledWith({ 'devtools-fontFamily': 'Hack' })).toBe(true); | ||
expect(fontFamily).toEqual('Hack'); | ||
}); | ||
|
||
it('should get devtools-fontFamily from storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
/** panel.getFontFamily */ | ||
it('should return devtools-fontFamily from storage or default', function(){ | ||
expect(panel.getFontFamily).toBeDefined(); | ||
expect(panel.getFontFamily()).toEqual('Hack'); | ||
expect(storage.set.calledWith({ 'devtools-fontFamily': 'Hack' })).toBe(true); | ||
expect(panel.getFontFamily('Menlo')).toEqual('Menlo'); | ||
}); | ||
|
||
/** panel.setFontSize */ | ||
it('should set devtools-fontSize to storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
var event = { | ||
target: { | ||
value: 16 | ||
}, | ||
type: 'change', | ||
bubbles: true, | ||
cancelable: false | ||
}; | ||
|
||
var fontSize = panel.setFontSize(event); | ||
|
||
expect(panel.setFontSize).toBeDefined(); | ||
expect(storage.set.calledWith({ 'devtools-fontSize': 16 })).toBe(true); | ||
expect(fontSize).toEqual(16); | ||
}); | ||
|
||
it('should get devtools-fontSize from storage', function(){ | ||
expect(panel).toBeDefined(); | ||
expect(storage).toBeDefined(); | ||
/** panel.getFontSize */ | ||
it('should return devtools-fontSize from storage or default', function(){ | ||
expect(panel.getFontSize).toBeDefined(); | ||
expect(panel.getFontSize()).toEqual(14); | ||
expect(storage.set.calledWith({ 'devtools-fontSize': 14 })).toBe(true); | ||
expect(panel.getFontSize(12)).toEqual(12); | ||
}); | ||
|
||
}); | ||
}); |