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 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
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
9 changes: 5 additions & 4 deletions airtable/functions/broadcast-sms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
exports.handler = function (context, event, callback) {
const response = new Twilio.Response();
import Airtable from 'airtable';

const Airtable = require('airtable');
//eslint-disable-import/no-unused-modules

Check failure on line 3 in airtable/functions/broadcast-sms.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 14)

Expected space or tab after '//' in comment

Check failure on line 3 in airtable/functions/broadcast-sms.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 16)

Expected space or tab after '//' in comment
export default function handler(context, event, callback) {

Check failure on line 4 in airtable/functions/broadcast-sms.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 14)

exported declaration 'default' not used within other modules

Check failure on line 4 in airtable/functions/broadcast-sms.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 16)

exported declaration 'default' not used within other modules
const response = new Twilio.Response();
const base = new Airtable({ apiKey: context.AIRTABLE_API_KEY }).base(
context.AIRTABLE_BASE_ID
);
Expand Down Expand Up @@ -34,4 +35,4 @@
.catch((err) => {
callback(err);
});
};
}
7 changes: 4 additions & 3 deletions airtable/functions/save-sms.protected.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Airtable = require('airtable');
import Airtable from 'airtable';

exports.handler = function (context, event, callback) {
//eslint-disable-import/no-unused-modules

Check failure on line 3 in airtable/functions/save-sms.protected.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 14)

Expected space or tab after '//' in comment

Check failure on line 3 in airtable/functions/save-sms.protected.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 16)

Expected space or tab after '//' in comment
export default function handler(context, event, callback) {

Check failure on line 4 in airtable/functions/save-sms.protected.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 14)

exported declaration 'default' not used within other modules

Check failure on line 4 in airtable/functions/save-sms.protected.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 16)

exported declaration 'default' not used within other modules
const twiml = new Twilio.twiml.MessagingResponse();

const base = new Airtable({ apiKey: context.AIRTABLE_API_KEY }).base(
Expand All @@ -22,4 +23,4 @@
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"
}
7 changes: 4 additions & 3 deletions airtable/tests/broadcast-sms.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const helpers = require('../../test/test-helper');
const broadcastSms = require('../functions/broadcast-sms').handler;
const Twilio = require('twilio');
import { afterAll, beforeAll, jest } from '@jest/globals';
import helpers from '../../test/test-helper';

const event = {};

Expand Down Expand Up @@ -37,6 +36,8 @@ jest.mock('airtable', () => {
});
});

const broadcastSms = (await import('../functions/broadcast-sms')).default;

const shouldFail = false;
const mockClient = {
messages: {
Expand Down
12 changes: 7 additions & 5 deletions airtable/tests/save-sms.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const helpers = require('../../test/test-helper');
const saveSms = require('../functions/save-sms.protected').handler;
const Twilio = require('twilio');

const event = {};
import { afterAll, beforeAll, jest } from '@jest/globals';
import helpers from '../../test/test-helper';
import Twilio from 'twilio';

const mockAirtableTable = {
create: jest.fn(() =>
Expand Down Expand Up @@ -30,6 +28,10 @@ jest.mock('airtable', () => {
});
});

const saveSms = (await import('../functions/save-sms.protected')).default;

const event = {};

const context = {
AIRTABLE_API_KEY: 'keyAbcD12efG3HijK',
AIRTABLE_BASE_ID: 'appAbcD12efG3HijK',
Expand Down
Loading
Loading