Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

feat(initial): initial bare bones implementation #2

Merged
merged 5 commits into from
Sep 16, 2016

Conversation

sethyates
Copy link

What does this PR do?

This is the first "real" implementation of the mock library. There's still some work to do, namely actually putting in place a unit test framework for the mock library itself. However, this does some things and adheres to the API documented here.

Why is this change being made?

This is the first step in implementing the code.

Where should the reviewer start?

GoogleTag.js

How was this tested? How can the reviewer verify your testing?

Untested currently :-(

What gif best describes this PR or how it makes you feel?

Completion checklist

  • The pull request has been appropriately labelled according to our conventions.
  • Documentation has been updated.
  • The change has unit & integration tests as appropriate.

no unit tests currently in place
Copy link

@jnewman jnewman left a comment

Choose a reason for hiding this comment

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

Amazing progress. 👍 as this is a progress PR.

{
"preset": "google",
"maximumLineLength": null,
"validateQuoteMarks": { "mark": "'", "escape": true }
Copy link

Choose a reason for hiding this comment

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

Does this mean we don't use "s even if we've got to escape?

Copy link
Author

Choose a reason for hiding this comment

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

per http://jscs.info/rule/validateQuoteMarks:

validateQuoteMarks

Requires all quote marks to be either the supplied value, or consistent if true

Types: Boolean, String or Object

Values:

  • """: all strings require double quotes
  • "'": all strings require single quotes
  • true: all strings require the quote mark first encountered in the source code
  • Object:
    • escape: allow the "other" quote mark to be used, but only to avoid having to escape
    • mark: the same effect as the non-object values
    • ignoreJSX: ignore JSX nodes

@@ -0,0 +1,3 @@
/**
* @typedef {SingleSize|MultiSize} GeneralSize
Copy link

Choose a reason for hiding this comment

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

Would be easier to understand if we had a description of purpose here.

* queue callbacks for when GPT is ready. These callbacks do not have to check
* {@link #apiReady} as they are guaranteed to execute once the API is set up.
*
* @property pubadsReady {boolean|undefined} Flag indicating that Pubads service
Copy link

Choose a reason for hiding this comment

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

Nit - you've flipped the order of the type and name

* This property will be simply `undefined` until {@link #enableServices()}
* is called and Pubads service is loaded and initialized.
*
* @property cmd {!Array<function()>|!CommandArray} Reference to the global
Copy link

Choose a reason for hiding this comment

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

Flipped again

this._addService(new CompanionAdsService(this));
this._addService(new ContentService(this));
this._addService(new PubAdsService(this));
this._title = null;
Copy link

Choose a reason for hiding this comment

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

Weird that this is null and others undefined. Guessing that's just how it is in the real one.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah...

*
* @param {string} key The targeting key to look for.
* @returns {!Array<string>} The values associated with this key, or an empty
* array if there is no such key.
Copy link

Choose a reason for hiding this comment

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

Nit - technically it returns an empty array if the value is undefined.

}

_getTargetingMap() {
return this._targeting;
Copy link

Choose a reason for hiding this comment

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

Might wanna clone this


/**
* Sets the slot-level preferences for SafeFrame configuration. Any unrecognized
* keys in the config object will be ignored. The entire config will be ignored
Copy link

Choose a reason for hiding this comment

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

Should we be validating the value

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, a later step.

@@ -0,0 +1,17 @@
/**
* This event is fired when a slot on the page has finished rendering. The event
* is fired by the service that rendered the slot. Example: To listen to
Copy link

Choose a reason for hiding this comment

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

Nit - To --> to

Copy link
Author

Choose a reason for hiding this comment

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

⌘+C, ⌘+V

@@ -2,3 +2,5 @@ import GoogleTag from './GoogleTag.js';

module.exports = new GoogleTag();

// Load this 1ms after this.
Copy link

@jnewman jnewman Sep 15, 2016

Choose a reason for hiding this comment

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

Nit - this should really say Defer loading until next tick. setTimeout just tries to ensure that at least that amount of time has passed

Copy link
Author

Choose a reason for hiding this comment

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

I think I'll actually just return the class from the library rather than an instance, so the caller can control when the _load event happens.

@jnewman
Copy link

jnewman commented Sep 16, 2016

LGTM just nits

@sethyates
Copy link
Author

Merging on LGTM

@sethyates sethyates merged commit e9652d4 into master Sep 16, 2016
@sethyates sethyates deleted the feature/initial branch September 16, 2016 07:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants