pwd-fs 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib → dist}/src/powered-file-system.d.ts +4 -4
- package/{lib → dist}/src/powered-file-system.js +4 -4
- package/package.json +4 -4
- package/src/powered-file-system.ts +17 -32
- package/test/read.spec.ts +4 -4
- package/tsconfig.json +2 -7
- package/lib/test/__fmock.d.ts +0 -5
- package/lib/test/__fmock.js +0 -40
- package/lib/test/append.spec.d.ts +0 -1
- package/lib/test/append.spec.js +0 -58
- package/lib/test/bitmask.spec.d.ts +0 -1
- package/lib/test/bitmask.spec.js +0 -26
- package/lib/test/chmod.spec.d.ts +0 -1
- package/lib/test/chmod.spec.js +0 -62
- package/lib/test/chown.spec.d.ts +0 -1
- package/lib/test/chown.spec.js +0 -74
- package/lib/test/constructor.spec.d.ts +0 -1
- package/lib/test/constructor.spec.js +0 -17
- package/lib/test/copy.spec.d.ts +0 -1
- package/lib/test/copy.spec.js +0 -80
- package/lib/test/mkdir.spec.d.ts +0 -1
- package/lib/test/mkdir.spec.js +0 -90
- package/lib/test/read.spec.d.ts +0 -1
- package/lib/test/read.spec.js +0 -73
- package/lib/test/readdir.spec.d.ts +0 -1
- package/lib/test/readdir.spec.js +0 -70
- package/lib/test/remove.spec.d.ts +0 -1
- package/lib/test/remove.spec.js +0 -63
- package/lib/test/rename.spec.d.ts +0 -1
- package/lib/test/rename.spec.js +0 -66
- package/lib/test/stat.spec.d.ts +0 -1
- package/lib/test/stat.spec.js +0 -76
- package/lib/test/symlink.spec.d.ts +0 -1
- package/lib/test/symlink.spec.js +0 -74
- package/lib/test/test.spec.d.ts +0 -1
- package/lib/test/test.spec.js +0 -60
- package/lib/test/write.spec.d.ts +0 -1
- package/lib/test/write.spec.js +0 -82
- /package/{lib → dist}/src/bitmask.d.ts +0 -0
- /package/{lib → dist}/src/bitmask.js +0 -0
- /package/{lib → dist}/src/index.d.ts +0 -0
- /package/{lib → dist}/src/index.js +0 -0
- /package/{lib → dist}/src/recurse-io-sync.d.ts +0 -0
- /package/{lib → dist}/src/recurse-io-sync.js +0 -0
- /package/{lib → dist}/src/recurse-io.d.ts +0 -0
- /package/{lib → dist}/src/recurse-io.js +0 -0
package/lib/test/write.spec.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const chance_1 = __importDefault(require("chance"));
|
|
9
|
-
const expect_1 = require("expect");
|
|
10
|
-
const __fmock_1 = require("./__fmock");
|
|
11
|
-
const src_1 = require("../src");
|
|
12
|
-
describe('write(src, data[, options])', () => {
|
|
13
|
-
const chance = new chance_1.default();
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
(0, __fmock_1.fmock)({
|
|
16
|
-
'./tmpdir/tings.txt': {
|
|
17
|
-
type: 'file',
|
|
18
|
-
data: chance.string()
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
(0, __fmock_1.restore)('./tmpdir');
|
|
24
|
-
});
|
|
25
|
-
it('Positive: Must write content to file', async () => {
|
|
26
|
-
const payload = chance.paragraph();
|
|
27
|
-
const guid = chance.guid();
|
|
28
|
-
await src_1.pfs.write(`./tmpdir/${guid}.txt`, payload);
|
|
29
|
-
const { size } = node_fs_1.default.lstatSync(`./tmpdir/${guid}.txt`);
|
|
30
|
-
(0, node_assert_1.default)(payload.length === size);
|
|
31
|
-
});
|
|
32
|
-
it('Positive: Must rewrite content if file already exists', async () => {
|
|
33
|
-
const payload = chance.paragraph();
|
|
34
|
-
await src_1.pfs.write('./tmpdir/tings.txt', payload);
|
|
35
|
-
const { size } = node_fs_1.default.lstatSync('./tmpdir/tings.txt');
|
|
36
|
-
(0, node_assert_1.default)(payload.length === size);
|
|
37
|
-
});
|
|
38
|
-
it('Negative: Throw if resource is directory', async () => {
|
|
39
|
-
const payload = chance.paragraph();
|
|
40
|
-
await (0, expect_1.expect)(async () => {
|
|
41
|
-
await src_1.pfs.write('./tmpdir', payload);
|
|
42
|
-
})
|
|
43
|
-
.rejects
|
|
44
|
-
.toThrow();
|
|
45
|
-
});
|
|
46
|
-
it(`Negative: Unexpected option 'flag' returns Error`, async () => {
|
|
47
|
-
const payload = chance.paragraph();
|
|
48
|
-
await (0, expect_1.expect)(async () => {
|
|
49
|
-
await src_1.pfs.write('./tmpdir/tings.txt', payload, {
|
|
50
|
-
flag: 'r'
|
|
51
|
-
});
|
|
52
|
-
})
|
|
53
|
-
.rejects
|
|
54
|
-
.toThrow();
|
|
55
|
-
});
|
|
56
|
-
it('[sync] Positive: Write contents even to a non-existent file', () => {
|
|
57
|
-
const payload = chance.paragraph();
|
|
58
|
-
const guid = chance.guid();
|
|
59
|
-
src_1.pfs.write(`./tmpdir/${guid}.txt`, payload, {
|
|
60
|
-
sync: true
|
|
61
|
-
});
|
|
62
|
-
const content = node_fs_1.default.readFileSync(`./tmpdir/${guid}.txt`, 'utf8');
|
|
63
|
-
(0, node_assert_1.default)(payload === content);
|
|
64
|
-
});
|
|
65
|
-
it('[sync] Negative: Throw if resource is directory', () => {
|
|
66
|
-
const payload = chance.paragraph();
|
|
67
|
-
node_assert_1.default.throws(() => {
|
|
68
|
-
src_1.pfs.write('./tmpdir', payload, {
|
|
69
|
-
sync: true
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
it(`[sync] Negative: Unexpected option 'flag' returns Error`, () => {
|
|
74
|
-
const payload = chance.paragraph();
|
|
75
|
-
node_assert_1.default.throws(() => {
|
|
76
|
-
src_1.pfs.write('./tmpdir/tings.txt', payload, {
|
|
77
|
-
sync: true,
|
|
78
|
-
flag: 'r'
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|