|
| 1 | +import * as operationUtils from '../operationUtils' |
| 2 | + |
| 3 | +describe('run-operationUtils', () => { |
| 4 | + const node: any = { range: [54, 106] } |
| 5 | + const start: number = 100 |
| 6 | + const end: number = 101 |
| 7 | + const rangeAt: number = 1000 |
| 8 | + const modifyText: string = 'Change Code' |
| 9 | + const blankTest: string = '' |
| 10 | + |
| 11 | + it('insertTextAfter code to equal object', () => { |
| 12 | + expect(operationUtils.insertTextAfter(node, modifyText)).toStrictEqual({ |
| 13 | + range: [node.range[1], node.range[1]], |
| 14 | + text: modifyText, |
| 15 | + }) |
| 16 | + }) |
| 17 | + |
| 18 | + it('insertTextAfterRange code to equal object', () => { |
| 19 | + expect( |
| 20 | + operationUtils.insertTextAfterRange([start, end], modifyText) |
| 21 | + ).toStrictEqual({ range: [end, end], text: modifyText }) |
| 22 | + }) |
| 23 | + |
| 24 | + it('insertTextAt code to equal object', () => { |
| 25 | + expect(operationUtils.insertTextAt(rangeAt, modifyText)).toStrictEqual({ |
| 26 | + range: [rangeAt, rangeAt], |
| 27 | + text: modifyText, |
| 28 | + }) |
| 29 | + }) |
| 30 | + |
| 31 | + it('insertTextBefore code to equal object', () => { |
| 32 | + expect(operationUtils.insertTextBefore(node, modifyText)).toStrictEqual({ |
| 33 | + range: [node.range[0], node.range[0]], |
| 34 | + text: modifyText, |
| 35 | + }) |
| 36 | + }) |
| 37 | + |
| 38 | + it('insertTextBeforeRange code to equal object', () => { |
| 39 | + expect( |
| 40 | + operationUtils.insertTextBeforeRange([start, end], modifyText) |
| 41 | + ).toStrictEqual({ range: [start, start], text: modifyText }) |
| 42 | + }) |
| 43 | + |
| 44 | + it('remove code to equal object', () => { |
| 45 | + expect(operationUtils.remove(node)).toStrictEqual({ |
| 46 | + range: node.range, |
| 47 | + text: blankTest, |
| 48 | + }) |
| 49 | + }) |
| 50 | + |
| 51 | + it('removeRange code to equal object', () => { |
| 52 | + expect(operationUtils.removeRange([start, end])).toStrictEqual({ |
| 53 | + range: [start, end], |
| 54 | + text: blankTest, |
| 55 | + }) |
| 56 | + }) |
| 57 | + |
| 58 | + it('replaceText code to equal object', () => { |
| 59 | + expect(operationUtils.replaceText(node, modifyText)).toStrictEqual({ |
| 60 | + range: node.range, |
| 61 | + text: modifyText, |
| 62 | + }) |
| 63 | + }) |
| 64 | + |
| 65 | + it('replaceTextRange code to equal object', () => { |
| 66 | + expect( |
| 67 | + operationUtils.replaceTextRange(node.range, modifyText) |
| 68 | + ).toStrictEqual({ range: node.range, text: modifyText }) |
| 69 | + }) |
| 70 | +}) |
0 commit comments