blob: 108dfea8f1ef955f73082ca8451587baa4235787 [file] [log] [blame] [edit]
// Copyright 2025 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { FuchsiaDiagnostics } from '../../problem_matcher';
import { describe, it } from 'mocha';
import assert from 'assert';
import * as vscode from 'vscode';
describe('DiagnosticsCollectionTest', function () {
let case1 = [
'../../examples/file.cc:10:1: error: expected expression',
'../../examples/file.cc:15:3: note: this should be logged :)',
'The fog in SF is nicknamed Karl'
];
const case2 = [
'../../examples/file.cc:10:1: error: expected expression',
'../../examples/file.cc:10:1: error: expected expression',
];
const ext = vscode.extensions.getExtension('fuchsia-authors.vscode-fuchsia');
const diagnostics = new FuchsiaDiagnostics(ext?.packageJSON);
this.beforeEach(function () {
diagnostics.clear();
});
describe('for the problem matcher', function () {
it('Matched messages are set in the diagnostics collection', () => {
case1.forEach((msg) => {
diagnostics.match(msg);
});
let collection = diagnostics.get();
assert.equal(collection.length, 2);
});
it('Matched messages should not contain duplicates', () => {
case2.forEach((msg) => {
diagnostics.match(msg);
});
let collection = diagnostics.get();
assert.equal(collection.length, 1);
});
});
});