-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace Q with Bluebird, close #4
- Loading branch information
Showing
4 changed files
with
111 additions
and
33 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 |
---|---|---|
@@ -1,29 +1,70 @@ | ||
var la = require('lazy-ass'); | ||
var check = require('check-more-types'); | ||
var folders = require('..'); | ||
var join = require('path').join; | ||
var parentFolder = join(process.cwd(), '..') | ||
|
||
la(check.object(folders), 'expected folders to be an object', folders); | ||
la(check.fn(folders.to), 'expected folders.to to be a function', folders); | ||
|
||
folders.to(__dirname) | ||
.then(folders.back) | ||
.then(folders.to(__dirname)) | ||
.then(folders.from) | ||
.then(folders.to(__dirname)) | ||
.then(function () { | ||
return 'foo'; | ||
const la = require('lazy-ass') | ||
const is = require('check-more-types') | ||
|
||
/* eslint-env mocha */ | ||
describe('chdir-promise', () => { | ||
const chdir = require('..') | ||
const originalFolder = process.cwd() | ||
|
||
const here = () => | ||
la( | ||
process.cwd() === __dirname, | ||
'expected to be in', | ||
__dirname, | ||
'but was in', | ||
process.cwd() | ||
) | ||
|
||
const inOriginal = () => | ||
la( | ||
process.cwd() === originalFolder, | ||
'expected to be in', | ||
originalFolder, | ||
'but was in', | ||
process.cwd() | ||
) | ||
|
||
it('has to method', () => { | ||
la(is.fn(chdir.to)) | ||
}) | ||
|
||
it('starts in original folder', () => { | ||
inOriginal() | ||
}) | ||
.tap(folders.back) | ||
.then(function (result) { | ||
la(result === 'foo', 'incorrect result', result); | ||
|
||
it('changes folders once', () => { | ||
return chdir | ||
.to(__dirname) | ||
.then(here) | ||
.then(chdir.back) | ||
.then(inOriginal) | ||
}) | ||
|
||
it('changes folders twice', () => { | ||
return chdir | ||
.to(__dirname) | ||
.then(here) | ||
.then(chdir.back) | ||
.then(inOriginal) | ||
.then(_ => chdir.to(__dirname)) | ||
.then(here) | ||
.then(chdir.back) | ||
.then(inOriginal) | ||
}) | ||
|
||
context('back', () => { | ||
it('is a function', () => { | ||
la(is.fn(chdir.back)) | ||
}) | ||
|
||
it('returns a promise', () => { | ||
return chdir | ||
.to(__dirname) | ||
.then(here) | ||
.then(_ => chdir.back().then(_ => 'foo')) | ||
.then(value => { | ||
la(value === 'foo', 'got', value) | ||
}) | ||
}) | ||
}) | ||
.done(); | ||
|
||
// .back() returns a promise | ||
folders.to(parentFolder) | ||
.then(function () { | ||
return folders.back() | ||
.then(function () {}) | ||
}).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,32 @@ | ||
const la = require('lazy-ass') | ||
const check = require('check-more-types') | ||
const folders = require('..') | ||
// const join = require('path').join | ||
// const parentFolder = join(process.cwd(), '..') | ||
|
||
la(check.object(folders), 'expected folders to be an object', folders) | ||
la(check.fn(folders.to), 'expected folders.to to be a function', folders) | ||
|
||
folders | ||
.to(__dirname) | ||
.then(folders.back) | ||
.then(() => folders.to(__dirname)) | ||
.then(folders.from) | ||
.then(() => folders.to(__dirname)) | ||
.then(function () { | ||
return 'foo' | ||
}) | ||
.tap(folders.back) | ||
.then(function (result) { | ||
la(result === 'foo', 'incorrect result', result) | ||
console.log('result', result) | ||
}) | ||
.done() | ||
|
||
// .back() returns a promise | ||
// folders | ||
// .to(parentFolder) | ||
// .then(function () { | ||
// return folders.back().then(function () {}) | ||
// }) | ||
// .done() |