Initial commit

Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com>
Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com>
Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com>
Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com>
Co-Authored-By: Johan  <4934465+joolsus@users.noreply.github.com>
Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com>
Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
Michael Cartner
2024-01-26 11:52:55 +01:00
commit b9c60b07dc
2789 changed files with 868795 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
const ActiveWarnings = require('./editorconnection.activewarnings');
describe('Tracks active warnings that are sent to the editor', ()=>{
let activeWarnings;
beforeEach(async ()=>{
activeWarnings = new ActiveWarnings();
});
test('Set and clear a warning', () => {
expect(activeWarnings.setWarning('testId', 'testKey', 'testWarning')).toBe(true);
//these warnings shouldnt exist
expect(activeWarnings.clearWarning('testId', 'otherKey')).toEqual(false);
expect(activeWarnings.clearWarning('otherId', 'testKey')).toEqual(false);
//this warning is the one we set
expect(activeWarnings.clearWarning('testId', 'testKey')).toEqual(true);
//and now the warning should be gone
expect(activeWarnings.clearWarning('testId', 'testKey')).toEqual(false);
});
test('Set and clear multiple warning on one node', () => {
expect(activeWarnings.setWarning('testId', 'testKey1', 'testWarning')).toBe(true);
expect(activeWarnings.setWarning('testId', 'testKey2', 'testWarning')).toBe(true);
expect(activeWarnings.clearWarning('testId', 'testKey1')).toEqual(true);
expect(activeWarnings.clearWarning('testId', 'testKey1')).toEqual(false);
expect(activeWarnings.clearWarning('testId', 'testKey2')).toEqual(true);
expect(activeWarnings.clearWarning('testId', 'testKey2')).toEqual(false);
});
test('Clear multiple warnings at once', () => {
expect(activeWarnings.setWarning('testId1', 'testKey1', 'testWarning')).toBe(true);
expect(activeWarnings.setWarning('testId1', 'testKey2', 'testWarning')).toBe(true);
expect(activeWarnings.setWarning('testId2', 'testKey1', 'testWarning')).toBe(true);
expect(activeWarnings.clearWarnings('testId3')).toEqual(false);
expect(activeWarnings.clearWarnings('testId1')).toEqual(true);
expect(activeWarnings.clearWarnings('testId1')).toEqual(false);
expect(activeWarnings.clearWarnings('testId2')).toEqual(true);
expect(activeWarnings.clearWarnings('testId2')).toEqual(false);
});
test('Set same warning multiple times', () => {
expect(activeWarnings.setWarning('testId', 'testKey', 'testWarning')).toBe(true);
expect(activeWarnings.setWarning('testId', 'testKey', 'testWarning')).toBe(false);
expect(activeWarnings.setWarning('testId', 'testKey', 'testWarning2')).toBe(true);
});
});