Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More unit tests #22

Merged
merged 6 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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