Skip to content

Commit

Permalink
More unit tests (#22)
Browse files Browse the repository at this point in the history
* copy tests

* oh yeah

* symlink copy test

* interesting edge test

* oops

* up threshold
  • Loading branch information
bdistin committed Oct 6, 2017
1 parent eaaa542 commit 1f542a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"test": "npx ava test/*.js",
"test:lint": "npx eslint src test && npx tslint 'typings/*.ts'",
"test:coverage": "npm run coverage && npx nyc check-coverage --lines 50 --functions 50 --branches 50",
"test:coverage": "npm run coverage && npx nyc check-coverage --lines 60 --functions 60 --branches 60",
"coverage": "npx nyc npm test",
"codacy": "npx nyc report --reporter=text-lcov | npx codacy-coverage",
"docs": "npx jsdoc -c ./.docstrap.json -R README.md",
Expand Down
24 changes: 24 additions & 0 deletions test/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ ava('File to New File Location', async test => {
test.true(stats.isFile());
});

ava('File to Existing File', async test => {
const newFile = tempFile();
const file = tempFile();
await nextra.copy(file, newFile);

const stats = await fs.statAsync(newFile);
test.true(stats.isFile());
});

ava('File to Existing File w/ errorOnExist', async test => {
const newFile = tempFile();
const file = tempFile();
await test.throws(nextra.copy(file, newFile, { overwrite: false, errorOnExist: true }));
});

ava('File to Empty Directory', async test => {
const emptyDir = tempDir();
const file = tempFile();
Expand Down Expand Up @@ -50,6 +65,15 @@ ava('Symlink to Empty Directory', async test => {
test.true(stats.isSymbolicLink());
});

ava('Symlink to Existing Symlink', async test => {
const newfile = tempSymlink();
const symlink = tempSymlink();
await nextra.copy(symlink, newfile);

const stats = await fs.lstatAsync(newfile);
test.true(stats.isSymbolicLink());
});

ava('Duplicated Directories', async test => {
const dir = tempDir();
tempFile(dir);
Expand Down
9 changes: 9 additions & 0 deletions test/createSymlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ ava('new file with non-existant directories', async test => {
test.true(stats.isSymbolicLink());
});

ava('relative source', async test => {
const file = './test/createSymlink.js';
const newfile = tempFileLoc();
await nextra.createSymlink(file, newfile);

const stats = await fs.lstatAsync(newfile);
test.true(stats.isSymbolicLink());
});

ava('new file (atomic shortcut)', async test => {
const file = tempFile();
const newfile = tempFileLoc();
Expand Down

0 comments on commit 1f542a0

Please sign in to comment.