Skip to content

Commit

Permalink
api-test: fix file-search tests
Browse files Browse the repository at this point in the history
The commit updates the `file-search` API tests following the monaco upgrade
which introduced breaking changes to the way we deal with `QuickOpenItems`.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Jul 4, 2021
1 parent bc3b5e1 commit 3bd43c9
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions examples/api-tests/src/file-search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('file-search', function () {
const { assert } = chai;

const Uri = require('@theia/core/lib/common/uri');
const { QuickOpenItem } = require('@theia/core/lib/browser');
const { QuickFileOpenService } = require('@theia/file-search/lib/browser/quick-file-open');

/** @type {import('inversify').Container} */
Expand All @@ -32,25 +31,31 @@ describe('file-search', function () {
describe('#compareItems', () => {

it('should compare two quick-open-items by `label`', () => {
const a = new QuickOpenItem({ label: 'a', uri: new Uri.default('a') });
const b = new QuickOpenItem({ label: 'a', uri: new Uri.default('b') });

/** @type monaco.quickInput.IAnythingQuickPickItem */
const a = { label: 'a', resource: new Uri.default('a') };
/** @type monaco.quickInput.IAnythingQuickPickItem */
const b = { label: 'a', resource: new Uri.default('b') };

assert.equal(quickFileOpenService['compareItems'](a, b), 1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](b, a), -1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](a, a), 0, 'items should be equal');

assert.equal(quickFileOpenService['compareItems'](a, b, 'getLabel'), 1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](b, a, 'getLabel'), -1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](a, a, 'getLabel'), 0, 'items should be equal');
assert.equal(quickFileOpenService['compareItems'](a, b, 'label'), 1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](b, a, 'label'), -1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](a, a, 'label'), 0, 'items should be equal');
});

it('should compare two quick-open-items by `uri`', () => {
const a = new QuickOpenItem({ label: 'a', uri: new Uri.default('a') });
const b = new QuickOpenItem({ label: 'a', uri: new Uri.default('b') });

assert.equal(quickFileOpenService['compareItems'](a, b, 'getUri'), 1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](b, a, 'getUri'), -1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](a, a, 'getUri'), 0, 'items should be equal');
/** @type monaco.quickInput.IAnythingQuickPickItem */
const a = { label: 'a', resource: new Uri.default('a') };
/** @type monaco.quickInput.IAnythingQuickPickItem */
const b = { label: 'a', resource: new Uri.default('b') };

assert.equal(quickFileOpenService['compareItems'](a, b, 'resource'), 1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](b, a, 'resource'), -1, 'a should be before b');
assert.equal(quickFileOpenService['compareItems'](a, a, 'resource'), 0, 'items should be equal');
});

});
Expand Down

0 comments on commit 3bd43c9

Please sign in to comment.