-
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
83d0c4b
commit 25332a4
Showing
3 changed files
with
61 additions
and
55 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,50 +1,42 @@ | ||
describe('DevTools Extension setup', function (){ | ||
|
||
var app, storage, panel, stylesDir; | ||
var app, pagePath, panel, storage, stylesDir; | ||
|
||
/** Variables & chrome.* API stubs */ | ||
beforeAll(function(){ | ||
app = window.app; | ||
storage = chrome.storage.sync; | ||
panel = chrome.devtools.panels; | ||
stylesDir = 'dist/styles/'; | ||
stylesDir = '/dist/styles/'; | ||
pagePath = '/dist/panel.html'; | ||
|
||
spyOn(XMLHttpRequest.prototype, 'open').and.callThrough(); | ||
spyOn(XMLHttpRequest.prototype, 'send'); | ||
storage.set({ 'devtools-theme': '3024' }); | ||
storage.get.withArgs('devtools-theme').yields({ 'devtools-theme': '3024' }); | ||
}); | ||
|
||
describe('Creates Author Settings panel via chrome.devtools.panels', function(){ | ||
|
||
it('should load panel HTML', function(){ | ||
var pagePath = 'dist/panel.html'; | ||
|
||
panel.create('Author Settings', null, pagePath, function(panelObj){ | ||
expect(panelObj).toBeDefined(); | ||
}); | ||
}); | ||
|
||
/** app.init */ | ||
it('should create Author Settings panel using chrome.devtools.panels', function(){ | ||
spyOn(app, 'init'); | ||
app.init(); | ||
|
||
expect(app.init).toHaveBeenCalled(); | ||
expect(panel.create.calledWith('Author Settings', null, pagePath)).toBe(true); | ||
}); | ||
|
||
describe('Get stylesheet name from chrome.storage and load stylesheet via AJAX', function(){ | ||
var theme; | ||
|
||
it('should get theme settings from storage', function(){ | ||
storage.get('devtools-theme', function(object){ | ||
theme = object['devtools-theme']; | ||
expect(theme).toBe('monokai'); | ||
}); | ||
}); | ||
|
||
|
||
it('should GET theme CSS file via AJAX', function(){ | ||
var options = { | ||
theme: stylesDir + 'themes/' + theme + '.css' | ||
}; | ||
/** app.loadTheme */ | ||
it('should load theme CSS file via AJAX using chrome.storage settings', function(){ | ||
var theme, themeObject; | ||
|
||
spyOn(XMLHttpRequest.prototype, 'open').and.callThrough(); | ||
spyOn(XMLHttpRequest.prototype, 'send'); | ||
|
||
app.loadTheme(options, function(){ | ||
expect(XMLHttpRequest.prototype.open).toHaveBeenCalled(); | ||
}); | ||
storage.get('devtools-theme', function(object){ | ||
theme = object['devtools-theme']; | ||
themeObject = { theme: stylesDir + 'themes/' + theme + '.css' }; | ||
}); | ||
|
||
expect(theme).toEqual('3024'); | ||
expect(app.loadTheme(themeObject)).toEqual('/dist/styles/themes/3024.css'); | ||
expect(XMLHttpRequest.prototype.open).toHaveBeenCalled(); | ||
}); | ||
|
||
}); | ||
}); |