|
| 1 | +import { strictEqual } from 'assert'; |
| 2 | +import { |
| 3 | + isUri, |
| 4 | + isString, |
| 5 | + isNumber, |
| 6 | + isBoolean, |
| 7 | + isObject, |
| 8 | + isArray, |
| 9 | + isOptionalString, |
| 10 | + isArrayOfString, |
| 11 | + arraysEqual, |
| 12 | + isPositionInString, |
| 13 | +} from '../src/lib/helper'; |
| 14 | +import * as vscode from 'vscode'; |
| 15 | + |
| 16 | +suite('helper functions isTypeVariable tests', () => { |
| 17 | + test('isUri', () => { |
| 18 | + strictEqual(true, isUri(vscode.Uri.parse('file:///home/user/file.txt'))); |
| 19 | + }); |
| 20 | + test('isString', () => { |
| 21 | + strictEqual(true, isString('hello')); |
| 22 | + }); |
| 23 | + test('isNumber', () => { |
| 24 | + strictEqual(true, isNumber(1)); |
| 25 | + }); |
| 26 | + test('isBoolean', () => { |
| 27 | + strictEqual(true, isBoolean(true)); |
| 28 | + }); |
| 29 | + test('isObject', () => { |
| 30 | + strictEqual(true, isObject({})); |
| 31 | + }); |
| 32 | + test('isArray', () => { |
| 33 | + strictEqual(true, isArray([])); |
| 34 | + }); |
| 35 | + test('isOptionalString', () => { |
| 36 | + strictEqual(true, isOptionalString('hello')); |
| 37 | + strictEqual(true, isOptionalString(undefined)); |
| 38 | + }); |
| 39 | + test('isArrayOfString', () => { |
| 40 | + strictEqual(true, isArrayOfString(['hello'])); |
| 41 | + }); |
| 42 | + test('arraysEqual', () => { |
| 43 | + strictEqual(true, arraysEqual(['hello'], ['hello'])); |
| 44 | + strictEqual(false, arraysEqual(['hello'], [null])); |
| 45 | + strictEqual(false, arraysEqual(['hello'], ['hello', 'world'])); |
| 46 | + strictEqual(false, arraysEqual(['hello'], ['world'])); |
| 47 | + }); |
| 48 | +}); |
| 49 | + |
| 50 | +suite('helper functions general tests', () => { |
| 51 | + test('isPositionInString', async () => { |
| 52 | + const doc = await vscode.workspace.openTextDocument({ |
| 53 | + language: 'text', |
| 54 | + content: 'hello "world"', |
| 55 | + }); |
| 56 | + const pos = new vscode.Position(0, 7); |
| 57 | + strictEqual(true, isPositionInString(doc, pos)); |
| 58 | + }); |
| 59 | +}); |
0 commit comments