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

FRIDGE-683 ES6 template example #500

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
FRIDGE-683 try to update one example
  • Loading branch information
makserik committed Jan 17, 2024
commit d76e068d3df07c19fff5a1cdd249617b98c209dc
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ cypress/screenshots/
cypress/videos/
**/cypress/screenshots/
**/cypress/videos/
**/.twiliodeployinfo
**/.twiliodeployinfo
.idea
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
18
6 changes: 3 additions & 3 deletions airtable/functions/save-sms.protected.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Airtable = require('airtable');
import Airtable from 'airtable';

exports.handler = function (context, event, callback) {
export default function handler(context, event, callback) {
const twiml = new Twilio.twiml.MessagingResponse();

const base = new Airtable({ apiKey: context.AIRTABLE_API_KEY }).base(
Expand All @@ -22,4 +22,4 @@ exports.handler = function (context, event, callback) {
console.log(err);
callback(err);
});
};
}
3 changes: 2 additions & 1 deletion airtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"private": true,
"dependencies": {
"airtable": "^0.11.0"
}
},
"type": "module"
}
44 changes: 21 additions & 23 deletions airtable/tests/save-sms.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
const helpers = require('../../test/test-helper');
const saveSms = require('../functions/save-sms.protected').handler;
const Twilio = require('twilio');
import helpers from '../../test/test-helper';
import saveSms from '../functions/save-sms.protected';
import Twilio from 'twilio';
import { afterAll, beforeAll, jest } from '@jest/globals';

const event = {};

const mockAirtableTable = {
create: jest.fn(() =>
Promise.resolve({
err: 'This is an error message',
})
),
};

const mockAirtableBase = {
table: jest.fn().mockImplementation(() => {
return mockAirtableTable;
}),
};

const mockAirtableClient = {
base: jest.fn().mockImplementation(() => {
return mockAirtableBase;
}),
};

jest.mock('airtable', () => {
const mockAirtableTable = {
create: jest.fn(() =>
Promise.resolve({
err: 'This is an error message',
})
),
};
const mockAirtableBase = {
table: jest.fn().mockImplementation(() => {
return mockAirtableTable;
}),
};
const mockAirtableClient = {
base: jest.fn().mockImplementation(() => {
return mockAirtableBase;
}),
};
return jest.fn().mockImplementation(() => {
return mockAirtableClient;
});
Expand Down
Loading
Loading