can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r12031: LJSUP-11909: Fast Repost feature. Add te...

Committer: dpetrov
LJSUP-11909: Fast Repost feature. Add tests for LJ.Util.Journal.parseLink function.
U   trunk/htdocs/js/test/basic.js
Modified: trunk/htdocs/js/test/basic.js
===================================================================
--- trunk/htdocs/js/test/basic.js	2012-05-30 11:30:33 UTC (rev 12030)
+++ trunk/htdocs/js/test/basic.js	2012-05-30 11:35:02 UTC (rev 12031)
@@ -45,3 +45,58 @@
 	throttledIncr(); throttledIncr();
 	setTimeout(function(){ equal(counter, 2, "incr was called twice"); start(); }, 220);
 });
+
+
+module('LJ.Util.Journal');
+
+test('test garbage', function() {
+	equal(null, LJ.Util.Journal.parseLink('http://ya.ru'));
+});
+
+test('link with missed slashed', function() {
+	equal(null, LJ.Util.Journal.parseLink('http://can3p.livejournal.com95681.html'));
+	equal(null, LJ.Util.Journal.parseLink('http://users.livejournal.com__galadriel__23674.html'));
+});
+
+test('new style link', function() {
+	var link = LJ.Util.Journal.parseLink('http://can3p.livejournal.com/95681.html');
+	 
+	equal( 'can3p', link.journal );
+	equal( 95681, link.ditemid );
+});
+
+test('new style journal link', function() {
+	var link = LJ.Util.Journal.parseLink('http://can3p.livejournal.com');
+	 
+	equal( 'can3p', link.journal );
+	equal( undefined, link.ditemid );
+});
+
+test('new style journal link with ending slash', function() {
+	var link = LJ.Util.Journal.parseLink('http://can3p.livejournal.com/');
+	 
+	equal( 'can3p', link.journal );
+	equal( undefined, link.ditemid );
+});
+
+test('old style full link', function() {
+	var link = LJ.Util.Journal.parseLink('http://users.livejournal.com/__galadriel__/23674.html');
+	 
+	equal( '__galadriel__', link.journal );
+	equal( 23674, link.ditemid );
+	
+});
+
+test('old style journal link', function() {
+	var link = LJ.Util.Journal.parseLink('http://users.livejournal.com/__galadriel__');
+	 
+	equal( '__galadriel__', link.journal );
+	equal( undefined, link.ditemid );
+});
+
+test('old style journal link with ending slash', function() {
+	var link = LJ.Util.Journal.parseLink('http://users.livejournal.com/__galadriel__/');
+	 
+	equal( '__galadriel__', link.journal );
+	equal( undefined, link.ditemid );
+});

Tags: can3p, dpetrov, js, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments