Example #1
0
      Ember.$(window).on('storage.torii', function(event){
        var storageEvent = event.originalEvent;

        var remoteIdFromEvent = PopupIdSerializer.deserialize(storageEvent.key);
        if (remoteId === remoteIdFromEvent){
          var data = parseMessage(storageEvent.newValue, keys);
          localStorage.removeItem(storageEvent.key);
          Ember.run(function() {
            resolve(data);
          });
        }
      });
test('.serialize returns null if passed undefined', function(assert){
  assert.equal(null, PopupIdSerializer.deserialize(undefined));
});
test('.deserialize returns null if not a properly serialized torii popup', function(assert){
  var serializedPopupId = "";

  assert.equal(null, PopupIdSerializer.deserialize(serializedPopupId));
});
test('.deserialize extracts the popup id from the serialized string', function(assert){
  var serializedPopupId = "torii-popup:gfedc123";

  assert.equal("gfedc123", PopupIdSerializer.deserialize(serializedPopupId));
});