|
| 1 | +const isSubsequence = require('./isSubsequence'); |
| 2 | + |
| 3 | +describe('Is Subsequence', () => { |
| 4 | + it('should return true when s is an empty string', () => { |
| 5 | + const result = isSubsequence('', 'hello world'); |
| 6 | + expect(result).toBe(true); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should return true when s is a substring of t', () => { |
| 10 | + const result = isSubsequence('abc', 'aabbcc'); |
| 11 | + expect(result).toBe(true); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should return false when s is not a substring of t', () => { |
| 15 | + const result = isSubsequence('xyz', 'hello world'); |
| 16 | + expect(result).toBe(false); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should return true when s is equal to t', () => { |
| 20 | + const result = isSubsequence('hello', 'hello'); |
| 21 | + expect(result).toBe(true); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should return true when s is a single character', () => { |
| 25 | + const result = isSubsequence('o', 'hello world'); |
| 26 | + expect(result).toBe(true); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should handle edge cases when s is longer than t', () => { |
| 30 | + const result = isSubsequence('hello world', 'hello'); |
| 31 | + expect(result).toBe(false); |
| 32 | + }); |
| 33 | +}); |
0 commit comments