mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Stop using this
in install-panel-spec.js
This commit is contained in:
parent
90110ad812
commit
5084785fcf
@ -3,133 +3,137 @@ const InstallPanel = require('../lib/install-panel');
|
||||
const PackageManager = require('../lib/package-manager');
|
||||
const SettingsView = require('../lib/settings-view');
|
||||
|
||||
let packageManager;
|
||||
let panel;
|
||||
let gitUrlInfo;
|
||||
|
||||
describe('InstallPanel', function() {
|
||||
beforeEach(function() {
|
||||
const settingsView = new SettingsView();
|
||||
this.packageManager = new PackageManager();
|
||||
return this.panel = new InstallPanel(settingsView, this.packageManager);
|
||||
packageManager = new PackageManager();
|
||||
panel = new InstallPanel(settingsView, packageManager);
|
||||
});
|
||||
|
||||
describe("when the packages button is clicked", function() {
|
||||
beforeEach(function() {
|
||||
spyOn(this.panel, 'search');
|
||||
return this.panel.refs.searchEditor.setText('something');
|
||||
spyOn(panel, 'search');
|
||||
panel.refs.searchEditor.setText('something');
|
||||
});
|
||||
|
||||
it("performs a search for the contents of the input", function() {
|
||||
this.panel.refs.searchPackagesButton.click();
|
||||
expect(this.panel.searchType).toBe('packages');
|
||||
expect(this.panel.search).toHaveBeenCalledWith('something');
|
||||
expect(this.panel.search.callCount).toBe(1);
|
||||
panel.refs.searchPackagesButton.click();
|
||||
expect(panel.searchType).toBe('packages');
|
||||
expect(panel.search).toHaveBeenCalledWith('something');
|
||||
expect(panel.search.callCount).toBe(1);
|
||||
|
||||
this.panel.refs.searchPackagesButton.click();
|
||||
expect(this.panel.searchType).toBe('packages');
|
||||
expect(this.panel.search).toHaveBeenCalledWith('something');
|
||||
expect(this.panel.search.callCount).toBe(2);
|
||||
panel.refs.searchPackagesButton.click();
|
||||
expect(panel.searchType).toBe('packages');
|
||||
expect(panel.search).toHaveBeenCalledWith('something');
|
||||
expect(panel.search.callCount).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the themes button is clicked", function() {
|
||||
beforeEach(function() {
|
||||
spyOn(this.panel, 'search');
|
||||
return this.panel.refs.searchEditor.setText('something');
|
||||
spyOn(panel, 'search');
|
||||
panel.refs.searchEditor.setText('something');
|
||||
});
|
||||
|
||||
it("performs a search for the contents of the input", function() {
|
||||
this.panel.refs.searchThemesButton.click();
|
||||
expect(this.panel.searchType).toBe('themes');
|
||||
expect(this.panel.search.callCount).toBe(1);
|
||||
expect(this.panel.search).toHaveBeenCalledWith('something');
|
||||
panel.refs.searchThemesButton.click();
|
||||
expect(panel.searchType).toBe('themes');
|
||||
expect(panel.search.callCount).toBe(1);
|
||||
expect(panel.search).toHaveBeenCalledWith('something');
|
||||
|
||||
this.panel.refs.searchThemesButton.click();
|
||||
expect(this.panel.searchType).toBe('themes');
|
||||
expect(this.panel.search.callCount).toBe(2);
|
||||
panel.refs.searchThemesButton.click();
|
||||
expect(panel.searchType).toBe('themes');
|
||||
expect(panel.search.callCount).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the buttons are toggled", function() {
|
||||
beforeEach(function() {
|
||||
spyOn(this.panel, 'search');
|
||||
return this.panel.refs.searchEditor.setText('something');
|
||||
spyOn(panel, 'search');
|
||||
panel.refs.searchEditor.setText('something');
|
||||
});
|
||||
|
||||
it("performs a search for the contents of the input", function() {
|
||||
this.panel.refs.searchThemesButton.click();
|
||||
expect(this.panel.searchType).toBe('themes');
|
||||
expect(this.panel.search.callCount).toBe(1);
|
||||
expect(this.panel.search).toHaveBeenCalledWith('something');
|
||||
panel.refs.searchThemesButton.click();
|
||||
expect(panel.searchType).toBe('themes');
|
||||
expect(panel.search.callCount).toBe(1);
|
||||
expect(panel.search).toHaveBeenCalledWith('something');
|
||||
|
||||
this.panel.refs.searchPackagesButton.click();
|
||||
expect(this.panel.searchType).toBe('packages');
|
||||
expect(this.panel.search.callCount).toBe(2);
|
||||
panel.refs.searchPackagesButton.click();
|
||||
expect(panel.searchType).toBe('packages');
|
||||
expect(panel.search.callCount).toBe(2);
|
||||
|
||||
this.panel.refs.searchThemesButton.click();
|
||||
expect(this.panel.searchType).toBe('themes');
|
||||
expect(this.panel.search.callCount).toBe(3);
|
||||
panel.refs.searchThemesButton.click();
|
||||
expect(panel.searchType).toBe('themes');
|
||||
expect(panel.search.callCount).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("searching packages", () => it("displays the packages in the order returned", function() {
|
||||
spyOn(this.panel.client, 'search').andCallFake(() => Promise.resolve([{name: 'not-first'}, {name: 'first'}]));
|
||||
spyOn(this.panel, 'getPackageCardView').andCallThrough();
|
||||
spyOn(panel.client, 'search').andCallFake(() => Promise.resolve([{name: 'not-first'}, {name: 'first'}]));
|
||||
spyOn(panel, 'getPackageCardView').andCallThrough();
|
||||
|
||||
waitsForPromise(() => {
|
||||
return this.panel.search('first');
|
||||
return panel.search('first');
|
||||
});
|
||||
|
||||
return runs(function() {
|
||||
expect(this.panel.getPackageCardView.argsForCall[0][0].name).toEqual('not-first');
|
||||
expect(this.panel.getPackageCardView.argsForCall[1][0].name).toEqual('first');
|
||||
expect(panel.getPackageCardView.argsForCall[0][0].name).toEqual('not-first');
|
||||
expect(panel.getPackageCardView.argsForCall[1][0].name).toEqual('first');
|
||||
});
|
||||
}));
|
||||
|
||||
describe("searching git packages", function() {
|
||||
beforeEach(() => {
|
||||
return spyOn(this.panel, 'showGitInstallPackageCard').andCallThrough();
|
||||
return spyOn(panel, 'showGitInstallPackageCard').andCallThrough();
|
||||
});
|
||||
|
||||
it("shows a git installation card with git specific info for ssh URLs", function() {
|
||||
const query = 'git@github.com:user/repo.git';
|
||||
this.panel.performSearchForQuery(query);
|
||||
const args = this.panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
panel.performSearchForQuery(query);
|
||||
const args = panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
expect(args.name).toEqual(query);
|
||||
expect(args.gitUrlInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
it("shows a git installation card with git specific info for https URLs", function() {
|
||||
const query = 'https://github.com/user/repo.git';
|
||||
this.panel.performSearchForQuery(query);
|
||||
const args = this.panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
panel.performSearchForQuery(query);
|
||||
const args = panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
expect(args.name).toEqual(query);
|
||||
expect(args.gitUrlInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
it("shows a git installation card with git specific info for shortcut URLs", function() {
|
||||
const query = 'user/repo';
|
||||
this.panel.performSearchForQuery(query);
|
||||
const args = this.panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
panel.performSearchForQuery(query);
|
||||
const args = panel.showGitInstallPackageCard.argsForCall[0][0];
|
||||
expect(args.name).toEqual(query);
|
||||
expect(args.gitUrlInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
it("doesn't show a git installation card for normal packages", function() {
|
||||
const query = 'this-package-is-so-normal';
|
||||
this.panel.performSearchForQuery(query);
|
||||
expect(this.panel.showGitInstallPackageCard).not.toHaveBeenCalled();
|
||||
panel.performSearchForQuery(query);
|
||||
expect(panel.showGitInstallPackageCard).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("when a package with the same gitUrlInfo property is installed", function() {
|
||||
beforeEach(function() {
|
||||
this.gitUrlInfo = jasmine.createSpy('gitUrlInfo');
|
||||
return this.panel.showGitInstallPackageCard({gitUrlInfo: this.gitUrlInfo});
|
||||
gitUrlInfo = jasmine.createSpy('gitUrlInfo');
|
||||
return panel.showGitInstallPackageCard({gitUrlInfo: gitUrlInfo});
|
||||
});
|
||||
|
||||
it("replaces the package card with the newly installed pack object", function() {
|
||||
const newPack =
|
||||
{gitUrlInfo: this.gitUrlInfo};
|
||||
spyOn(this.panel, 'updateGitPackageCard');
|
||||
this.packageManager.emitter.emit('package-installed', {pack: newPack});
|
||||
expect(this.panel.updateGitPackageCard).toHaveBeenCalledWith(newPack);
|
||||
{gitUrlInfo: gitUrlInfo};
|
||||
spyOn(panel, 'updateGitPackageCard');
|
||||
packageManager.emitter.emit('package-installed', {pack: newPack});
|
||||
expect(panel.updateGitPackageCard).toHaveBeenCalledWith(newPack);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user