|
1 | | -import chai from 'chai'; |
| 1 | +import chai, { AssertionError } from 'chai'; |
2 | 2 |
|
3 | | -import { something } from '../index.js'; |
| 3 | +import chaiPosixPath from '../index.js'; |
4 | 4 |
|
5 | | -chai.should(); |
| 5 | +chai.use(chaiPosixPath); |
6 | 6 |
|
7 | | -describe('something', () => { |
8 | | - it('should work', async () => { |
9 | | - await something(); |
| 7 | +const should = chai.should(); |
| 8 | + |
| 9 | +describe('chaiPosixPath', () => { |
| 10 | + it('should handle win32 path', () => { |
| 11 | + 'foo\\bar'.should.be.posixPath('foo/bar'); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should handle posix path', () => { |
| 15 | + 'foo/bar'.should.be.posixPath('foo/bar'); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should handle chaining', () => { |
| 19 | + 'foo\\bar'.should.be.posixPath('foo/bar').that.is.a('string'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should handle negating path', () => { |
| 23 | + 'foo\\bar'.should.not.be.posixPath('foo'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should throw on mismatch', () => { |
| 27 | + should.Throw( |
| 28 | + () => { |
| 29 | + 'foo\\bar'.should.be.posixPath('foo'); |
| 30 | + }, |
| 31 | + AssertionError, |
| 32 | + // eslint-disable-next-line quotes |
| 33 | + `expected 'foo\\bar' to be 'foo' but got 'foo/bar'` |
| 34 | + ); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should throw on negative mismatch', () => { |
| 38 | + should.Throw( |
| 39 | + () => { |
| 40 | + 'foo\\bar'.should.not.be.posixPath('foo/bar'); |
| 41 | + }, |
| 42 | + AssertionError, |
| 43 | + // eslint-disable-next-line quotes |
| 44 | + `expected 'foo\\bar' to not be matching 'foo/bar'` |
| 45 | + ); |
| 46 | + }); |
| 47 | + |
| 48 | + it('should throw on invalid entry value', () => { |
| 49 | + should.Throw( |
| 50 | + () => { |
| 51 | + const value = 123; |
| 52 | + value.should.be.posixPath('foo'); |
| 53 | + }, |
| 54 | + AssertionError, |
| 55 | + 'expected 123 to be a string' |
| 56 | + ); |
| 57 | + }); |
| 58 | + |
| 59 | + it('should throw on invalid target value', () => { |
| 60 | + should.Throw( |
| 61 | + () => { |
| 62 | + // @ts-ignore |
| 63 | + 'foo\\bar'.should.be.posixPath(456); |
| 64 | + }, |
| 65 | + AssertionError, |
| 66 | + 'expected 456 to be a string' |
| 67 | + ); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should throw when both are invalid', () => { |
| 71 | + should.Throw( |
| 72 | + () => { |
| 73 | + const value = 123; |
| 74 | + // @ts-ignore |
| 75 | + value.should.be.posixPath(456); |
| 76 | + }, |
| 77 | + AssertionError, |
| 78 | + 'expected 123 to be a string' |
| 79 | + ); |
10 | 80 | }); |
11 | 81 | }); |
0 commit comments