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

Stabilize Circle CI Build Job #5208

Merged
merged 3 commits into from
May 21, 2020
Merged
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
6 changes: 3 additions & 3 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ describe('User ID', function() {
sandbox = sinon.createSandbox();
sandbox.stub(global, 'setTimeout').returns(2);
sandbox.stub(events, 'on');
sandbox.stub(coreStorage, 'getCookie');

// remove cookie
coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE);
Expand Down Expand Up @@ -626,11 +627,10 @@ describe('User ID', function() {
});

it('does not delay auction if there are no ids to fetch', function() {
coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString());

coreStorage.getCookie.withArgs('MOCKID').returns('123456778');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate this fix ? Original test is setting cookie and you updated it to get cookie. Does this change the unit test completely ?
Also you reduced the auction delay to 33. What do we achieve by doing that ?

Copy link
Contributor Author

@Fawke Fawke May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaiminpanchal27
I mocked getCookie function because at this line, coreStorage.getCookie is returning undefined. Because of this, the test case was failing half of the times.

Ideally, while unit testing a module, we should not be calling any external library or functions. So, I mocked it to return a set value.

Auction delay was previously set to 33, in this PR I changed it to 200, but that fix didn't work. So kinda, reverting it back. Anyway, auctionDelay should not matter much to the outcome of this test, whatever we set it to.

config.setConfig({
usersync: {
auctionDelay: 200,
auctionDelay: 33,
syncDelay: 77,
userIds: [{
name: 'mockId', storage: { name: 'MOCKID', type: 'cookie' }
Expand Down