Skip to content

Commit

Permalink
add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdistin committed Mar 12, 2019
1 parent df51ab7 commit 1e53b16
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
32 changes: 31 additions & 1 deletion test/targz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ ava('File', async test => {
test.true(stats.isFile());
});

ava('Files', async test => {
test.plan(2);

const file1 = tempFileLoc();
await nextra.writeFile(file1, 'test1', 'utf8');
const file2 = tempFileLoc();
await nextra.writeFile(file2, 'test2', 'utf8');
const fileName = `${tempFileLoc()}.tar.gz`;
const retVal = await nextra.targz(fileName, [file1, file2]);
const stats = await fs.stat(fileName);

test.is(retVal, undefined);
test.true(stats.isFile());
});

ava('Directory', async test => {
test.plan(2);

Expand Down Expand Up @@ -43,6 +58,21 @@ ava('File (Atomic Shortcut)', async test => {
test.true(stats.isFile());
});

ava('Files (Atomic Shortcut)', async test => {
test.plan(2);

const file1 = tempFileLoc();
await nextra.writeFile(file1, 'test1', 'utf8');
const file2 = tempFileLoc();
await nextra.writeFile(file2, 'test2', 'utf8');
const fileName = `${tempFileLoc()}.tar.gz`;
const retVal = await nextra.targz(fileName, [file1, file2], true);
const stats = await fs.stat(fileName);

test.is(retVal, undefined);
test.true(stats.isFile());
});

ava('Directory (Atomic Shortcut)', async test => {
test.plan(2);

Expand All @@ -55,4 +85,4 @@ ava('Directory (Atomic Shortcut)', async test => {

test.is(retVal, undefined);
test.true(stats.isFile());
});
});
15 changes: 15 additions & 0 deletions test/targzAtomic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ ava('File', async test => {
test.true(stats.isFile());
});

ava('Files', async test => {
test.plan(2);

const file1 = tempFileLoc();
await nextra.writeFile(file1, 'test1', 'utf8');
const file2 = tempFileLoc();
await nextra.writeFile(file2, 'test2', 'utf8');
const fileName = `${tempFileLoc()}.tar.gz`;
const retVal = await nextra.targzAtomic(fileName, [file1, file2]);
const stats = await fs.stat(fileName);

test.is(retVal, undefined);
test.true(stats.isFile());
});

ava('Directory', async test => {
test.plan(2);

Expand Down

0 comments on commit 1e53b16

Please sign in to comment.