-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from w3b3d3v/fix/name-missing-at-login-providers
Fix user storage to avoid saving empty data
- Loading branch information
Showing
4 changed files
with
93 additions
and
88 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 |
---|---|---|
|
@@ -5,56 +5,58 @@ jest.mock('@mailchimp/mailchimp_marketing', () => ({ | |
setConfig: jest.fn(), | ||
lists: { | ||
addListMember: jest.fn(), | ||
} | ||
}, | ||
})) | ||
|
||
describe('add User to list', function() { | ||
describe('add User to list', function () { | ||
beforeEach(() => { | ||
mailchimp.lists.addListMember.mockClear() | ||
}) | ||
it("Should add users to list correctly", async () => { | ||
it('Should add users to list correctly', async () => { | ||
const emailData = { | ||
user_email: "[email protected]", | ||
firstName: "John", | ||
lastName: "Doe", | ||
user_email: '[email protected]', | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
params: { | ||
cohort: "test", | ||
course: "test", | ||
cohort: 'cohort_list_id', | ||
course: 'course_list_id', | ||
}, | ||
} | ||
await addUserToList(emailData) | ||
expect(mailchimp.setConfig).toHaveBeenCalledTimes(1) | ||
expect(mailchimp.lists.addListMember).toHaveBeenCalledWith("test", { | ||
email_address: "[email protected]", | ||
expect(mailchimp.lists.addListMember).toHaveBeenCalledWith('cohort_list_id', { | ||
email_address: '[email protected]', | ||
status: 'subscribed', | ||
}) | ||
expect(mailchimp.lists.addListMember).toHaveBeenCalledWith('course_list_id', { | ||
email_address: '[email protected]', | ||
status: 'subscribed', | ||
}) | ||
|
||
expect(mailchimp.lists.addListMember).toHaveBeenCalledTimes(2) | ||
}) | ||
}) | ||
|
||
describe("create user in mailchimp", () => { | ||
describe('create user in mailchimp', () => { | ||
beforeEach(() => { | ||
mailchimp.lists.addListMember.mockClear() | ||
}) | ||
|
||
const user = { | ||
email: "[email protected]", | ||
firstName: "John", | ||
lastName: "Doe", | ||
email: '[email protected]', | ||
name: 'John', | ||
wallet_address: '0x1234567890abcdef', | ||
} | ||
|
||
it("Should create user in mailchimp", async () => { | ||
it('Should create user in mailchimp', async () => { | ||
await createUser(user) | ||
|
||
expect(mailchimp.lists.addListMember).toHaveBeenCalledWith("b578d43584", { | ||
email_address: "[email protected]", | ||
status: "subscribed", | ||
expect(mailchimp.lists.addListMember).toHaveBeenCalledWith('b578d43584', { | ||
email_address: '[email protected]', | ||
status: 'subscribed', | ||
merge_fields: { | ||
EMAIL: "[email protected]", | ||
FIRSTNAME: "John", | ||
LASTNAME: "Doe", | ||
NAME: 'John', | ||
WALLET: '0x1234567890abcdef', | ||
}, | ||
}) | ||
}) | ||
}) | ||
}) |
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