-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage for
lib/table.js
(#178)
* Add tests initial tests for table.js * Add Table#select tests * Add table tests for handling of error cases - Is there a better way to rest the 'handler override' than switching to beforeEach/afterEach? * Add tests to Table#list * Add tests for Table#forEach * Remove unused fetchNextPage from select tests * Improve error tests by adding status and msg check * Improve forEach tests - Add tests with more than one record - Add test with no records - Add iteration counter to ensure all expectations are run * Ensure testing correct errors in select test * Use then with an error statement instead of catch To test that errors are thrown in tests. This way if tests unexpectly fufill the promise they immediately error instead of just timeing out.
- Loading branch information
Showing
8 changed files
with
577 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// istanbul ignore file | ||
'use strict'; | ||
|
||
var isArray = require('lodash/isArray'); | ||
|
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
var testHelpers = require('./test_helpers'); | ||
|
||
describe('record retrival', function() { | ||
var airtable; | ||
var testExpressApp; | ||
var teardownAsync; | ||
|
||
beforeAll(function() { | ||
return testHelpers.getMockEnvironmentAsync().then(function(env) { | ||
airtable = env.airtable; | ||
testExpressApp = env.testExpressApp; | ||
teardownAsync = env.teardownAsync; | ||
}); | ||
}); | ||
|
||
afterAll(function() { | ||
return teardownAsync(); | ||
}); | ||
|
||
it('can find one record', function() { | ||
var recordId = 'record1'; | ||
|
||
testExpressApp.set('handler override', function(req, res) { | ||
expect(req.method).toBe('GET'); | ||
expect(req.url).toBe('/v0/app123/Table/record1?'); | ||
res.json({ | ||
id: req.params.recordId, | ||
fields: {Name: 'Rebecca'}, | ||
createdTime: '2020-04-20T16:20:00.000Z', | ||
}); | ||
}); | ||
|
||
return airtable | ||
.base('app123') | ||
.table('Table') | ||
.find(recordId) | ||
.then(function(foundRecord) { | ||
expect(foundRecord.id).toBe(recordId); | ||
expect(foundRecord.get('Name')).toBe('Rebecca'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.