-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6338421
commit 68439db
Showing
6 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renameSync(fromPath, toPath) Throws if path is of wrong type 1`] = `"path must be a string or Buffer"`; | ||
|
||
exports[`renameSync(fromPath, toPath) Throws on no params 1`] = `"path must be a string or Buffer"`; | ||
|
||
exports[`renameSync(fromPath, toPath) Throws on only one param 1`] = `"path must be a string or Buffer"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {create} from "../util"; | ||
|
||
|
||
describe('renameSync(fromPath, toPath)', () => { | ||
it('Renames a simple case', done => { | ||
const vol = create({'/foo': 'bar'}); | ||
vol.rename('/foo', '/foo2', (err, res) => { | ||
expect(vol.toJSON()).toEqual({'/foo2': 'bar'}); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {create} from "../util"; | ||
|
||
|
||
describe('renameSync(fromPath, toPath)', () => { | ||
it('Renames a file', () => { | ||
const vol = create({'/foo': 'bar'}); | ||
expect(vol.root.getChild('foo').getNode().isFile()).toBe(true); | ||
vol.renameSync('/foo', '/baz'); | ||
expect(vol.root.getChild('foo')).toBeUndefined(); | ||
expect(vol.root.getChild('baz').getNode().isFile()).toBe(true); | ||
expect(vol.readFileSync('/baz', 'utf8')).toBe('bar'); | ||
}); | ||
it('Rename file two levels deep', () => { | ||
const vol = create({'/1/2': 'foobar'}); | ||
vol.renameSync('/1/2', '/1/3'); | ||
expect(vol.toJSON()).toEqual({'/1/3': 'foobar'}); | ||
}); | ||
it('Rename file three levels deep', () => { | ||
const vol = create({ | ||
'/foo1': 'bar', | ||
'/foo2/foo': 'bar', | ||
'/foo3/foo/foo': 'bar', | ||
}); | ||
vol.renameSync('/foo3/foo/foo', '/foo3/foo/foo2'); | ||
expect(vol.toJSON()).toEqual({ | ||
'/foo1': 'bar', | ||
'/foo2/foo': 'bar', | ||
'/foo3/foo/foo2': 'bar', | ||
}); | ||
}); | ||
it('Throws on no params', () => { | ||
const vol = create(); | ||
expect(() => { | ||
(vol as any).renameSync(); | ||
}).toThrowErrorMatchingSnapshot() | ||
}); | ||
it('Throws on only one param', () => { | ||
const vol = create({'/foo': 'bar'}); | ||
expect(() => { | ||
(vol as any).renameSync('/foo'); | ||
}).toThrowErrorMatchingSnapshot() | ||
}); | ||
it('Throws if path is of wrong type', () => { | ||
const vol = create({'/foo': 'bar'}); | ||
expect(() => { | ||
(vol as any).renameSync('/foo', 123); | ||
}).toThrowErrorMatchingSnapshot() | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters