data_test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2014 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.soy.dataTest');
  15. goog.setTestOnly('goog.soy.dataTest');
  16. goog.require('goog.html.SafeHtml');
  17. goog.require('goog.html.SafeUrl');
  18. /** @suppress {extraRequire} */
  19. goog.require('goog.soy.testHelper');
  20. goog.require('goog.testing.jsunit');
  21. function testToSafeHtml() {
  22. var html;
  23. html = example.unsanitizedTextTemplate().toSafeHtml();
  24. assertEquals(
  25. 'I <3 Puppies & Kittens', goog.html.SafeHtml.unwrap(html));
  26. html = example.sanitizedHtmlTemplate().toSafeHtml();
  27. assertEquals('Hello <b>World</b>', goog.html.SafeHtml.unwrap(html));
  28. }
  29. function testToSafeUrl() {
  30. var url;
  31. url = example.sanitizedSmsUrlTemplate().toSafeUrl();
  32. assertEquals('sms:123456789', goog.html.SafeUrl.unwrap(url));
  33. url = example.sanitizedHttpUrlTemplate().toSafeUrl();
  34. assertEquals('https://google.com/foo?n=917', goog.html.SafeUrl.unwrap(url));
  35. }